From 581f3352bc56c905069aba9933fe4cc7b761146f Mon Sep 17 00:00:00 2001 From: Ralph Caraveo III Date: Sun, 27 Apr 2014 21:07:23 -0700 Subject: [PATCH] Found bug, switch fallthrough is not automatic in Go --- HTML5-CDGPlayer_files/blank.png | Bin 972 -> 661 bytes .../cdgmagic_cdgdecoder_lowresource.go | 21 +++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/HTML5-CDGPlayer_files/blank.png b/HTML5-CDGPlayer_files/blank.png index d884bea3839dbd941627818490a4e2ff40e2bc61..566fce38b8e34c7bef5cc4b92d395b64098801da 100644 GIT binary patch literal 661 zcmeAS@N?(olHy`uVBq!ia0y~yU{nCI4{)#n$t4^1ZDU|yit%)D45^s&=8B^r0|N(( z;_-hA^^eslu+%dMGBQezqR|i_D+Fe;GBEuAU;dD>QDE^ELtt`a@O1TaS?83{1OV|; BEg=8^ literal 972 zcmeAS@N?(olHy`uVBq!ia0y~yU{nCI4{)#n$t4^1ZDU|yp6u!37*a9k&0WW$%LWV% z7pJ_OxZ^)(mHG@m=9~qNE02Uf`94k2!b!}&%;m-Fw`IS}n8PY1YyK_$XIHn9ogrpA z1EVA(lMxe33Jb>x4uJ`R3JS^&4sHz%JtRncj^bzFD_=SPv*{^OBqPo|Vc6?yb?ijp zzi)po9(O-$^-uY{eC?hY?fu70s^;|9oll=1J@@#<$7d|Q?R~sHM!o(SS4aJpJi&KA zcUfEI>+#)a`)~E*$E)lAVNk3?YZ^qEAD=>dAFtQTA%73Cad+&KChj#*j;Q| z@wR(?jxp-{ST`?-zPhOF-p_{((Hn&4{CsEDzVqkXJv%=re$n4tmYDXg?ah-&vH!PX zXBY17O}}#M<8G#;Vteubn^`^>#ihxp@Lc%abnE5ZhZ9-rw#IHq|FQY4*|EFFHc$T{ zcIIT`UfJEe=SwReSDx`J=PBm6uypSB1(At&rP~-{r~P=7dF=bEcQ>DNg*4cuex3gP zTcpNo+uvnheU47wCB5z8%{x<-YR>oUype5p|NE!E^S2&Yq4}ThgsucMz?c0Is5)h< z@?lR5Bcb?Ui0RiRCz42y)=?dV;sQO>ocRvSnE(H~lzPu|ZuvY1$YJnw^>bP0l+XkK Dw`)(X diff --git a/HTML5-CDGPlayer_files/cdgmagic_cdgdecoder_lowresource.go b/HTML5-CDGPlayer_files/cdgmagic_cdgdecoder_lowresource.go index 8c8c0c4..19893b9 100644 --- a/HTML5-CDGPlayer_files/cdgmagic_cdgdecoder_lowresource.go +++ b/HTML5-CDGPlayer_files/cdgmagic_cdgdecoder_lowresource.go @@ -80,7 +80,7 @@ var ( internal_rgba_imagedata = make([]uint8, 0) internal_usedirtyrect = true - internal_border_index = byte(0x00) // The current border palette index. + internal_border_index = 0x00 // The current border palette index. internal_current_pack = 0x00 internal_border_dirty = false @@ -95,11 +95,13 @@ func main() { fmt.Println("Compiles baby!") + //load data cdg_file_data, err := ioutil.ReadFile("../SC-SBI-REMIX - Billy Idol - Rebel Yell.cdg") if err != nil { log.Fatal("Couldn't read .cdg file") } + //loop through some bytes for i := 0; i < 19000; i++ { decode_packs(cdg_file_data, i) redrawCanvas() @@ -224,16 +226,13 @@ func decode_packs(cdg_file_data []byte, playback_position int) { case BORDER_PRESET: proc_BORDER_PRESET(this_pack) - case LOAD_CLUT_LO: - case LOAD_CLUT_HI: + case LOAD_CLUT_LO, LOAD_CLUT_HI: proc_LOAD_CLUT(this_pack) - case COPY_FONT: - case XOR_FONT: + case COPY_FONT, XOR_FONT: proc_WRITE_FONT(this_pack) - case SCROLL_PRESET: - case SCROLL_COPY: + case SCROLL_PRESET, SCROLL_COPY: proc_DO_SCROLL(this_pack) } @@ -447,7 +446,7 @@ func proc_BORDER_PRESET(cdg_pack []byte) { // NOTE: The "border" is actually a DIV element, which can be very expensive to change in some browsers. // This somewhat bizarre check ensures that the DIV is only touched if the actual RGB color is different, // but the border index variable is always set... A similar check is also performed during palette update. - new_border_index := cdg_pack[4] & 0x3F // Get the border index from subcode. + new_border_index := int(cdg_pack[4] & 0x3F) // Get the border index from subcode. // Check if the new border **RGB** color is different from the old one. if internal_palette[new_border_index] != internal_palette[internal_border_index] { internal_border_dirty = true // Border needs updating. @@ -463,10 +462,10 @@ func proc_MEMORY_PRESET(cdg_pack []byte) { func proc_LOAD_CLUT(cdg_pack []byte) { // If instruction is 0x1E then 8*0=0, if 0x1F then 8*1=8 for offset. - pal_offset := (cdg_pack[1] & 0x01) * 8 + pal_offset := int((cdg_pack[1] & 0x01) * 8) // Step through the eight color indices, setting the RGB values. for pal_inc := 0; pal_inc < 8; pal_inc++ { - temp_idx := byte(pal_inc) + pal_offset + temp_idx := pal_inc + pal_offset temp_rgb := byte(0x00000000) temp_entry := byte(0x00000000) // Set red. @@ -489,6 +488,8 @@ func proc_LOAD_CLUT(cdg_pack []byte) { } // The border color has changed. } } + + fmt.Println(internal_palette) } func proc_WRITE_FONT(cdg_pack []byte) {