├── AnalysisDefleMaskData └── README.txt ├── DirectBgRenderingTest1 ├── DirectBgRenderingTest1.gbc └── main.asm ├── LICENSE ├── README.md ├── RunLengthEncodeDecode ├── RunLengthEncoder.php ├── a.sh ├── bg_tile0_1024.bin ├── bg_tile0_compress.bin ├── bg_tile1_1024.bin ├── bg_tile1_compress.bin ├── main.asm ├── test_RunLengthDecoder.php └── tiles.bin ├── SoundDriver ├── a.sh ├── gbsd.inc ├── gbsd_macro.inc ├── gbsd_musical_scale_tbl.inc ├── gbsd_sound_data_tbl.inc ├── main.asm ├── resource │ └── musical_scale_list.xlsx ├── rom │ ├── sound_driver_v01.gb │ ├── sound_driver_v010.gb │ ├── sound_driver_v02.gb │ ├── sound_driver_v03.gb │ ├── sound_driver_v04.gb │ ├── sound_driver_v05.gb │ ├── sound_driver_v06.gb │ ├── sound_driver_v07.gb │ ├── sound_driver_v08.gb │ └── sound_driver_v09.gb └── tools │ ├── AnalysisDefleMaskData.php │ ├── convDMF2Hex.php │ ├── dmf │ ├── test_v010.dmf │ ├── test_v04.dmf │ ├── test_v05.dmf │ ├── test_v06.dmf │ ├── test_v08.dmf │ └── test_v09.dmf │ ├── init.php │ ├── templates │ └── gbsd_sound_data_tbl.inc │ └── test.dmf ├── SoundEditor ├── a.sh ├── bg_tile0.inc ├── bg_tile1.inc ├── bg_tile_win0.inc ├── bg_tile_win1.inc ├── conv.php ├── data.inc ├── equ.inc ├── macro.inc ├── main.asm ├── map_editor.txt ├── map_editor_win.txt ├── rom │ ├── sound_editor_v01.gbc │ ├── sound_editor_v02.gbc │ ├── sound_editor_v03.gbc │ ├── sound_editor_v04.gbc │ ├── sound_editor_v05.gbc │ └── sound_editor_v06.gbc ├── sprites.bin ├── sprites.gbr ├── tiles.bin ├── tiles.gbr └── wram.inc ├── car_game ├── data.inc ├── equ.inc ├── main.asm ├── map.bin ├── material │ ├── car.aseprite │ ├── map.gbm │ └── tiles.gbr ├── rom │ ├── car_game_v01.gbc │ ├── car_game_v010.gbc │ ├── car_game_v011.gbc │ ├── car_game_v02.gbc │ ├── car_game_v03.gbc │ ├── car_game_v04.gbc │ ├── car_game_v05.gbc │ ├── car_game_v06.gbc │ ├── car_game_v07.gbc │ ├── car_game_v08.gbc │ └── car_game_v09.gbc ├── sound_asm.inc ├── sound_equ.inc ├── sound_tbl.inc ├── tiles.bin └── wram.inc ├── car_game01 ├── data.inc ├── equ.inc ├── macro.inc ├── main.asm ├── map_editor │ ├── css │ │ └── main.css │ ├── index.html │ ├── init_data.js │ ├── js │ │ ├── data.js │ │ ├── editor.js │ │ ├── init.js │ │ ├── jquery-3.6.0.min.js │ │ └── main.js │ ├── map_editor.txt │ ├── tiles.bin │ └── tiles.gbr ├── rom │ ├── car_game_v012.gbc │ ├── car_game_v013.gbc │ ├── car_game_v014.gbc │ ├── car_game_v015-2.gbc │ ├── car_game_v015.gbc │ ├── car_game_v016.gbc │ ├── car_game_v017-1.gbc │ ├── car_game_v017.gbc │ ├── car_game_v018.gbc │ ├── car_game_v019.gbc │ └── car_game_v020.gbc ├── tiles.bin └── wram.inc ├── car_game02 ├── a.sh ├── bg_tile0.inc ├── bg_tile1.inc ├── conv.php ├── data.inc ├── equ.inc ├── macro.inc ├── main.asm ├── map_editor.txt ├── rom │ ├── car_game_v021.gbc │ ├── car_game_v022.gbc │ ├── car_game_v023.gbc │ ├── car_game_v024.gbc │ ├── car_game_v025.gbc │ ├── car_game_v026.gbc │ ├── car_game_v027.gbc │ ├── car_game_v028-test01.gbc │ ├── car_game_v028-test02.gbc │ ├── car_game_v028-test03.gbc │ ├── car_game_v028-test04.gbc │ ├── car_game_v028-test05.gbc │ ├── car_game_v028-test06.gbc │ ├── car_game_v028-test07.gbc │ ├── car_game_v028.gbc │ ├── car_game_v029-test01.gbc │ ├── car_game_v029.gbc │ ├── car_game_v030-test01.gbc │ ├── car_game_v030.gbc │ └── car_game_v031.gbc ├── sprites.bin ├── sprites.gbr ├── tiles.bin ├── tiles.gbr └── wram.inc ├── car_game03 ├── RunLengthEncoder.php ├── a.sh ├── bg_tile0.bin ├── bg_tile0_comp.bin ├── bg_tile1.bin ├── bg_tile1_comp.bin ├── bg_tile_win0.inc ├── bg_tile_win1.inc ├── conv.php ├── convBin.php ├── data.inc ├── equ.inc ├── macro.inc ├── main.asm ├── map_editor.txt ├── map_editor_win.txt ├── rom │ ├── car_game_v032-test01.gbc │ ├── car_game_v032-test02.gbc │ ├── car_game_v032-test03.gbc │ ├── car_game_v032-test04.gbc │ ├── car_game_v032.gbc │ ├── car_game_v033.gbc │ ├── car_game_v034.gbc │ ├── car_game_v035.gbc │ ├── car_game_v036.gbc │ ├── car_game_v037.gbc │ ├── car_game_v038.gbc │ ├── car_game_v039.gbc │ ├── car_game_v040-test01.gbc │ ├── car_game_v040-test03.gbc │ ├── car_game_v040-test04.gbc │ ├── car_game_v040.gbc │ ├── car_game_v041-test01.gbc │ ├── car_game_v041-test02.gbc │ ├── car_game_v041-test03.gbc │ ├── car_game_v041.gbc │ ├── car_game_v042-test01.gbc │ ├── car_game_v042.gbc │ ├── car_game_v043-test01.gbc │ ├── car_game_v043-test02.gbc │ ├── car_game_v043.gbc │ ├── car_game_v044-test01.gbc │ ├── car_game_v044-test02.gbc │ ├── car_game_v044-test03.gbc │ ├── car_game_v044.gbc │ ├── car_game_v045-test01.gbc │ ├── car_game_v045-test02.gbc │ ├── car_game_v045-test03.gbc │ ├── car_game_v045.gbc │ ├── car_game_v046-test01.gbc │ ├── car_game_v046-test02.gbc │ ├── car_game_v046-test03.gbc │ ├── car_game_v046.gbc │ └── car_game_v047-test01.gbc ├── sprites.bin ├── sprites.gbr ├── sprites_comp.bin ├── tiles.bin ├── tiles.gbr ├── tiles_comp.bin └── wram.inc ├── car_game04 ├── a.sh ├── car_macro.inc ├── data.inc ├── equ.inc ├── macro.inc ├── main.asm ├── p.sh ├── resource │ ├── RunLengthEncoder.php │ ├── bg_tile0.bin │ ├── bg_tile0_comp.bin │ ├── bg_tile1.bin │ ├── bg_tile1_comp.bin │ ├── car.psd │ ├── car2.psd │ ├── convBin.php │ ├── createRoadXPosTbl.php │ ├── map_editor.txt │ ├── my_car.aseprite │ ├── my_car2.aseprite │ ├── road_x.inc │ ├── sprites.bin │ ├── sprites.gbr │ ├── sprites_comp.bin │ ├── tiles.bin │ ├── tiles.gbr │ └── tiles_comp.bin ├── road_x.inc ├── rom │ ├── car_game04_v01.gbc │ ├── car_game04_v02.gbc │ ├── car_game04_v03.gbc │ ├── car_game04_v04-test01.gbc │ ├── car_game04_v04-test02.gbc │ ├── car_game04_v04-test03.gbc │ ├── car_game04_v04.gbc │ └── car_game04_v05.gbc └── wram.inc ├── collision0.5 ├── main.asm ├── map.bin ├── map.gbm ├── tiles.bin └── tiles.gbr ├── collision1 ├── CalculateMemoryAddressFromXY.png ├── main.asm ├── map.bin ├── map.gbm ├── tiles.bin └── tiles.gbr ├── move_speed_control ├── main.asm ├── map.bin ├── map.gbm ├── move_speed_control.gb ├── tiles.bin └── tiles.gbr ├── move_sprite ├── main.asm └── sprite.bin ├── raster_scroll0.1 ├── main.asm ├── map.bin ├── map.gbm ├── tiles.bin └── tiles.gbr ├── raster_scroll0.2 ├── main.asm ├── map.bin ├── map.gbm ├── tiles.bin └── tiles.gbr ├── raster_scroll0.3 ├── main.asm ├── map.bin ├── map.gbm ├── raster_scroll03.gb ├── tiles.bin └── tiles.gbr ├── raster_scroll0.4 ├── main.asm ├── map.bin ├── map.gbm ├── raster_scroll04.gb ├── tiles.bin └── tiles.gbr ├── raster_scroll0.5 ├── main.asm ├── map.bin ├── map.gbm ├── raster_scroll05.gb ├── tiles.bin └── tiles.gbr ├── raster_scroll1 ├── main.asm ├── map.bin ├── map.gbm ├── raster_scroll1.gb ├── tiles.bin └── tiles.gbr ├── reading_joypad └── main.asm ├── rotation_object1 ├── main.asm ├── rotation_object1.gb ├── tiles.bin └── tiles.gbr ├── rotation_object2 ├── main.asm ├── rotation_object2.gb ├── tiles.bin └── tiles.gbr ├── rotation_object3 ├── main.asm ├── rotation_object3.gbc ├── tiles.bin └── tiles.gbr ├── scrolling1 ├── bg.bin ├── main.asm └── sprite.bin ├── scrolling2 ├── main.asm ├── tiles.bin └── tiles.gbr └── scrolling3 ├── main.asm ├── map.bin ├── map.gbm ├── tiles.bin └── tiles.gbr /AnalysisDefleMaskData/README.txt: -------------------------------------------------------------------------------- 1 | The files that were here have been moved. 2 | Please check below for the latest source code. 3 | https://github.com/emutyworks/Learning-GB-Programming/tree/main/SoundDriver/tools 4 | https://github.com/emutyworks/Learning-GB-Programming/blob/main/SoundDriver/tools/AnalysisDefleMaskData.php -------------------------------------------------------------------------------- /DirectBgRenderingTest1/DirectBgRenderingTest1.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/DirectBgRenderingTest1/DirectBgRenderingTest1.gbc -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Learning GB Programming 2 | Learning Game Boy programming step by step. Let's start game programming with Assembly language. 3 | 4 | * Wiki https://github.com/emutyworks/Learning-GB-Programming/wiki 5 | -------------------------------------------------------------------------------- /RunLengthEncodeDecode/RunLengthEncoder.php: -------------------------------------------------------------------------------- 1 | \n"; 10 | exit; 11 | } 12 | $inpit_file = $argv[1]; 13 | $output_file = $argv[2]; 14 | 15 | $in_array = str_split(bin2hex(file_get_contents($inpit_file)),2); 16 | 17 | $val_past = array_shift($in_array); 18 | $val_next = null; 19 | $out_array = array(); 20 | do{ 21 | echo $val_past; 22 | $out_array[] = $val_past; 23 | $val_next = array_shift($in_array); 24 | if($val_past!=$val_next){ 25 | $val_past = $val_next; 26 | continue; 27 | } 28 | echo $val_next; 29 | $out_array[] = $val_next; 30 | $cnt = 2; 31 | while(1){ 32 | $val_past = array_shift($in_array); 33 | if($val_next!=$val_past || $cnt==255){ 34 | echo ":$cnt\n"; 35 | $out_array[] = dechex($cnt); 36 | break; 37 | }else{ 38 | echo $val_past; 39 | } 40 | $cnt++; 41 | } 42 | }while(count($in_array)!=0); 43 | 44 | echo "\n----\ntotal: ".count($out_array)." bytes\n"; 45 | 46 | $bin = null; 47 | for($i=0; $i -------------------------------------------------------------------------------- /RunLengthEncodeDecode/a.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ -z "$2" ] 4 | then 5 | echo "Usage: ./a.sh <.asm filename> <.gb filename>" 6 | fi 7 | 8 | rgbasm -l -H -o $1.o $1.asm 9 | rgblink -t -o $2.gbc $1.o 10 | rgbfix -v -p 0 -C $2.gbc -------------------------------------------------------------------------------- /RunLengthEncodeDecode/bg_tile0_1024.bin: -------------------------------------------------------------------------------- 1 |  2 |   -------------------------------------------------------------------------------- /RunLengthEncodeDecode/bg_tile0_compress.bin: -------------------------------------------------------------------------------- 1 | : 2 |     3 |  4 |   5 |  6 | 8 -------------------------------------------------------------------------------- /RunLengthEncodeDecode/bg_tile1_1024.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/RunLengthEncodeDecode/bg_tile1_1024.bin -------------------------------------------------------------------------------- /RunLengthEncodeDecode/bg_tile1_compress.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/RunLengthEncodeDecode/bg_tile1_compress.bin -------------------------------------------------------------------------------- /RunLengthEncodeDecode/main.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; I used this Website/Document as a reference to create it. 3 | ; 4 | ; Run-length encoding 5 | ; https://en.wikipedia.org/wiki/Run-length_encoding 6 | ; 7 | ; Lesson H9- Hello World on the Gameboy and Gameboy Color 8 | ; https://www.chibiakumas.com/z80/helloworld.php#LessonH9 9 | ; 10 | ; Pan Docs 11 | ; https://gbdev.io/pandocs/ 12 | ; 13 | 14 | INCLUDE "hardware.inc" 15 | 16 | SECTION "Header",ROM0[$100] 17 | 18 | EntryPoint: 19 | di 20 | jr Start 21 | 22 | REPT $150 - $104 23 | db 0 24 | ENDR 25 | 26 | SECTION "Start",ROM0[$150] 27 | 28 | Start: 29 | call WaitVBlank 30 | 31 | ; Set BG Palette 32 | ld a,%10000000 ; Palette 0, Auto increment after writing 33 | ldh [rBCPS],a 34 | ld c,2 35 | ld hl,BGPalette 36 | ld de,rBCPD 37 | call SetPalette 38 | 39 | xor a 40 | ldh [rLCDC],a 41 | ldh [rIE],a 42 | ldh [rIF],a 43 | ldh [rSTAT],a 44 | ldh [rSVBK],a 45 | ldh [rSCY],a 46 | ldh [rSCX],a 47 | 48 | ; Set Tiles data 49 | ld hl,_VRAM+$1000 ;$9000 50 | ld de,Tiles 51 | ld bc,TilesEnd - Tiles 52 | call CopyData 53 | 54 | ; Set Map data (Decompression version) 55 | ld a,1 56 | ldh [rVBK],a ; BG Map Attributes 57 | ld hl,_SCRN0 ; write address 58 | ld de,BgTileMap1 ; data address 59 | ld bc,BgTileMap1End-1 ; data end address 60 | call CopyDecompressionData 61 | xor a 62 | ldh [rVBK],a ; Tile Indexes 63 | ld hl,_SCRN0 64 | ld de,BgTileMap0 65 | ld bc,BgTileMap0End-1 66 | call CopyDecompressionData 67 | 68 | ; Set Map data (No decompression version) 69 | ;ld a,1 70 | ;ldh [rVBK],a ; BG Map Attributes 71 | ;ld hl,_SCRN0 72 | ;ld de,BgTileMap1 73 | ;ld bc,BgTileMap1End - BgTileMap1 74 | ;call CopyData 75 | ;xor a 76 | ;ldh [rVBK],a ; Tile Indexes 77 | ;ld hl,_SCRN0 78 | ;ld de,BgTileMap0 79 | ;ld bc,BgTileMap0End - BgTileMap0 80 | ;call CopyData 81 | 82 | ld a,LCDCF_ON|LCDCF_BGON 83 | ldh [rLCDC],a 84 | 85 | MainLoop: 86 | jp MainLoop 87 | 88 | CopyDecompressionData: 89 | ;ld hl, 90 | ;ld de, 91 | ;ld bc, 92 | .start 93 | ld a,[de] 94 | inc de 95 | ld [hli],a 96 | push bc 97 | .loop 98 | ld b,a 99 | ld a,[de] 100 | cp b 101 | jr z,.next 102 | inc de 103 | ld [hli],a 104 | jr .loop 105 | .next 106 | inc de 107 | ld [hli],a 108 | ld a,[de] 109 | inc de 110 | sub 2 111 | cp 0 112 | jr z,.skip 113 | ld c,a 114 | ld a,b 115 | .copy 116 | ld [hli],a 117 | dec c 118 | jr nz,.copy 119 | .skip 120 | pop bc 121 | ld a,b 122 | cp d 123 | jr nz,.start 124 | ld a,c 125 | cp e 126 | jr nc,.start 127 | ret 128 | 129 | WaitVBlank: 130 | .loop 131 | ldh a,[rLY] 132 | cp SCRN_Y ; 144 ; Check if the LCD is past VBlank 133 | jr nz,.loop 134 | ret 135 | 136 | SetPalette: 137 | .loop 138 | ld a,[hli] 139 | ld [de],a 140 | ld a,[hli] 141 | ld [de],a 142 | dec c 143 | jr nz,.loop 144 | ret 145 | 146 | CopyData: 147 | ld a,[de] ; Grab 1 byte from the source 148 | ld [hli],a ; Place it at the destination, incrementing hl 149 | inc de ; Move to next byte 150 | dec bc ; Decrement count 151 | ld a,b ; Check if count is 0, since `dec bc` doesn't update flags 152 | or c 153 | jr nz,CopyData 154 | ret 155 | 156 | BGPalette: 157 | dw 0 158 | dw 8456 159 | dw 24311 160 | dw 32767 161 | 162 | dw 0 163 | dw 8456 164 | dw 32767 165 | dw 24311 166 | 167 | SECTION "BG Data",ROM0[$2000] 168 | BgTileMap0: ; Tile Indexes 169 | ;INCBIN "bg_tile0_1024.bin" ; 1024 bytes 170 | INCBIN "bg_tile0_compress.bin" ; 337 bytes 171 | BgTileMap0End: 172 | 173 | BgTileMap1: ; BG Map Attributes 174 | ;INCBIN "bg_tile1_1024.bin" ; 1024 bytes 175 | INCBIN "bg_tile1_compress.bin" ; 151 bytes 176 | BgTileMap1End: 177 | 178 | Tiles: 179 | INCBIN "tiles.bin" 180 | TilesEnd: -------------------------------------------------------------------------------- /RunLengthEncodeDecode/test_RunLengthDecoder.php: -------------------------------------------------------------------------------- 1 | \n"; 11 | exit; 12 | } 13 | $inpit_file = $argv[1]; 14 | $output_file = $argv[2]; 15 | 16 | $in_array = str_split(bin2hex(file_get_contents($inpit_file)),2); 17 | 18 | $val_past = array_shift($in_array); 19 | $val_next = null; 20 | $cnt = 0; 21 | $out_array = array(); 22 | do{ 23 | echo $val_past; 24 | $out_array[] = $val_past; 25 | $val_next = array_shift($in_array); 26 | if($val_past!=$val_next){ 27 | $val_past = $val_next; 28 | continue; 29 | } 30 | echo $val_next; 31 | $out_array[] = $val_next; 32 | $cnt = hexdec(array_shift($in_array)); 33 | echo "|$cnt:"; 34 | for($i=0; $i<($cnt-2); $i++){ 35 | echo $val_next; 36 | $out_array[] = $val_next; 37 | } 38 | echo "\n"; 39 | $val_past = array_shift($in_array); 40 | }while(count($in_array)!=0); 41 | 42 | //var_dump($out_array); 43 | //var_dump(count($out_array)); 44 | 45 | $bin = null; 46 | for($i=0; $i -------------------------------------------------------------------------------- /RunLengthEncodeDecode/tiles.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/RunLengthEncodeDecode/tiles.bin -------------------------------------------------------------------------------- /SoundDriver/a.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ -z "$2" ] 4 | then 5 | echo "Usage: ./a.sh <.asm filename> <.gb filename>" 6 | fi 7 | 8 | rgbasm -o $1.o $1.asm 9 | rgblink -o $2.gb $1.o 10 | rgbfix -v -p 0 $2.gb -------------------------------------------------------------------------------- /SoundDriver/gbsd.inc: -------------------------------------------------------------------------------- 1 | GBSD_ENVELOPE EQU $C0 2 | GBSD_OCTAVE EQU $D0 3 | GBSD_DIVIDER EQU $D0 4 | GBSD_EMPTY EQU $E0 5 | GBSD_NOTE EQU $F0 6 | GBSD_SHIFT EQU $F0 7 | GBSD_ENDDATA EQU $CF 8 | 9 | INCLUDE "gbsd_macro.inc" 10 | 11 | InitSoundDriver: 12 | ld a,HIGH(SQ1SoundDataTbl) 13 | ld [wSQ1SoundData],a 14 | ld a,LOW(SQ1SoundDataTbl) 15 | ld [wSQ1SoundData+1],a 16 | ld a,HIGH(SQ2SoundDataTbl) 17 | ld [wSQ2SoundData],a 18 | ld a,LOW(SQ2SoundDataTbl) 19 | ld [wSQ2SoundData+1],a 20 | ld a,HIGH(WavSoundDataTbl) 21 | ld [wWavSoundData],a 22 | ld a,LOW(WavSoundDataTbl) 23 | ld [wWavSoundData+1],a 24 | ld a,HIGH(NoiSoundDataTbl) 25 | ld [wNoiSoundData],a 26 | ld a,LOW(NoiSoundDataTbl) 27 | ld [wNoiSoundData+1],a 28 | 29 | call SetWaveData 30 | 31 | ;Create wMusicalScaleTbl 32 | ld bc,MusicalScaleTbl 33 | ld hl,wMusicalScaleTbl 34 | ld d,$ff 35 | .next 36 | inc d 37 | ld a,[bc] 38 | ld e,a 39 | inc bc 40 | .loop 41 | ld a,[bc] ;wavelength low 42 | ld [hli],a 43 | ld [hl],d ;wavelength high 44 | inc hl 45 | inc bc 46 | dec e 47 | jr nz,.loop 48 | ld a,d 49 | cp 7 50 | jr nz,.next 51 | 52 | ;Init registers 53 | ld a,%10000000 54 | ldh [rAUDENA],a ; All sound on/off 55 | ldh [rAUD3ENA],a ; Sound on/off 56 | ld a,%01110111 57 | ldh [rAUDVOL],a ; -LLL-RRR Output level 58 | ld a,%11111111 59 | ldh [rAUDTERM],a ; Sound output terminal 60 | ld a,%00100000 61 | ldh [rAUD3LEVEL],a ; Select output level 62 | ld a,%00111111 63 | ldh [rAUD1LEN],a ; Sound length/Wave pattern duty 64 | ldh [rAUD2LEN],a 65 | ldh [rAUD4LEN],a ;Sound length 66 | ld a,%11111111 67 | ldh [rAUD3LEN],a 68 | xor a 69 | ldh [rAUD1SWEEP],a ; Sweep register 70 | ldh [rAUD1ENV],a ; Envelope 71 | ldh [rAUD2ENV],a 72 | ldh [rAUD4ENV],a 73 | ret 74 | 75 | PlaySound: 76 | mSetSQxSoundData 1 77 | mSetSQxSoundData 2 78 | mSetWavSoundData 79 | mSetNoiSoundData 80 | ret 81 | 82 | SetWaveData: 83 | ld hl,_AUD3WAVERAM 84 | ld de,WaveData 85 | ld c,16 86 | .loop 87 | ld a,[de] 88 | ld [hli],a 89 | inc de 90 | dec c 91 | jr nz,.loop 92 | ret 93 | 94 | INCLUDE "gbsd_musical_scale_tbl.inc" 95 | INCLUDE "gbsd_sound_data_tbl.inc" 96 | 97 | MusicalScalePosTbl: 98 | db 0,12,24,36,48,60 -------------------------------------------------------------------------------- /SoundDriver/gbsd_macro.inc: -------------------------------------------------------------------------------- 1 | MACRO mSetSQxSoundData 2 | ld a,[wSQ\1SoundData] 3 | ld b,a 4 | ld a,[wSQ\1SoundData+1] 5 | ld c,a 6 | .next\@ 7 | ldh a,[hEmptyCnt\1] 8 | cp 0 9 | jr nz,.decEmpty\@ 10 | ld a,[bc] 11 | cp GBSD_ENDDATA 12 | jr z,.endData\@ 13 | inc bc 14 | cp GBSD_ENVELOPE 15 | jr z,.setEnvelope\@ 16 | ld d,a 17 | and %00001111 18 | ld e,a ;low 19 | xor d 20 | ld d,a ;hi 21 | cp GBSD_NOTE 22 | jr z,.setNote\@ 23 | cp GBSD_EMPTY 24 | jr z,.setEmpty\@ 25 | cp GBSD_OCTAVE 26 | jr z,.setMusicalScalePos\@ 27 | ; Set Note/Volume 28 | ldh a,[rAUD\1ENV] 29 | and %00001111 30 | swap e 31 | or e 32 | ldh [rAUD\1ENV],a 33 | swap d 34 | ld e,d 35 | .setNote\@ 36 | ldh a,[hMusicalScalePos\1] 37 | add a,e 38 | ld h,HIGH(wMusicalScaleTbl) 39 | rlca 40 | ld l,a 41 | ld a,[hli] 42 | ldh [rAUD\1LOW],a 43 | ld a,[hli] 44 | or %10000000 45 | ldh [rAUD\1HIGH],a 46 | jr .exit\@ 47 | .setMusicalScalePos\@ 48 | ld d,HIGH(MusicalScalePosTbl) 49 | ld a,LOW(MusicalScalePosTbl) 50 | add a,e 51 | ld e,a 52 | ld a,[de] 53 | ldh [hMusicalScalePos\1],a 54 | jr .next\@ 55 | .setEnvelope\@ 56 | ld a,[bc] 57 | inc bc 58 | ldh [rAUD\1ENV],a 59 | jr .next\@ 60 | .decEmpty\@ 61 | dec a 62 | ldh [hEmptyCnt\1],a 63 | jr .exit\@ 64 | .setEmpty\@ 65 | ld a,e 66 | cp 0 67 | jr z,.exit\@ 68 | ldh [hEmptyCnt\1],a 69 | jr .exit\@ 70 | .endData\@ 71 | ;xor a 72 | ;ldh [rAUD1ENV],a 73 | .exit\@ 74 | ld a,b 75 | ld [wSQ\1SoundData],a 76 | ld a,c 77 | ld [wSQ\1SoundData+1],a 78 | ENDM 79 | 80 | MACRO mSetWavSoundData 81 | ld a,[wWavSoundData] 82 | ld b,a 83 | ld a,[wWavSoundData+1] 84 | ld c,a 85 | .next\@ 86 | ldh a,[hEmptyCnt3] 87 | cp 0 88 | jr nz,.decEmpty\@ 89 | ld a,[bc] 90 | cp GBSD_ENDDATA 91 | jr z,.endData\@ 92 | inc bc 93 | ld d,a 94 | and %00001111 95 | ld e,a ;low 96 | xor d 97 | ld d,a ;hi 98 | cp GBSD_NOTE 99 | jr z,.setNote\@ 100 | cp GBSD_EMPTY 101 | jr z,.setEmpty\@ 102 | ; Set Octave 103 | ld d,HIGH(MusicalScalePosTbl) 104 | ld a,LOW(MusicalScalePosTbl) 105 | add a,e 106 | ld e,a 107 | ld a,[de] 108 | ldh [hMusicalScalePos3],a 109 | jr .next\@ 110 | .setNote\@ 111 | ldh a,[hMusicalScalePos3] 112 | add a,e 113 | ld h,HIGH(wMusicalScaleTbl) 114 | rlca 115 | ld l,a 116 | ld a,[hli] 117 | ldh [rAUD3LOW],a 118 | ld a,[hli] 119 | or %10000000 120 | ldh [rAUD3HIGH],a 121 | jr .exit\@ 122 | .decEmpty\@ 123 | dec a 124 | ldh [hEmptyCnt3],a 125 | jr .exit\@ 126 | .setEmpty\@ 127 | ld a,e 128 | cp 0 129 | jr z,.exit\@ 130 | ldh [hEmptyCnt3],a 131 | jr .exit\@ 132 | .endData\@ 133 | xor a 134 | ldh [rAUD3ENA],a 135 | .exit\@ 136 | ld a,b 137 | ld [wWavSoundData],a 138 | ld a,c 139 | ld [wWavSoundData+1],a 140 | ENDM 141 | 142 | MACRO mSetNoiSoundData 143 | ld a,[wNoiSoundData] 144 | ld b,a 145 | ld a,[wNoiSoundData+1] 146 | ld c,a 147 | .next\@ 148 | ldh a,[hEmptyCnt4] 149 | cp 0 150 | jr nz,.decEmpty\@ 151 | ld a,[bc] 152 | cp GBSD_ENDDATA 153 | jr z,.endData\@ 154 | inc bc 155 | cp GBSD_ENVELOPE 156 | jr z,.setEnvelope\@ 157 | ld d,a 158 | and %00001111 159 | ld e,a ;low 160 | xor d 161 | ld d,a ;hi 162 | cp GBSD_SHIFT 163 | jr z,.setClockShift\@ 164 | cp GBSD_EMPTY 165 | jr z,.setEmpty\@ 166 | cp GBSD_DIVIDER 167 | jr z,.setClockDivider\@ 168 | jr .exit\@ 169 | .setClockShift\@ 170 | ldh a,[hClockDivider] 171 | swap e 172 | or e 173 | ldh [rAUD4POLY],a 174 | ld a,%10000000 175 | ldh [rAUD4GO],a 176 | jr .exit\@ 177 | .setClockDivider\@ 178 | ld a,e 179 | ldh [hClockDivider],a 180 | jr .next\@ 181 | .setEnvelope\@ 182 | ld a,[bc] 183 | inc bc 184 | ldh [rAUD4ENV],a 185 | jr .next\@ 186 | .decEmpty\@ 187 | dec a 188 | ldh [hEmptyCnt4],a 189 | jr .exit\@ 190 | .setEmpty\@ 191 | ld a,e 192 | cp 0 193 | jr z,.exit\@ 194 | ldh [hEmptyCnt4],a 195 | jr .exit\@ 196 | .endData\@ 197 | ;xor a 198 | ;ldh [rAUD1ENV],a 199 | .exit\@ 200 | ld a,b 201 | ld [wNoiSoundData],a 202 | ld a,c 203 | ld [wNoiSoundData+1],a 204 | ENDM 205 | -------------------------------------------------------------------------------- /SoundDriver/gbsd_musical_scale_tbl.inc: -------------------------------------------------------------------------------- 1 | MusicalScaleTbl: ; total 80 bytes (-64 bytes) 2 | db 2 ;0:2 counts 3 | db $2C ; C2 4 | db $9C ; C#2 5 | db 3 ;1:3 counts 6 | db $06 ; D2 7 | db $6B ; D#2 8 | db $C9 ; E2 9 | db 3 ;2:3 counts 10 | db $23 ; F2 11 | db $77 ; F#2 12 | db $C6 ; G2 13 | db 4 ;3:4 counts 14 | db $12 ; G#2 15 | db $56 ; A2 16 | db $9B ; A#2 17 | db $DA ; B2 18 | db 5 ;4:5 counts 19 | db $16 ; C3 20 | db $4E ; C#3 21 | db $83 ; D3 22 | db $B5 ; D#3 23 | db $E5 ; E3 24 | db 7 ;5:7 counts 25 | db $11 ; F3 26 | db $3B ; F#3 27 | db $63 ; G3 28 | db $89 ; G#3 29 | db $AC ; A3 30 | db $CE ; A#3 31 | db $ED ; B3 32 | db 12 ;6:12 counts 33 | db $0A ; C4 34 | db $27 ; C#4 35 | db $42 ; D4 36 | db $5B ; D#4 37 | db $72 ; E4 38 | db $89 ; F4 39 | db $9E ; F#4 40 | db $B2 ; G4 41 | db $C4 ; G#4 42 | db $D6 ; A4 43 | db $E7 ; A#4 44 | db $F7 ; B4 45 | db 36 ;7:36 counts 46 | db $06 ; C5 47 | db $14 ; C#5 48 | db $21 ; D5 49 | db $2D ; D#5 50 | db $39 ; E5 51 | db $44 ; F5 52 | db $4F ; F#5 53 | db $59 ; G5 54 | db $62 ; G#5 55 | db $6B ; A5 56 | db $73 ; A#5 57 | db $7B ; B5 58 | db $83 ; C6 59 | db $8A ; C#6 60 | db $90 ; D6 61 | db $97 ; D#6 62 | db $9D ; E6 63 | db $A2 ; F6 64 | db $A7 ; F#6 65 | db $AC ; G6 66 | db $B1 ; G#6 67 | db $B6 ; A6 68 | db $BA ; A#6 69 | db $BE ; B6 70 | db $C1 ; C7 71 | db $C4 ; C#7 72 | db $C8 ; D7 73 | db $CB ; D#7 74 | db $CE ; E7 75 | db $D1 ; F7 76 | db $D4 ; F#7 77 | db $D6 ; G7 78 | db $D9 ; G#7 79 | db $DB ; A7 80 | db $DD ; A#7 81 | db $DF ; B -------------------------------------------------------------------------------- /SoundDriver/gbsd_sound_data_tbl.inc: -------------------------------------------------------------------------------- 1 | ; - Generating "sound_data_tbl.inc". 2 | ; php tools/convDMF2Hex.php tools/test.dmf 3 | ; 4 | ; - Data format 5 | ; $C0,$xx: Set Envelope 6 | ; $CF: End of data 7 | ; $D0-$D5: Set Octave (2-7) 8 | ; $E0-$Ef: Set Empty (1-16) 9 | ; $xx: Set Volume/Note 10 | ; |+ $0-$f Volume (0-15) 11 | ; +- $0-$b Note (C,C#,D,D#,E,F,F#,G,G#,A,A#,B) 12 | ; $F0-$Fb: Set Note 13 | ; 14 | ; *Total 142 bytes of data. 15 | SQ1SoundDataTbl: 16 | db $Ef 17 | db $Ef 18 | db $Ef 19 | db $Ef 20 | db $E7 21 | db $CF 22 | 23 | SQ2SoundDataTbl: 24 | db $Ef 25 | db $Ef 26 | db $Ef 27 | db $Ef 28 | db $E7 29 | db $CF 30 | 31 | ; - Data format 32 | ; $CF: End of data 33 | ; $D0-$D5: Set Octave (2-7) 34 | ; $E0-$Ef: Set Empty (1-16) 35 | ; $F0-$Fb: Set Note (C,C#,D,D#,E,F,F#,G,G#,A,A#,B) 36 | WavSoundDataTbl: 37 | db $Ef 38 | db $Ef 39 | db $Ef 40 | db $Ef 41 | db $E7 42 | db $CF 43 | 44 | WaveData: 45 | db $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$00,$00,$00,$00,$00,$00,$00,$00 46 | 47 | ; - Data format 48 | ; $C0,$xx: Set Envelope 49 | ; $CF: End of data 50 | ; $D0-$Df: Set LFSR width + Clock divider (0-15) 51 | ; $E0-$Ef: Set Empty (1-16) 52 | ; $F0-$Ff: Set Clock shift (0-15) 53 | NoiSoundDataTbl: 54 | db $C0,$91 55 | db $D4 56 | db $F0 57 | db $E0 58 | db $F0 59 | db $E0 60 | db $F0 61 | db $E0 62 | db $F0 63 | db $E0 64 | db $F0 65 | db $F0 66 | db $D8 67 | db $F0 68 | db $D4 69 | db $F0 70 | db $F0 71 | db $F0 72 | db $D8 73 | db $F0 74 | db $D4 75 | db $F0 76 | db $F0 77 | db $F0 78 | db $D8 79 | db $F0 80 | db $D4 81 | db $F0 82 | db $F0 83 | db $F0 84 | db $D8 85 | db $F0 86 | db $D4 87 | db $F0 88 | db $F0 89 | db $F0 90 | db $D8 91 | db $F0 92 | db $D4 93 | db $F0 94 | db $F0 95 | db $F0 96 | db $D8 97 | db $F0 98 | db $D4 99 | db $F0 100 | db $F0 101 | db $F0 102 | db $D8 103 | db $F0 104 | db $D4 105 | db $F0 106 | db $F0 107 | db $F0 108 | db $D8 109 | db $F0 110 | db $D4 111 | db $F0 112 | db $F0 113 | db $F0 114 | db $D8 115 | db $F0 116 | db $D4 117 | db $F0 118 | db $F0 119 | db $F0 120 | db $D8 121 | db $F0 122 | db $D4 123 | db $F0 124 | db $F0 125 | db $F0 126 | db $D8 127 | db $F0 128 | db $D4 129 | db $F0 130 | db $F0 131 | db $F0 132 | db $D8 133 | db $F0 134 | db $D4 135 | db $F0 136 | db $F0 137 | db $F0 138 | db $D8 139 | db $F0 140 | db $D4 141 | db $F0 142 | db $F0 143 | db $F0 144 | db $D8 145 | db $F0 146 | db $D4 147 | db $F0 148 | db $F0 149 | db $F0 150 | db $D8 151 | db $F0 152 | db $D4 153 | db $F0 154 | db $F0 155 | db $F0 156 | db $D8 157 | db $F0 158 | db $D4 159 | db $F0 160 | db $CF 161 | -------------------------------------------------------------------------------- /SoundDriver/main.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; I used this Website/Document as a reference to create it. 3 | ; 4 | ; Z80 1バイトデータの分解 (Z80 1-byte data decomposition) 5 | ; https://codeknowledge.livedoor.blog/archives/25232135.html 6 | ; 7 | ; Lesson P21 - Sound on the Gameboy and GBC 8 | ; https://www.chibiakumas.com/z80/platform3.php#LessonP21 9 | ; https://www.youtube.com/watch?v=LCPLGkYJk5M 10 | ; 11 | ; Pan Docs 12 | ; https://gbdev.io/pandocs/ 13 | ; 14 | 15 | INCLUDE "hardware.inc" 16 | 17 | SoundWait EQU 15 18 | 19 | SECTION "VBlank Handler",ROM0[$40] 20 | push af 21 | ld a,1 22 | ld [wVBlankDone],a 23 | pop af 24 | reti 25 | 26 | SECTION "Header",ROM0[$100] 27 | 28 | EntryPoint: 29 | di 30 | jp Start 31 | 32 | REPT $150 - $104 33 | db 0 34 | ENDR 35 | 36 | SECTION "Start",ROM0[$150] 37 | 38 | Start: 39 | xor a 40 | ldh [rLCDC],a 41 | ldh [rIE],a 42 | ldh [rIF],a 43 | ldh [rSCY],a 44 | ldh [rSCX],a 45 | ldh [hMusicalScalePos1],a 46 | ldh [hMusicalScalePos2],a 47 | ldh [hMusicalScalePos3],a 48 | ldh [hClockDivider],a 49 | ldh [hEmptyCnt1],a 50 | ldh [hEmptyCnt2],a 51 | ldh [hEmptyCnt3],a 52 | ldh [hEmptyCnt4],a 53 | ld [wVBlankDone],a 54 | ld [wSoundWait],a 55 | 56 | ld a,LCDCF_ON 57 | ldh [rLCDC],a 58 | 59 | ld a,IEF_VBLANK 60 | ldh [rIE],a 61 | xor a 62 | ei 63 | ldh [rIF],a 64 | 65 | ; Set Sound driver 66 | call InitSoundDriver 67 | ld a,SoundWait 68 | ld [wSoundWait],a 69 | 70 | MainLoop: 71 | ld a,[wVBlankDone] 72 | cp 1 73 | jp nz,MainLoop 74 | xor a 75 | ld [wVBlankDone],a 76 | 77 | ld a,[wSoundWait] 78 | cp 0 79 | jr z,.playSound 80 | dec a 81 | ld [wSoundWait],a 82 | jp MainLoop 83 | 84 | .playSound 85 | call PlaySound 86 | ld a,SoundWait 87 | ld [wSoundWait],a 88 | 89 | jp MainLoop 90 | 91 | INCLUDE "gbsd.inc" 92 | 93 | SECTION "State",WRAM0 94 | wMusicalScaleTbl: ds 144 95 | wSoundWait: ds 1 96 | wVBlankDone: ds 1 97 | wSQ1SoundData: ds 2 98 | wSQ2SoundData: ds 2 99 | wWavSoundData: ds 2 100 | wNoiSoundData: ds 2 101 | 102 | SECTION "HRAM Variables",HRAM 103 | hMusicalScalePos1: ds 1 104 | hMusicalScalePos2: ds 1 105 | hMusicalScalePos3: ds 1 106 | hClockDivider: ds 1 107 | hEmptyCnt1: ds 1 108 | hEmptyCnt2: ds 1 109 | hEmptyCnt3: ds 1 110 | hEmptyCnt4: ds 1 111 | -------------------------------------------------------------------------------- /SoundDriver/resource/musical_scale_list.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/SoundDriver/resource/musical_scale_list.xlsx -------------------------------------------------------------------------------- /SoundDriver/rom/sound_driver_v01.gb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/SoundDriver/rom/sound_driver_v01.gb -------------------------------------------------------------------------------- /SoundDriver/rom/sound_driver_v010.gb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/SoundDriver/rom/sound_driver_v010.gb -------------------------------------------------------------------------------- /SoundDriver/rom/sound_driver_v02.gb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/SoundDriver/rom/sound_driver_v02.gb -------------------------------------------------------------------------------- /SoundDriver/rom/sound_driver_v03.gb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/SoundDriver/rom/sound_driver_v03.gb -------------------------------------------------------------------------------- /SoundDriver/rom/sound_driver_v04.gb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/SoundDriver/rom/sound_driver_v04.gb -------------------------------------------------------------------------------- /SoundDriver/rom/sound_driver_v05.gb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/SoundDriver/rom/sound_driver_v05.gb -------------------------------------------------------------------------------- /SoundDriver/rom/sound_driver_v06.gb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/SoundDriver/rom/sound_driver_v06.gb -------------------------------------------------------------------------------- /SoundDriver/rom/sound_driver_v07.gb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/SoundDriver/rom/sound_driver_v07.gb -------------------------------------------------------------------------------- /SoundDriver/rom/sound_driver_v08.gb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/SoundDriver/rom/sound_driver_v08.gb -------------------------------------------------------------------------------- /SoundDriver/rom/sound_driver_v09.gb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/SoundDriver/rom/sound_driver_v09.gb -------------------------------------------------------------------------------- /SoundDriver/tools/convDMF2Hex.php: -------------------------------------------------------------------------------- 1 | \n"; 12 | exit; 13 | } 14 | $argv[2] = 'no_file.bin'; 15 | $mode_conv = 1; 16 | include 'AnalysisDefleMaskData.php'; 17 | 18 | // Generate sound_data_tbl.inc 19 | $total_bytes = 0; 20 | 21 | $sq1 = getPatternsData('SQ1',$d,$total_bytes); 22 | $sq2 = getPatternsData('SQ2',$d,$total_bytes); 23 | $wav = getPatternsData('WAV',$d,$total_bytes); 24 | $noi = getPatternsData('NOI',$d,$total_bytes); 25 | 26 | /*test 27 | $list = $d['PATTERNS_DATA']['NOI'][0]['PATTERN_MATRIX']; 28 | //print_r($list); 29 | for($i=0; $i Array 65 | ( 66 | [EnvelopeVolume] => 9 67 | [EnvelopeDirection] => 1 68 | [EnvelopeLength] => 3 69 | [SoundLength] => 49 70 | ( 71 | 72 | ; [Envelope] 73 | ld a,%7654xxxx ; EnvelopeVolume - Initial value of envelope 74 | %xxxx3xxx ; EnvelopeDirection - Envelope 1:UP/0:DOWN 75 | %xxxxx210 ; EnvelopeLength - Number of envelope sweep (# 0-7) 76 | ldh [rAUD1ENV],a 77 | 78 | ; [Sound length/Wave pattern duty] 79 | ld a,%76xxxxxx ; - Wave Pattern Duty (00:12.5% 01:25% 10:50% 11:75%) 80 | %xx543210 ; SoundLength - Sound length data (# 0-63) 81 | ldh [rAUD1LEN],a 82 | 83 | ----- 84 | [PATTERNS_DATA][SQ1][0][PATTERN_MATRIX] => Array 85 | ( 86 | [0] => Array 87 | ( 88 | [NoteForThisIndex] => 0100 89 | [OctaveForThisIndex] => 0100 (NoteForThisIndex:0000 + OctaveForThisIndex:0000 = Empty) 90 | [VolumeForThisIndex] => 0100 (ffff = Empty) 91 | ) 92 | ) 93 | 94 | ; [Envelope] 95 | ld a,%7654xxxx ; VolumeForThisIndex - Initial value of envelope 96 | ldh [rAUD1ENV],a 97 | 98 | ; NoteForThisIndex + OctaveForThisIndex -> GameBoy Sound Table 99 | ld a,%76543210 100 | ldh [rAUD1LOW],a ; Frequency low byte 101 | ld a,%xxxxx210 102 | ldh [rAUD1HIGH],a ; Frequency high byte 103 | 104 | - Reference 105 | Specs for DMF (DefleMask Module Format, for DefleMask v1.0.0 and above) 106 | https://www.deflemask.com/DMF_SPECS.txt 107 | Pan Docs: Audio Registers 108 | https://gbdev.io/pandocs/Audio_Registers.html 109 | hardware.inc: Gameboy Hardware definitions 110 | https://github.com/gbdev/hardware.inc/tree/master 111 | */ 112 | ?> 113 | 114 | -------------------------------------------------------------------------------- /SoundDriver/tools/dmf/test_v010.dmf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/SoundDriver/tools/dmf/test_v010.dmf -------------------------------------------------------------------------------- /SoundDriver/tools/dmf/test_v04.dmf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/SoundDriver/tools/dmf/test_v04.dmf -------------------------------------------------------------------------------- /SoundDriver/tools/dmf/test_v05.dmf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/SoundDriver/tools/dmf/test_v05.dmf -------------------------------------------------------------------------------- /SoundDriver/tools/dmf/test_v06.dmf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/SoundDriver/tools/dmf/test_v06.dmf -------------------------------------------------------------------------------- /SoundDriver/tools/dmf/test_v08.dmf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/SoundDriver/tools/dmf/test_v08.dmf -------------------------------------------------------------------------------- /SoundDriver/tools/dmf/test_v09.dmf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/SoundDriver/tools/dmf/test_v09.dmf -------------------------------------------------------------------------------- /SoundDriver/tools/init.php: -------------------------------------------------------------------------------- 1 | =2 && $octave<=7 && $octave_old!=$octave){ 62 | $hex[] = sprintf("%s%s",SD_OCTAVE,$octave-2); 63 | $octave_old = $octave; 64 | $total_bytes++; 65 | } 66 | } 67 | 68 | // Set Note 69 | if($volume===null || $key=='WAV' || $key=='NOI'){ 70 | $row = sprintf("%s%s",SD_NOTE,$note); 71 | }else{ 72 | $row = sprintf("%s%s",$note,$volume); 73 | } 74 | 75 | // Set Empty 76 | if($note.$octave=='00'){ 77 | $empty_cnt++; 78 | }else{ 79 | if($empty_cnt!=-1){ 80 | do{ 81 | if($empty_cnt>=SD_EMPTY_CNT_MAX){ 82 | $hex[] = sprintf("%s%s",SD_EMPTY,dechex(SD_EMPTY_CNT_MAX-1)); 83 | $empty_cnt -= SD_EMPTY_CNT_MAX; 84 | $total_bytes++; 85 | }else{ 86 | $hex[] = sprintf("%s%s",SD_EMPTY,dechex($empty_cnt)); 87 | $total_bytes++; 88 | $empty_cnt = -1; 89 | } 90 | }while($empty_cnt>-1); 91 | $hex[] = $row; 92 | $total_bytes++; 93 | }else{ 94 | $hex[] = $row; 95 | $total_bytes++; 96 | } 97 | } 98 | } 99 | 100 | // Set Empty 101 | if($empty_cnt!=-1){ 102 | do{ 103 | if($empty_cnt>=SD_EMPTY_CNT_MAX){ 104 | $hex[] = sprintf("%s%s",SD_EMPTY,dechex(SD_EMPTY_CNT_MAX-1)); 105 | $empty_cnt -= SD_EMPTY_CNT_MAX; 106 | $total_bytes++; 107 | }else{ 108 | $hex[] = sprintf("%s%s",SD_EMPTY,dechex($empty_cnt)); 109 | $total_bytes++; 110 | $empty_cnt = -1; 111 | } 112 | }while($empty_cnt>-1); 113 | } 114 | 115 | // debug 116 | for($i=0; $i -------------------------------------------------------------------------------- /SoundDriver/tools/templates/gbsd_sound_data_tbl.inc: -------------------------------------------------------------------------------- 1 | ; - Generating "sound_data_tbl.inc". 2 | ; php tools/convDMF2Hex.php tools/test.dmf 3 | ; 4 | ; - Data format 5 | ; $C0,$xx: Set Envelope 6 | ; $CF: End of data 7 | ; $D0-$D5: Set Octave (2-7) 8 | ; $E0-$Ef: Set Empty (1-16) 9 | ; $xx: Set Volume/Note 10 | ; |+ $0-$f Volume (0-15) 11 | ; +- $0-$b Note (C,C#,D,D#,E,F,F#,G,G#,A,A#,B) 12 | ; $F0-$Fb: Set Note 13 | ; 14 | ; *Total {{TOTAL_BYTES}} bytes of data. 15 | SQ1SoundDataTbl: 16 | {{DATA_SQ1}} 17 | 18 | SQ2SoundDataTbl: 19 | {{DATA_SQ2}} 20 | 21 | ; - Data format 22 | ; $CF: End of data 23 | ; $D0-$D5: Set Octave (2-7) 24 | ; $E0-$Ef: Set Empty (1-16) 25 | ; $F0-$Fb: Set Note (C,C#,D,D#,E,F,F#,G,G#,A,A#,B) 26 | WavSoundDataTbl: 27 | {{DATA_WAV}} 28 | 29 | WaveData: 30 | {{DATA_WAVE_DATA}} 31 | 32 | ; - Data format 33 | ; $C0,$xx: Set Envelope 34 | ; $CF: End of data 35 | ; $D0-$Df: Set LFSR width + Clock divider (0-15) 36 | ; $E0-$Ef: Set Empty (1-16) 37 | ; $F0-$Ff: Set Clock shift (0-15) 38 | NoiSoundDataTbl: 39 | {{DATA_NOI}} 40 | -------------------------------------------------------------------------------- /SoundDriver/tools/test.dmf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/SoundDriver/tools/test.dmf -------------------------------------------------------------------------------- /SoundEditor/a.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ -z "$2" ] 4 | then 5 | echo "Usage: ./a.sh <.asm filename> <.gb filename>" 6 | fi 7 | 8 | rgbasm -H -o $1.o $1.asm 9 | rgblink -t -o $2.gbc $1.o 10 | rgbfix -v -p 0 -C $2.gbc -------------------------------------------------------------------------------- /SoundEditor/bg_tile0.inc: -------------------------------------------------------------------------------- 1 | db $60,$61,$62,$5B,$5C,$5D,$5E,$2F,$58,$59,$5F,$63,$5C,$5D,$5E,$2F,$58,$59,$5A,$5B,$64,$65,$66,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 2 | db $30,$31,$32,$33,$34,$35,$2F,$2F,$1F,$20,$2F,$2F,$2F,$2F,$2F,$2F,$30,$31,$32,$33,$34,$35,$2F,$00,$06,$2F,$2F,$2F,$2F,$2F,$2F,$2F 3 | db $36,$37,$38,$2F,$2F,$2F,$2F,$2F,$21,$22,$2F,$2F,$2F,$2F,$2F,$2F,$30,$1B,$25,$2F,$2F,$2F,$2F,$00,$07,$2F,$2F,$2F,$2F,$2F,$2F,$2F 4 | db $11,$12,$2F,$2F,$2F,$2F,$2F,$2F,$23,$24,$2F,$2F,$2F,$2F,$2F,$2F,$29,$2A,$2B,$2F,$2F,$2F,$2F,$00,$08,$2F,$2F,$2F,$2F,$2F,$2F,$2F 5 | db $13,$14,$15,$2F,$2F,$2F,$2F,$2F,$26,$27,$2F,$2F,$2F,$2F,$2F,$2F,$2D,$2E,$2F,$2F,$2F,$2F,$2F,$00,$09,$2F,$2F,$2F,$2F,$2F,$2F,$2F 6 | db $16,$17,$18,$2F,$2F,$2F,$2F,$2F,$30,$31,$32,$33,$34,$35,$2F,$2F,$0D,$0E,$0F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 7 | db $19,$1A,$2F,$2F,$2F,$2F,$2F,$2F,$36,$37,$38,$10,$2F,$2F,$2F,$39,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 8 | db $1C,$1D,$1E,$2F,$2F,$2F,$2F,$2F,$11,$12,$2F,$2F,$2F,$2F,$2F,$3A,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 9 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$13,$14,$15,$2F,$2F,$2F,$2F,$3B,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 10 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$29,$2A,$2B,$2F,$2F,$2F,$2F,$3C,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 11 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2D,$2E,$2F,$2F,$2F,$2F,$2F,$3D,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 12 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$3E,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 13 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$3F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 14 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$40,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 15 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 16 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 17 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$7D,$75,$71,$50,$51,$0D,$0E,$0F,$7D,$28,$2C,$52,$53,$54,$2F,$2F 18 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 19 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 20 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 21 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 22 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 23 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 24 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 25 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 26 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 27 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 28 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 29 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 30 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 31 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 32 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 33 | -------------------------------------------------------------------------------- /SoundEditor/bg_tile1.inc: -------------------------------------------------------------------------------- 1 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 2 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 3 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 4 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 5 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 6 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 7 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01 8 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01 9 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01 10 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01 11 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01 12 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01 13 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01 14 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01 15 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 16 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 17 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 18 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 19 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 20 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 21 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 22 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 23 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 24 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 25 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 26 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 27 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 28 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 29 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 30 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 31 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 32 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 33 | 34 | -------------------------------------------------------------------------------- /SoundEditor/bg_tile_win0.inc: -------------------------------------------------------------------------------- 1 | db $2F,$2F,$2F,$2F,$2F,$2F,$69,$6A,$6B,$6C,$6D,$6E,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 2 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 3 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$71,$72,$73,$74,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 4 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$75,$76,$77,$78,$79,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 5 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$7A,$7B,$7C,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 6 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$7D,$7E,$7F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 7 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$67,$68,$6F,$70,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 8 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$72,$73,$74,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 9 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 10 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 11 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 12 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 13 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 14 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 15 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 16 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 17 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 18 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 19 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 20 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 21 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 22 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 23 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 24 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 25 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 26 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 27 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 28 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 29 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 30 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 31 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 32 | db $2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$2F 33 | -------------------------------------------------------------------------------- /SoundEditor/bg_tile_win1.inc: -------------------------------------------------------------------------------- 1 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 2 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 3 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 4 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 5 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 6 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 7 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 8 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 9 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 10 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 11 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 12 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 13 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 14 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 15 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 16 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 17 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 18 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 19 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 20 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 21 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 22 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 23 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 24 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 25 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 26 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 27 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 28 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 29 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 30 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 31 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 32 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 33 | 34 | -------------------------------------------------------------------------------- /SoundEditor/conv.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /SoundEditor/data.inc: -------------------------------------------------------------------------------- 1 | SECTION "Data",ROM0[$2000] 2 | SRegCalc0Tbl: 3 | db %00111111 ; FF20 %xx543210 Initial length timer 4 | db %00001111 ; FF21 %7654xxxx Initial volume 5 | db %00000001 ; %xxxx3xxx Env dir 6 | db %00000111 ; %xxxxx210 Sweep pace 7 | db %00001111 ; FF22 %7654xxxx Clock shift 8 | db %00000001 ; %xxxx3xxx LFSR width 9 | db %00000111 ; %xxxxx210 Clock divider 10 | SRegCalc1Tbl: 11 | db %00000111 ; FF10 %x654xxxx Pace 12 | db %00000001 ; %xxxx3xxx Direction 13 | db %00000111 ; %xxxxx210 Individual step 14 | db %00000011 ; FF11 %76xxxxxx Wave duty 15 | db %00111111 ; %xx543210 Initial length timer 16 | db %00001111 ; FF12 %7654xxxx Initial volume 17 | db %00000001 ; %xxxx3xxx Env dir 18 | db %00000111 ; %xxxxx210 Sweep pace 19 | SRegCalc2Tbl: 20 | db %11111111 ; FF1B %76543210 Initial length timer 21 | db %00000011 ; FF1C %x65xxxxx Output level 22 | 23 | MusicalScaleTbl: 24 | db %00101100,%000 ; C2 25 | ;db %10011100,%000 ; C#2 26 | db %00000110,%001 ; D2 27 | ;db %01101011,%001 ; D#2 28 | db %11001001,%001 ; E2 29 | db %00100011,%010 ; F2 30 | ;db %01110111,%010 ; F#2 31 | db %11000110,%010 ; G2 32 | ;db %00010010,%011 ; G#2 33 | db %01010110,%011 ; A2 34 | ;db %10011011,%011 ; A#2 35 | db %11011010,%011 ; B2 36 | db %00010110,%100 ; C3 37 | ;db %01001110,%100 ; C#3 38 | db %10000011,%100 ; D3 39 | ;db %10110101,%100 ; D#3 40 | db %11100101,%100 ; E3 41 | db %00010001,%101 ; F3 42 | ;db %00111011,%101 ; F#3 43 | db %01100011,%101 ; G3 44 | ;db %10001001,%101 ; G#3 45 | db %10101100,%101 ; A3 46 | ;db %11001110,%101 ; A#3 47 | db %11101101,%101 ; B3 48 | db %00001010,%110 ; C4 49 | ;db %00100111,%110 ; C#4 50 | db %01000010,%110 ; D4 51 | ;db %01011011,%110 ; D#4 52 | db %01110010,%110 ; E4 53 | db %10001001,%110 ; F4 54 | ;db %10011110,%110 ; F#4 55 | db %10110010,%110 ; G4 56 | ;db %11000100,%110 ; G#4 57 | db %11010110,%110 ; A4 58 | ;db %11100111,%110 ; A#4 59 | db %11110111,%110 ; B4 60 | db %00000110,%111 ; C5 61 | ;db %00010100,%111 ; C#5 62 | db %00100001,%111 ; D5 63 | ;db %00101101,%111 ; D#5 64 | db %00111001,%111 ; E5 65 | db %01000100,%111 ; F5 66 | ;db %01001111,%111 ; F#5 67 | db %01011001,%111 ; G5 68 | ;db %01100010,%111 ; G#5 69 | db %01101011,%111 ; A5 70 | ;db %01110011,%111 ; A#5 71 | db %01111011,%111 ; B5 72 | db %10000011,%111 ; C6 73 | ;db %10001010,%111 ; C#6 74 | db %10010000,%111 ; D6 75 | ;db %10010111,%111 ; D#6 76 | db %10011101,%111 ; E6 77 | db %10100010,%111 ; F6 78 | ;db %10100111,%111 ; F#6 79 | db %10101100,%111 ; G6 80 | ;db %10110001,%111 ; G#6 81 | db %10110110,%111 ; A6 82 | ;db %10111010,%111 ; A#6 83 | db %10111110,%111 ; B6 84 | db %11000001,%111 ; C7 85 | ;db %11000100,%111 ; C#7 86 | db %11001000,%111 ; D7 87 | ;db %11001011,%111 ; D#7 88 | db %11001110,%111 ; E7 89 | db %11010001,%111 ; F7 90 | ;db %11010100,%111 ; F#7 91 | db %11010110,%111 ; G7 92 | ;db %11011001,%111 ; G#7 93 | db %11011011,%111 ; A7 94 | ;db %11011101,%111 ; A#7 95 | db %11011111,%111 ; B7 96 | 97 | MusicalScalePosTbl: 98 | db 0,14,28,42,56,70 99 | 100 | WaveInitData: 101 | db $7d,$b8,$bd,$a7,$bf,$d8,$ab,$73,$7c,$73,$46,$20,$37,$41,$36,$31 102 | 103 | BGPalette: 104 | dw 0 105 | dw 31 106 | dw 25492 107 | dw 32767 108 | 109 | dw 0 110 | dw 1023 111 | dw 25492 112 | dw 32767 113 | 114 | ObjPalette: 115 | dw 0 116 | dw 31 117 | dw 25492 118 | dw 32767 119 | 120 | dw 0 121 | dw 25492 122 | dw 31 123 | dw 32767 124 | 125 | Sprites: 126 | INCBIN "sprites.bin" 127 | SpritesEnd: 128 | 129 | Tiles: 130 | INCBIN "tiles.bin" 131 | TilesEnd: 132 | 133 | ; - This data creation command. 134 | ; php conv.php 135 | ; 136 | ; map_editor.txt (https://github.com/emutyworks/GBCMapEditor/wiki) 137 | ; bg_tile0.inc, bg_tile1.inc 138 | ; 139 | BgTileMap0: ; Tile Indexes 140 | INCLUDE "bg_tile0.inc" 141 | BgTileMap0End: 142 | BgTileMap1: ; BG Map Attributes 143 | INCLUDE "bg_tile1.inc" 144 | BgTileMap1End: 145 | 146 | ; php conv.php _win 147 | ; 148 | ; map_editor_win.txt (https://github.com/emutyworks/GBCMapEditor/wiki) 149 | ; bg_tile_win0.inc, bg_tile_win1.inc 150 | ; 151 | BgTileMapWin0: 152 | INCLUDE "bg_tile_win0.inc" 153 | BgTileMapWin0End: 154 | 155 | BgTileMapWin1: 156 | INCLUDE "bg_tile_win1.inc" 157 | BgTileMapWin1End: 158 | 159 | -------------------------------------------------------------------------------- /SoundEditor/equ.inc: -------------------------------------------------------------------------------- 1 | JBitRight EQU 0 2 | JBitLeft EQU 1 3 | JBitUp EQU 2 4 | JBitDown EQU 3 5 | JBitButtonA EQU 4 6 | JBitButtonB EQU 5 7 | JBitSelect EQU 6 8 | JBitStart EQU 7 9 | JoypadWait EQU 10 10 | 11 | SBY EQU 16 ; Screen Base Y 12 | SBX EQU 8 ; Screen Base X 13 | 14 | SValueY EQU SBY+8*1 15 | SValueX EQU SBX 16 | UseMaxOAM EQU 22 17 | 18 | RegAddr EQU _SCRN1+32 19 | WaveAddr EQU _SCRN0+32*6+16 20 | Wave2Max EQU 16 21 | Wave2NumMax EQU Wave2Max*2 22 | Wave2GraphMax EQU 16*8 23 | Wave2CurPosY EQU SBY+8*14+1 24 | Wave2CurPosX EQU SBX+8 25 | 26 | ResetWaveAddr EQU _SCRN0+32*6+31 27 | ResetBGTile EQU 47 28 | 29 | BGPaletteCnt EQU 4*2 30 | ObjPaletteCnt EQU 4*2 -------------------------------------------------------------------------------- /SoundEditor/macro.inc: -------------------------------------------------------------------------------- 1 | MACRO mCheckJoypad 2 | ;wJoypad 3 | ;%76543210 4 | ; |||||||+ Right 5 | ; ||||||+- Left 6 | ; |||||+-- Up 7 | ; ||||+--- Down 8 | ; |||+---- A 9 | ; ||+----- B 10 | ; |+------ Select 11 | ; +------- Start 12 | ld a,P1F_4 13 | ldh [rP1],a ; Select P14 14 | ldh a,[rP1] 15 | ldh a,[rP1] ; Wait a few cycles 16 | cpl ; Complement A 17 | and %00001111 ; Get only first 4 bits 18 | swap a 19 | ld b,a 20 | ld a,P1F_5 21 | ldh [rP1],a ; Select P15 22 | ldh a,[rP1] 23 | ldh a,[rP1] 24 | ldh a,[rP1] 25 | ldh a,[rP1] 26 | ldh a,[rP1] 27 | ldh a,[rP1] ; Wait a few MORE cycles 28 | cpl 29 | and %00001111 30 | or a,b ; Put A and B together 31 | ld [wJoypad],a 32 | ld a,P1F_4|P1F_5 ; Deselect P14 and P15. 33 | ldh [rP1],a 34 | ENDM 35 | 36 | MACRO mSetOAM 37 | ; call the DMA subroutine we copied to HRAM 38 | ; which then copies the bytes to the OAM and sprites begin to draw 39 | ld a,HIGH(wShadowOAM) 40 | call hOAMDMA 41 | ENDM 42 | 43 | MACRO mInitwShadowOAM 44 | ld hl,wShadowOAM 45 | ld c,4*40 46 | xor a 47 | .loop\@ 48 | ld [hli],a 49 | dec c 50 | jr nz,.loop\@ 51 | ENDM 52 | 53 | MACRO mCopyDMARoutine 54 | ld hl,DMARoutine 55 | ld b,DMARoutineEnd - DMARoutine ; Number of bytes to copy 56 | ld c,LOW(hOAMDMA) ; Low byte of the destination address 57 | .loop\@ 58 | ld a,[hli] 59 | ldh [c],a 60 | inc c 61 | dec b 62 | jr nz,.loop\@ 63 | ENDM 64 | 65 | MACRO mResetShadowOAM 66 | ld a,l 67 | rrca 68 | rrca 69 | ld c,a 70 | ld a,UseMaxOAM 71 | sub c 72 | cp 0 73 | jr z,.skip\@ 74 | ld c,a 75 | xor a 76 | .loop\@ 77 | ld [hli],a 78 | ld [hli],a 79 | inc l 80 | inc l 81 | dec c 82 | jr nz,.loop\@ 83 | .skip\@ 84 | ENDM 85 | 86 | MACRO mSetWaveGraphDot 87 | ;left dot 88 | ld a,[de] 89 | bit 0,a 90 | jr nz,.upperLDot\@ 91 | ld b,%00000100 92 | jr .setLdot\@ 93 | .upperLDot\@ 94 | ld b,%00001000 95 | .setLdot\@ 96 | and %00001110 97 | rrca 98 | add a,l 99 | ld l,a 100 | ld [hl],b 101 | ;right dot 102 | inc e 103 | ld a,[wWave2GraphAddrL] 104 | ld l,a 105 | ld a,[de] 106 | bit 0,a 107 | jr nz,.upperRDot\@ 108 | ld b,%00000001 109 | jr .setRdot\@ 110 | .upperRDot\@ 111 | ld b,%00000010 112 | .setRdot\@ 113 | and %00001110 114 | rrca 115 | add a,l 116 | ld l,a 117 | ld a,[hl] 118 | or b 119 | ld [hl],a 120 | ENDM 121 | -------------------------------------------------------------------------------- /SoundEditor/rom/sound_editor_v01.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/SoundEditor/rom/sound_editor_v01.gbc -------------------------------------------------------------------------------- /SoundEditor/rom/sound_editor_v02.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/SoundEditor/rom/sound_editor_v02.gbc -------------------------------------------------------------------------------- /SoundEditor/rom/sound_editor_v03.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/SoundEditor/rom/sound_editor_v03.gbc -------------------------------------------------------------------------------- /SoundEditor/rom/sound_editor_v04.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/SoundEditor/rom/sound_editor_v04.gbc -------------------------------------------------------------------------------- /SoundEditor/rom/sound_editor_v05.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/SoundEditor/rom/sound_editor_v05.gbc -------------------------------------------------------------------------------- /SoundEditor/rom/sound_editor_v06.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/SoundEditor/rom/sound_editor_v06.gbc -------------------------------------------------------------------------------- /SoundEditor/sprites.bin: -------------------------------------------------------------------------------- 1 | pPPPp pp@ppppPPpp@ppp@pPpppPpPppPppPpPP`PpP`p@@@p`PPP`p@p@pp@p@@p -------------------------------------------------------------------------------- /SoundEditor/sprites.gbr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/SoundEditor/sprites.gbr -------------------------------------------------------------------------------- /SoundEditor/tiles.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/SoundEditor/tiles.bin -------------------------------------------------------------------------------- /SoundEditor/tiles.gbr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/SoundEditor/tiles.gbr -------------------------------------------------------------------------------- /SoundEditor/wram.inc: -------------------------------------------------------------------------------- 1 | SECTION "Shadow OAM",WRAM0[$C000] 2 | wShadowOAM: ds 4*40 ; This is the buffer we'll write sprite data to 3 | 4 | ;State 5 | wPosY: ds 1 6 | wPosX: ds 1 7 | wHex: ds 1 8 | wJoypad: ds 1 9 | wJoyPadPos: ds 1 10 | wJoypadWait: ds 1 11 | wVBlankDone: ds 1 12 | wMainLoopFlg: ds 1 13 | 14 | wMode: ds 1 15 | wFF10: ds 1 16 | wFF11: ds 1 17 | wFF12: ds 1 18 | wFF13: ds 1 19 | wFF14: ds 1 20 | wFF1B: ds 1 21 | wFF1C: ds 1 22 | wFF1D: ds 1 23 | wFF1E: ds 1 24 | wFF20: ds 1 25 | wFF21: ds 1 26 | wFF22: ds 1 27 | 28 | ;Sound Value 29 | wSValueTbl: ds 2 30 | wSRegCalcTbl: ds 2 31 | wSValueMax: ds 1 32 | wPlayFlg: ds 1 33 | 34 | wSValue0Tbl: 35 | wLengthTimer0: ds 1 36 | wVolume0: ds 1 37 | wEnv0: ds 1 38 | wSweep0: ds 1 39 | wShift0: ds 1 40 | wLFSR0: ds 1 41 | wDivider0: ds 1 42 | 43 | wSValue1Tbl: 44 | wPace1: ds 1 45 | wDir1: ds 1 46 | wStep1: ds 1 47 | wDuty1: ds 1 48 | wLengthTimer1: ds 1 49 | wVolume1: ds 1 50 | wEnv1: ds 1 51 | wSweep1: ds 1 52 | wOctave1: ds 1 53 | wNote1: ds 1 54 | 55 | wSValue2Tbl: 56 | wLengthTimer2: ds 1 57 | wLevel2: ds 1 58 | wOctave2: ds 1 59 | wNote2: ds 1 60 | wWaveCur: ds 1 61 | wWave2GraphAddrL: ds 1 62 | 63 | SECTION "Wave Num",WRAM0[$C1E0] 64 | wWave2Num: ds Wave2NumMax 65 | SECTION "Wave Graph",WRAM0[$C200] 66 | wWave2Graph: ds Wave2GraphMax 67 | 68 | SECTION "HRAM Variables",HRAM 69 | hOAMDMA: 70 | ds DMARoutineEnd - DMARoutine ; Reserve space to copy the routine to -------------------------------------------------------------------------------- /car_game/equ.inc: -------------------------------------------------------------------------------- 1 | ; Loop flg 2 | LoopSound EQU %00000001 3 | LoopSoundBit EQU 0 ; %00000001 4 | ; 5 | OamTblCnt EQU 4*5 6 | OAMPositionCnt EQU 5 7 | ; Shadow OAM 8 | Light1SA EQU 3 ; Attributes 9 | Light2SA EQU 7 10 | Light3SA EQU 11 11 | Car1S EQU 4*5 12 | ; 13 | SBY EQU 16 ; Screen Base Y 14 | SBX EQU 8 ; ScreenBaseX 15 | ScrollMaxY EQU SBY+8*12 16 | ScrollMaxX EQU SBX+8*11 17 | ScrollAreaYup EQU SBY+8*4 18 | ScrollAreaYdown EQU SBY+8*12 19 | ScrollAreaXleft EQU SBX+8*4 20 | ScrollAreaXright EQU SBX+8*14 21 | ScreenMaxY EQU SBY+8*12 22 | ScreenMaxX EQU SBX+8*14 23 | ScreenMinY EQU SBY+8*4 24 | ScreenMinX EQU SBX+8*4 25 | Car1StartY EQU SBY+8*4 26 | Car1StartX EQU SBX+8*9 27 | CarDataCnt EQU 16 28 | CarDirectionMax EQU 7 29 | ;CarSpeedMax EQU 3 30 | CarSpeedMax EQU 1 31 | CarTurnWait EQU 5 32 | CarCollision EQU 2 33 | CarCollisionAdd EQU 16 34 | BGPaletteCnt EQU 4*2 35 | ObjPaletteCnt EQU 4*5 36 | SoundDataCnt EQU 3 37 | -------------------------------------------------------------------------------- /car_game/map.bin: -------------------------------------------------------------------------------- 1 |   2 | XYVW[XY\]^_`abc -------------------------------------------------------------------------------- /car_game/material/car.aseprite: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game/material/car.aseprite -------------------------------------------------------------------------------- /car_game/material/map.gbm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game/material/map.gbm -------------------------------------------------------------------------------- /car_game/material/tiles.gbr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game/material/tiles.gbr -------------------------------------------------------------------------------- /car_game/rom/car_game_v01.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game/rom/car_game_v01.gbc -------------------------------------------------------------------------------- /car_game/rom/car_game_v010.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game/rom/car_game_v010.gbc -------------------------------------------------------------------------------- /car_game/rom/car_game_v011.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game/rom/car_game_v011.gbc -------------------------------------------------------------------------------- /car_game/rom/car_game_v02.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game/rom/car_game_v02.gbc -------------------------------------------------------------------------------- /car_game/rom/car_game_v03.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game/rom/car_game_v03.gbc -------------------------------------------------------------------------------- /car_game/rom/car_game_v04.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game/rom/car_game_v04.gbc -------------------------------------------------------------------------------- /car_game/rom/car_game_v05.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game/rom/car_game_v05.gbc -------------------------------------------------------------------------------- /car_game/rom/car_game_v06.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game/rom/car_game_v06.gbc -------------------------------------------------------------------------------- /car_game/rom/car_game_v07.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game/rom/car_game_v07.gbc -------------------------------------------------------------------------------- /car_game/rom/car_game_v08.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game/rom/car_game_v08.gbc -------------------------------------------------------------------------------- /car_game/rom/car_game_v09.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game/rom/car_game_v09.gbc -------------------------------------------------------------------------------- /car_game/sound_asm.inc: -------------------------------------------------------------------------------- 1 | InitSound: 2 | ld a,%01110111 ; -LLL-RRR Master volume & VIN panning 3 | ldh [$FF24],a 4 | ld a,%11111111 ; LLLLRRRR Sound panning 5 | ldh [$FF25],a 6 | ld a,%10000000 ; x------- Sound on/off 7 | ldh [$FF26],a 8 | ld a,%00000000 ; Channel 1 sweep 9 | ldh [$FF10],a ; Bit 6-4 - Sweep pace 10 | ; Bit 3 - Sweep increase/decrease 11 | ; 0: Addition (wavelength increases) 12 | ; 1: Subtraction (wavelength decreases) 13 | ; Bit 2-0 - Sweep slope control (n: 0-7) 14 | ld a,%00000000 ; Channel 1 length timer & duty cycle 15 | ldh [$FF11],a ; Bit 7-6 - Wave duty (Read/Write) 16 | ; Bit 5-0 - Initial length timer (Write Only) 17 | ld a,%00000011 ; Channel 1 volume & envelope 18 | ldh [$FF12],a ; Bit 7-4 - Initial volume of envelope (0-F) (0=No Sound) 19 | ; Bit 3 - Envelope direction (0=Decrease, 1=Increase) 20 | ; Bit 2-0 - Sweep pace (0=No Sweep) 21 | ret 22 | 23 | PlaySound: 24 | ld a,[wSoundWait] 25 | cp 0 26 | jr z,PlayNextSound 27 | dec a 28 | ld [wSoundWait],a 29 | ret nz 30 | 31 | PlayNextSound: 32 | ld a,[wSoundTbl] 33 | ld d,a 34 | ld a,[wSoundTbl+1] 35 | ld e,a 36 | .getTbl 37 | ld a,[de] 38 | cp JF ; Jump function 39 | jr z,.jumpFunction 40 | cp E12 ; Set Duty cycle 41 | jr z,.setDutyCycle 42 | cp SF ; Sound Off 43 | jr z,.soundOff 44 | cp SN ; Sound On 45 | jr z,.soundOn 46 | cp SW ; Sound Wait 47 | jr z,.setWait 48 | cp SS ; Sound Stop 49 | jr z,.soundStop 50 | 51 | ld [wSoundWait],a 52 | inc de 53 | ld h,HIGH(MusicalScaleTbl) 54 | ld a,[de] 55 | ld l,a 56 | ld a,[hli] 57 | ldh [$FF13],a ; Channel 1 wavelength low 58 | ld a,[hli] 59 | or %10000000 60 | ldh [$FF14],a ; Channel 1 wavelength high & control 61 | jr .setNextTbl 62 | .setDutyCycle 63 | inc de 64 | ld a,[de] 65 | rrca 66 | rrca 67 | ld b,a 68 | ldh a,[$FF11] ; Channel 1 length timer & duty cycle 69 | and %00111111 70 | or b 71 | ldh [$FF11],a 72 | inc de 73 | jr .getTbl 74 | 75 | .soundOn 76 | ldh a,[$FF12] 77 | or %11110000 78 | ldh [$FF12],a ; Channel 1 volume & envelope 79 | inc de 80 | jr .getTbl 81 | .soundOff 82 | ldh a,[$FF12] 83 | and %00001111 84 | ldh [$FF12],a 85 | inc de 86 | jr .getTbl 87 | 88 | .setWait 89 | inc de 90 | ld a,[de] 91 | ld [wSoundWait],a 92 | .setNextTbl 93 | inc de 94 | ld a,d 95 | ld [wSoundTbl],a 96 | ld a,e 97 | ld [wSoundTbl+1],a 98 | ret 99 | 100 | .soundStop 101 | ld a,[wLoopFlg] 102 | res LoopSoundBit,a 103 | ld [wLoopFlg],a 104 | ret 105 | 106 | .jumpFunction 107 | inc de 108 | ld a,[de] 109 | ld l,a 110 | inc de 111 | ld a,[de] 112 | ld h,a 113 | call .setNextTbl 114 | jp hl -------------------------------------------------------------------------------- /car_game/sound_equ.inc: -------------------------------------------------------------------------------- 1 | ; Musical scale 2 | C2 EQU 0 3 | C#2 EQU 2 4 | D2 EQU 4 5 | D#2 EQU 6 6 | E2 EQU 8 7 | F2 EQU 10 8 | F#2 EQU 12 9 | G2 EQU 14 10 | G#2 EQU 16 11 | A2 EQU 18 12 | A#2 EQU 20 13 | B2 EQU 22 14 | C3 EQU 24 15 | C#3 EQU 26 16 | D3 EQU 28 17 | D#3 EQU 30 18 | E3 EQU 32 19 | F3 EQU 34 20 | F#3 EQU 36 21 | G3 EQU 38 22 | G#3 EQU 40 23 | A3 EQU 42 24 | A#3 EQU 44 25 | B3 EQU 46 26 | C4 EQU 48 27 | C#4 EQU 50 28 | D4 EQU 52 29 | D#4 EQU 54 30 | E4 EQU 56 31 | F4 EQU 58 32 | F#4 EQU 60 33 | G4 EQU 62 34 | G#4 EQU 64 35 | A4 EQU 66 36 | A#4 EQU 68 37 | B4 EQU 70 38 | C5 EQU 72 39 | C#5 EQU 74 40 | D5 EQU 76 41 | D#5 EQU 78 42 | E5 EQU 80 43 | F5 EQU 82 44 | F#5 EQU 84 45 | G5 EQU 86 46 | G#5 EQU 88 47 | A5 EQU 90 48 | A#5 EQU 92 49 | B5 EQU 94 50 | C6 EQU 96 51 | C#6 EQU 98 52 | D6 EQU 100 53 | D#6 EQU 102 54 | E6 EQU 104 55 | F6 EQU 106 56 | F#6 EQU 108 57 | G6 EQU 110 58 | G#6 EQU 112 59 | A6 EQU 114 60 | A#6 EQU 116 61 | B6 EQU 118 62 | C7 EQU 120 63 | C#7 EQU 122 64 | D7 EQU 124 65 | D#7 EQU 126 66 | E7 EQU 128 67 | F7 EQU 130 68 | F#7 EQU 132 69 | G7 EQU 136 70 | G#7 EQU 138 71 | A7 EQU 140 72 | A#7 EQU 142 73 | B7 EQU 144 74 | ; 75 | NS EQU 2 ; 2 Sixteenth note 76 | N8 EQU NS*2 ; 4 Eighth note 77 | N4 EQU N8*2 ; 8 Quarter note 78 | N2 EQU N4*2 ; 16 Half note 79 | NW EQU N2*2 ; 32 Whole note 80 | ; 81 | JF EQU $FA ; Jump function 82 | E12 EQU $FB ; Set Duty cycle 83 | SF EQU $FC ; Sound Off 84 | SN EQU $FD ; Sound On 85 | SW EQU $FE ; Sound Wait 86 | SS EQU $FF ; Sound Stop 87 | -------------------------------------------------------------------------------- /car_game/sound_tbl.inc: -------------------------------------------------------------------------------- 1 | MusicalScaleTbl: 2 | db %00101100,%000 ; C2 3 | db %10011101,%000 ; C#2 4 | db %00000111,%001 ; D2 5 | db %01101011,%001 ; D#2 6 | db %11001010,%001 ; E2 7 | db %00100011,%010 ; F2 8 | db %01110111,%010 ; F#2 9 | db %11000111,%010 ; G2 10 | db %00010010,%011 ; G#2 11 | db %01011001,%011 ; A2 12 | db %10011011,%011 ; A#2 13 | db %11011011,%011 ; B2 14 | db %00010110,%100 ; C3 15 | db %01001110,%100 ; C#3 16 | db %10000011,%100 ; D3 17 | db %10110101,%100 ; D#3 18 | db %11100101,%100 ; E3 19 | db %00010001,%101 ; F3 20 | db %00111011,%101 ; F#3 21 | db %01100011,%101 ; G3 22 | db %10001001,%101 ; G#3 23 | db %10101100,%101 ; A3 24 | db %11001110,%101 ; A#3 25 | db %11101101,%101 ; B3 26 | db %00001011,%110 ; C4 27 | db %00100111,%110 ; C#4 28 | db %01000010,%110 ; D4 29 | db %01011011,%110 ; D#4 30 | db %01110010,%110 ; E4 31 | db %10001001,%110 ; F4 32 | db %10011110,%110 ; F#4 33 | db %10110010,%110 ; G4 34 | db %11000100,%110 ; G#4 35 | db %11010110,%110 ; A4 36 | db %11100111,%110 ; A#4 37 | db %11110111,%110 ; B4 38 | db %00000101,%111 ; C5 39 | db %00010100,%111 ; C#5 40 | db %00100001,%111 ; D5 41 | db %00101101,%111 ; D#5 42 | db %00111001,%111 ; E5 43 | db %01000100,%111 ; F5 44 | db %01001111,%111 ; F#5 45 | db %01011001,%111 ; G5 46 | db %01100010,%111 ; G#5 47 | db %01101011,%111 ; A5 48 | db %01110011,%111 ; A#5 49 | db %01111011,%111 ; B5 50 | db %10000011,%111 ; C6 51 | db %10001010,%111 ; C#6 52 | db %10010000,%111 ; D6 53 | db %10010111,%111 ; D#6 54 | db %10011101,%111 ; E6 55 | db %10100010,%111 ; F6 56 | db %10100111,%111 ; F#6 57 | db %10101100,%111 ; G6 58 | db %10110001,%111 ; G#6 59 | db %10110110,%111 ; A6 60 | db %10111010,%111 ; A#6 61 | db %10111110,%111 ; B6 62 | db %11000001,%111 ; C7 63 | db %11000101,%111 ; C#7 64 | db %11001000,%111 ; D7 65 | db %11001011,%111 ; D#7 66 | db %11001110,%111 ; E7 67 | db %11010001,%111 ; F7 68 | db %11010100,%111 ; F#7 69 | db %11010110,%111 ; G7 70 | db %11011001,%111 ; G#7 71 | db %11011011,%111 ; A7 72 | db %11011101,%111 ; A#7 73 | db %11011111,%111 ; B7 74 | 75 | Sound01Tbl: 76 | db SF ; Sound Off 77 | db SW,NW ; Sound Wait,Note 78 | ; Note - NS: Sixteenth note 79 | ; N8: Eighth note 80 | ; N4: Quarter note 81 | ; N2: Half note 82 | ; NW: Whole note 83 | db SW,NW 84 | db SN ; Sound On 85 | db E12,3 ; Set Duty cycle 86 | db N2,C5 ; Note,Scale 87 | ; Scale - CxDxExFxGxAxBx: Musical scale 88 | ; x=2-5: Octave 89 | db N4,C5 90 | db N4,C5 91 | db N4,C5 92 | db N2,E5 93 | db N4,E5 94 | db N4,E5 95 | db N4,E5 96 | db NW,F5 97 | db SW,NW 98 | db SW,N2 99 | ; 100 | db E12,2 101 | db JF ; Jump function 102 | dw SetLightPalette 103 | db NW,C5 104 | db SW,NW 105 | db JF 106 | dw SetLightPalette 107 | db NW,C5 108 | db SW,NW 109 | db JF 110 | dw SetLightPalette 111 | db NW,F5 112 | db SW,NW 113 | db JF 114 | dw SetLightPalette 115 | db SS ; Sound Stop 116 | -------------------------------------------------------------------------------- /car_game/tiles.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game/tiles.bin -------------------------------------------------------------------------------- /car_game/wram.inc: -------------------------------------------------------------------------------- 1 | SECTION "Shadow OAM",WRAM0[$C000] 2 | wShadowOAM: ds 4*40 ; This is the buffer we'll write sprite data to 3 | 4 | SECTION "OAM Position",WRAM0[$C100] 5 | wOAMPosition: ds 2*40 ; Y,X 6 | 7 | ;SECTION "State",WRAM0 8 | SECTION "State",WRAM0[$C200];debug 9 | wCarDirection: ds 1 10 | wCollisionY: ds 1 11 | wCollisionX: ds 1 12 | wPosY: ds 1 13 | wPosX: ds 1 14 | wNextSCY: ds 1 15 | wNextSCX: ds 1 16 | wNextPosY: ds 1 17 | wNextPosX: ds 1 18 | ; 19 | wJoypad: ds 1 20 | wButton: ds 1 21 | wCarSpeed: ds 1 22 | wCarSpeedUpWait: ds 1 23 | wCarSpeedDownWait: ds 1 24 | wCarTurnWait: ds 1 25 | ;wCarDirection: ds 1 26 | wCarPattern: ds 1 27 | ; 28 | wEngineSound: ds 1 29 | wSoundTbl: ds 2 30 | wSoundWait: ds 1 31 | ; 32 | wLoopFlg: ds 1 33 | wLightPalette: ds 2 34 | 35 | SECTION "HRAM Variables",HRAM 36 | hOAMDMA: 37 | ds DMARoutineEnd - DMARoutine ; Reserve space to copy the routine to -------------------------------------------------------------------------------- /car_game01/equ.inc: -------------------------------------------------------------------------------- 1 | JBitRight EQU 0 2 | JBitLeft EQU 1 3 | JBitButtonA EQU 0 4 | 5 | MapVramPosInit EQU 20 ; $9800+$20*20 6 | MapSize EQU 20 7 | MapTblSize EQU 10 8 | MapPartTblSize EQU 2048 9 | 10 | SBY EQU 16 ; Screen Base Y 11 | SBX EQU 8 ; Screen Base X 12 | CarBaseY EQU 11 13 | CarStartY EQU SBY+8*CarBaseY 14 | CarStartX EQU SBX+8*8 15 | CarVibration EQU 3 16 | CarColWait EQU 20 17 | 18 | EnemyStartY EQU SBY+8*3 19 | EnemyStartX EQU SBX+8*8 20 | EnemyWaitCnt EQU 2 21 | 22 | BGPaletteCnt EQU 4*3 23 | ObjPaletteCnt EQU 4*2 24 | 25 | BGPriorityTile EQU $1E 26 | BGDontColTile EQU $03 27 | 28 | SetMapTblEnd EQU LOW($C0A0+MapSize*2-1) ; $C0A0 = wMapIndexesTbl 29 | WMapIndexesEnd EQU LOW($C0A0+MapSize) 30 | WMapAttributesEnd EQU LOW($C0A0+MapSize*2) -------------------------------------------------------------------------------- /car_game01/map_editor/css/main.css: -------------------------------------------------------------------------------- 1 | body, input, select, textarea, button, span, tr, td, div{ 2 | z-index: 5; 3 | font-family: sans-serif; 4 | font-size: 8pt; 5 | padding: 0px 0px 0px 0px; 6 | cursor: default; 7 | } 8 | 9 | .canvas_base{ 10 | position: absolute; 11 | top: 94px; 12 | left: 8px; 13 | } 14 | #base{ 15 | z-index: 0; 16 | } 17 | #view{ 18 | z-index: 1; 19 | } 20 | #grid{ 21 | z-index: 2; 22 | } 23 | #win{ 24 | z-index: 3; 25 | } 26 | #cursor{ 27 | z-index: 4; 28 | } 29 | 30 | #map_table_title{ 31 | position: absolute; 32 | top: 73px; 33 | left: 8px; 34 | } 35 | 36 | #bg_tiles_title{ 37 | position: absolute; 38 | top: 80px; 39 | left: 344px; 40 | } 41 | #bg_palette_title{ 42 | position: absolute; 43 | top: 80px; 44 | left: 496px; 45 | } 46 | #map_view_title{ 47 | position: absolute; 48 | top: 80px; 49 | left: 624px; 50 | } 51 | #map_part_title{ 52 | position: absolute; 53 | top: 166px; 54 | left: 344px; 55 | } 56 | 57 | #help_mes{ 58 | position: relative; 59 | top: 5px; 60 | background-color: #ffff80; 61 | width: 939px; 62 | } 63 | 64 | #win_mappart{ 65 | display: none; 66 | position: absolute; 67 | top: 156px; 68 | } 69 | 70 | #win_table{ 71 | float: right; 72 | border: none; 73 | } 74 | 75 | table, td, th{ 76 | border-collapse: collapse; 77 | border: 1px #c0c0c0 solid; 78 | padding: 0px 2px; 79 | } 80 | 81 | input[type="radio"], input[type="checkbox"]{ 82 | position: relative; 83 | top: 3px; 84 | } 85 | select{ 86 | position: relative; 87 | top: -3px; 88 | } 89 | 90 | #map_table{ 91 | position: absolute; 92 | top: 630px; 93 | left: 8px; 94 | } 95 | 96 | #hr{ 97 | position: relative; 98 | top: 670px; 99 | } 100 | 101 | -------------------------------------------------------------------------------- /car_game01/map_editor/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Compress Map Editor (prototype) 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | Upload tiles.bin (GBTD export file/All-purpose binary):
19 | Download: Download in reverse Map Table order | Upload:
20 |
21 | Map Table: edit tiles Show Grid 25 | BG Tiles: 26 | BG Palette: 27 | Map Part: 28 | Map View: 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 59 |
38 | 39 | 40 | 48 | 56 | 57 |
PaletteHorizontal Flip
Left 41 | 0 42 | 1 43 | 2 44 | 3 45 | 46 | 47 |
Right 49 | 0 50 | 1 51 | 2 52 | 3 53 | 54 | 55 |
[Save]
58 |
60 |
61 | 62 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /car_game01/map_editor/init_data.js: -------------------------------------------------------------------------------- 1 | var init_load_data = ` 2 | # [BGPalette] 3 | dw 15134 4 | dw 23391 5 | dw 10840 6 | dw 3472 7 | 8 | dw 15134 9 | dw 8456 10 | dw 24311 11 | dw 32767 12 | 13 | # [MapPartTbl] 14 | db $00,$00 15 | 16 | # [MapTbl] 17 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00 18 | `; -------------------------------------------------------------------------------- /car_game01/map_editor/tiles.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game01/map_editor/tiles.bin -------------------------------------------------------------------------------- /car_game01/map_editor/tiles.gbr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game01/map_editor/tiles.gbr -------------------------------------------------------------------------------- /car_game01/rom/car_game_v012.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game01/rom/car_game_v012.gbc -------------------------------------------------------------------------------- /car_game01/rom/car_game_v013.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game01/rom/car_game_v013.gbc -------------------------------------------------------------------------------- /car_game01/rom/car_game_v014.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game01/rom/car_game_v014.gbc -------------------------------------------------------------------------------- /car_game01/rom/car_game_v015-2.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game01/rom/car_game_v015-2.gbc -------------------------------------------------------------------------------- /car_game01/rom/car_game_v015.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game01/rom/car_game_v015.gbc -------------------------------------------------------------------------------- /car_game01/rom/car_game_v016.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game01/rom/car_game_v016.gbc -------------------------------------------------------------------------------- /car_game01/rom/car_game_v017-1.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game01/rom/car_game_v017-1.gbc -------------------------------------------------------------------------------- /car_game01/rom/car_game_v017.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game01/rom/car_game_v017.gbc -------------------------------------------------------------------------------- /car_game01/rom/car_game_v018.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game01/rom/car_game_v018.gbc -------------------------------------------------------------------------------- /car_game01/rom/car_game_v019.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game01/rom/car_game_v019.gbc -------------------------------------------------------------------------------- /car_game01/rom/car_game_v020.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game01/rom/car_game_v020.gbc -------------------------------------------------------------------------------- /car_game01/tiles.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game01/tiles.bin -------------------------------------------------------------------------------- /car_game01/wram.inc: -------------------------------------------------------------------------------- 1 | SECTION "Shadow OAM",WRAM0[$C000] 2 | wShadowOAM: ds 4*40 ; This is the buffer we'll write sprite data to 3 | 4 | SECTION "Map Indexes/Attributes Table",WRAM0[$C0A0] 5 | wMapIndexesTbl: ds MapSize 6 | wMapAttributesTbl: ds MapSize 7 | 8 | ;SECTION "State",WRAM0 9 | SECTION "State",WRAM0[$C100];debug 10 | wOneEighthY: ds 1 11 | wOneEighthYOld: ds 1 12 | wMapTbl: ds 2 13 | 14 | wCarColWait: ds 1 15 | wCarPosY: ds 1 16 | wCarPosX: ds 1 17 | wNewCarPosX: ds 1 18 | 19 | wEnemyPosY: ds 1 20 | wEnemyPosX: ds 1 21 | wEnemyWaitCnt: ds 1 22 | 23 | wJoypad: ds 1 24 | wButton: ds 1 25 | 26 | SECTION "Map Part Table",WRAMX[$D000] 27 | wMapPartTbl: ds MapPartTblSize 28 | 29 | SECTION "HRAM Variables",HRAM 30 | hOAMDMA: 31 | ds DMARoutineEnd - DMARoutine ; Reserve space to copy the routine to -------------------------------------------------------------------------------- /car_game02/a.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ -z "$2" ] 4 | then 5 | echo "Usage: ./a.sh <.asm filename> <.gb filename>" 6 | fi 7 | 8 | rgbasm -o $1.o $1.asm 9 | rgblink -o $2.gbc $1.o 10 | rgbfix -v -p 0 -C $2.gbc -------------------------------------------------------------------------------- /car_game02/bg_tile0.inc: -------------------------------------------------------------------------------- 1 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 2 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$01,$00,$00,$00,$00,$00 3 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$01,$01,$00,$00,$00,$00,$00 4 | db $00,$00,$00,$01,$01,$01,$01,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$01,$01,$01,$01,$01,$01,$00,$00,$00 5 | db $00,$01,$01,$01,$01,$01,$01,$00,$00,$00,$00,$00,$02,$03,$03,$03,$03,$03,$02,$00,$00,$00,$00,$01,$01,$01,$01,$01,$01,$01,$00,$00 6 | db $00,$01,$01,$01,$01,$01,$01,$00,$00,$00,$00,$00,$04,$06,$07,$01,$01,$01,$04,$00,$00,$00,$00,$01,$01,$01,$01,$01,$00,$00,$00,$00 7 | db $00,$01,$01,$01,$01,$01,$00,$00,$00,$00,$00,$00,$04,$08,$09,$0A,$01,$01,$04,$00,$00,$00,$00,$00,$01,$01,$01,$01,$00,$00,$00,$00 8 | db $00,$01,$01,$01,$01,$01,$01,$00,$00,$00,$00,$00,$04,$0B,$0C,$0D,$0E,$0F,$04,$00,$00,$00,$00,$00,$01,$00,$00,$00,$00,$00,$00,$00 9 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$04,$01,$01,$01,$01,$01,$04,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 10 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$02,$03,$01,$01,$01,$03,$02,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 11 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$01,$01,$01,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 12 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$01,$01,$01,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 13 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$01,$01,$01,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 14 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$01,$01,$01,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 15 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$01,$01,$01,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 16 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$01,$01,$01,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 17 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$01,$01,$01,$01,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 18 | db $00,$00,$00,$02,$03,$03,$03,$03,$03,$02,$00,$00,$00,$01,$01,$01,$01,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 19 | db $00,$00,$00,$04,$02,$03,$03,$03,$02,$01,$01,$01,$01,$01,$01,$01,$01,$01,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 20 | db $00,$00,$00,$04,$04,$01,$01,$01,$04,$01,$01,$01,$01,$01,$01,$01,$01,$01,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 21 | db $00,$00,$00,$04,$04,$01,$01,$01,$04,$04,$00,$01,$01,$01,$01,$01,$01,$01,$01,$00,$00,$00,$02,$03,$03,$03,$03,$03,$02,$00,$00,$00 22 | db $00,$00,$00,$04,$02,$03,$03,$03,$02,$04,$00,$00,$00,$00,$00,$01,$01,$01,$01,$01,$00,$00,$04,$01,$01,$01,$01,$01,$04,$00,$00,$00 23 | db $00,$00,$00,$02,$03,$03,$03,$03,$03,$02,$00,$00,$00,$00,$00,$00,$00,$00,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$04,$00,$00,$00 24 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$01,$01,$01,$01,$01,$01,$01,$01,$04,$00,$00,$00 25 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$04,$01,$01,$01,$01,$01,$04,$00,$00,$00 26 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$01,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$04,$01,$01,$01,$01,$01,$04,$00,$00,$00 27 | db $00,$00,$00,$00,$00,$00,$00,$00,$01,$01,$01,$01,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$02,$03,$03,$03,$03,$03,$02,$00,$00,$00 28 | db $00,$00,$00,$00,$00,$00,$00,$01,$01,$01,$01,$01,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 29 | db $00,$00,$00,$00,$00,$00,$01,$01,$01,$01,$01,$01,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 30 | db $00,$00,$00,$00,$00,$00,$01,$01,$01,$01,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 31 | db $00,$00,$00,$00,$00,$00,$01,$01,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 32 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 33 | -------------------------------------------------------------------------------- /car_game02/bg_tile1.inc: -------------------------------------------------------------------------------- 1 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 2 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 3 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 4 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 5 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$20,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 6 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$20,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 7 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$20,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 8 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$20,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 9 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$20,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 10 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$40,$40,$00,$00,$00,$40,$60,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 11 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$81,$00,$81,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 12 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$81,$00,$81,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 13 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$81,$00,$81,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 14 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$81,$00,$81,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 15 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$81,$00,$81,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 16 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$81,$00,$81,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 17 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 18 | db $00,$00,$00,$80,$80,$80,$80,$80,$80,$A0,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 19 | db $00,$00,$00,$80,$01,$01,$01,$01,$21,$80,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 20 | db $00,$00,$00,$80,$01,$01,$01,$01,$21,$80,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 21 | db $00,$00,$00,$80,$01,$01,$01,$01,$21,$A0,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$20,$00,$00,$00 22 | db $00,$00,$00,$80,$41,$41,$41,$41,$61,$A0,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$20,$00,$00,$00 23 | db $00,$00,$00,$C0,$C0,$C0,$C0,$C0,$C0,$E0,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$20,$00,$00,$00 24 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$20,$00,$00,$00 25 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$20,$00,$00,$00 26 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$20,$00,$00,$00 27 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$40,$40,$40,$40,$40,$40,$60,$00,$00,$00 28 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 29 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 30 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 31 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 32 | db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 33 | 34 | -------------------------------------------------------------------------------- /car_game02/conv.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /car_game02/data.inc: -------------------------------------------------------------------------------- 1 | SECTION "Car Speed Table",ROM0[$2000] 2 | CarSpeedTbl:; Wait, Count 3 | db 7,7 4 | db 5,10 5 | db 3,10 6 | db 2,30 7 | db 1,50 8 | db 0,200 9 | 10 | BGPalette: 11 | ; 0 12 | dw 0 13 | dw 8456 14 | dw 24311 15 | dw 32767 16 | ; 1 17 | dw 0 18 | dw 8456 19 | dw 32767 20 | dw 24311 21 | 22 | ObjPalette: 23 | ; 0 24 | dw 15134 25 | dw 0 26 | dw 32767 27 | dw 31 28 | 29 | SECTION "Car Sprite Table",ROM0[$2100] 30 | ;14,15,00,01,02 31 | ;13 03 32 | ;12 04 33 | ;11 05 34 | ;10,09,08,07,06 35 | CarSpriteTbl: ; AddY,AddX,Tile Index,Attributes/Flags 36 | ; 00 37 | db 0,0,20,0 38 | db 0,8,22,0 39 | db 0,0,0,OAMF_PRI|0 40 | db 0,8,2,OAMF_PRI|0 41 | ; 01 42 | db 0,0,24,0 43 | db 0,8,26,0 44 | db 0,0,4,OAMF_PRI|0 45 | db 0,8,6,OAMF_PRI|0 46 | ; 02 47 | db 0,0,28,0 48 | db 0,8,30,0 49 | db 0,0,8,OAMF_PRI|0 50 | db 0,8,10,OAMF_PRI|0 51 | ; 03 52 | db 0,0,32,0 53 | db 0,8,34,0 54 | db 0,0,12,OAMF_PRI|0 55 | db 0,8,14,OAMF_PRI|0 56 | ; 04 57 | db 0,0,36,0 58 | db 0,8,38,0 59 | db 0,0,16,OAMF_PRI|0 60 | db 0,8,18,OAMF_PRI|0 61 | ; 05 62 | db 255,0,32,OAMF_YFLIP|0 63 | db 255,8,34,OAMF_YFLIP|0 64 | db 255,0,12,OAMF_PRI|OAMF_PRI|OAMF_YFLIP|0 65 | db 255,8,14,OAMF_PRI|OAMF_PRI|OAMF_YFLIP|0 66 | ; 06 67 | db 255,0,28,OAMF_YFLIP|0 68 | db 255,8,30,OAMF_YFLIP|0 69 | db 255,0,8,OAMF_PRI|OAMF_YFLIP|0 70 | db 255,8,10,OAMF_PRI|OAMF_YFLIP|0 71 | ; 07 72 | db 255,0,24,OAMF_YFLIP|0 73 | db 255,8,26,OAMF_YFLIP|0 74 | db 255,0,4,OAMF_PRI|OAMF_YFLIP|0 75 | db 255,8,6,OAMF_PRI|OAMF_YFLIP|0 76 | ; 08 77 | db 255,0,20,OAMF_YFLIP|0 78 | db 255,8,22,OAMF_YFLIP|0 79 | db 255,0,0,OAMF_PRI|OAMF_YFLIP|0 80 | db 255,8,2,OAMF_PRI|OAMF_YFLIP|0 81 | ; 09 82 | db 255,255,26,OAMF_YFLIP|OAMF_XFLIP|0 83 | db 255,7,24,OAMF_YFLIP|OAMF_XFLIP|0 84 | db 255,255,6,OAMF_PRI|OAMF_YFLIP|OAMF_XFLIP|0 85 | db 255,7,4,OAMF_PRI|OAMF_YFLIP|OAMF_XFLIP|0 86 | ; 10 87 | db 255,255,30,OAMF_YFLIP|OAMF_XFLIP|0 88 | db 255,7,28,OAMF_YFLIP|OAMF_XFLIP|0 89 | db 255,255,10,OAMF_PRI|OAMF_YFLIP|OAMF_XFLIP|0 90 | db 255,7,8,OAMF_PRI|OAMF_YFLIP|OAMF_XFLIP|0 91 | ; 11 92 | db 255,255,34,OAMF_YFLIP|OAMF_XFLIP|0 93 | db 255,7,32,OAMF_YFLIP|OAMF_XFLIP|0 94 | db 255,255,14,OAMF_PRI|OAMF_YFLIP|OAMF_XFLIP|0 95 | db 255,7,12,OAMF_PRI|OAMF_YFLIP|OAMF_XFLIP|0 96 | ; 12 97 | db 0,255,38,OAMF_XFLIP|0 98 | db 0,7,36,OAMF_XFLIP|0 99 | db 0,255,18,OAMF_PRI|OAMF_XFLIP|0 100 | db 0,7,16,OAMF_PRI|OAMF_XFLIP|0 101 | ; 13 102 | db 0,255,34,OAMF_XFLIP|0 103 | db 0,7,32,OAMF_XFLIP|0 104 | db 0,255,14,OAMF_PRI|OAMF_XFLIP|0 105 | db 0,7,12,OAMF_PRI|OAMF_XFLIP|0 106 | ; 14 107 | db 0,255,30,OAMF_XFLIP|0 108 | db 0,7,28,OAMF_XFLIP|0 109 | db 0,255,10,OAMF_PRI|OAMF_XFLIP|0 110 | db 0,7,8,OAMF_PRI|OAMF_XFLIP|0 111 | ; 15 112 | db 0,255,26,OAMF_XFLIP|0 113 | db 0,7,24,OAMF_XFLIP|0 114 | db 0,255,6,OAMF_PRI|OAMF_XFLIP|0 115 | db 0,7,4,OAMF_PRI|OAMF_XFLIP|0 116 | 117 | SECTION "Map VRAM Address Table",ROM0[$2200] 118 | MapVramTbl:;MapY 119 | dw $9800 ; 0 120 | dw $9820 ; 1 121 | dw $9840 ; 2 122 | dw $9860 ; 3 123 | dw $9880 ; 4 124 | dw $98A0 ; 5 125 | dw $98C0 ; 6 126 | dw $98E0 ; 7 127 | dw $9900 ; 8 128 | dw $9920 ; 9 129 | dw $9940 ; 10 130 | dw $9960 ; 11 131 | dw $9980 ; 12 132 | dw $99A0 ; 13 133 | dw $99C0 ; 14 134 | dw $99E0 ; 15 135 | dw $9A00 ; 16 136 | dw $9A20 ; 17 137 | dw $9A40 ; 18 138 | dw $9A60 ; 19 139 | dw $9A80 ; 20 140 | dw $9AA0 ; 21 141 | dw $9AC0 ; 22 142 | dw $9AE0 ; 23 143 | dw $9B00 ; 24 144 | dw $9B20 ; 25 145 | dw $9B40 ; 26 146 | dw $9B60 ; 27 147 | dw $9B80 ; 28 148 | dw $9BA0 ; 29 149 | dw $9BC0 ; 30 150 | dw $9BE0 ; 31 151 | 152 | SECTION "Direction Jump Table",ROM0[$2300] 153 | DirJpTbl: 154 | dw Dir00 155 | dw Dir01 156 | dw Dir02 157 | dw Dir03 158 | dw Dir04 159 | dw Dir05 160 | dw Dir06 161 | dw Dir07 162 | dw Dir08 163 | dw Dir09 164 | dw Dir10 165 | dw Dir11 166 | dw Dir12 167 | dw Dir13 168 | dw Dir14 169 | dw Dir15 170 | 171 | Sprites: 172 | INCBIN "sprites.bin" 173 | SpritesEnd: 174 | 175 | Tiles: 176 | INCBIN "tiles.bin" 177 | TilesEnd: 178 | 179 | BgTileMap0: ; Tile Indexes 180 | INCLUDE "bg_tile0.inc" 181 | BgTileMap0End: 182 | 183 | BgTileMap1: ; BG Map Attributes 184 | INCLUDE "bg_tile1.inc" 185 | BgTileMap1End: 186 | -------------------------------------------------------------------------------- /car_game02/equ.inc: -------------------------------------------------------------------------------- 1 | JBitRight EQU 0 2 | JBitLeft EQU 1 3 | JBitButtonA EQU 0 4 | 5 | SBY EQU 16 ; Screen Base Y 6 | SBX EQU 8 ; Screen Base X 7 | CarStartY EQU SBY+8*8 8 | CarStartX EQU SBX+8*8 9 | CarMaxShift EQU 5 10 | 11 | ScrollRightPos EQU SBX+8*15-16 12 | ScrollRightSC EQU 8*12 13 | ScrollLeftPos EQU SBX+8*5 14 | ScrollLeftSC EQU 0 15 | 16 | ScrollDownPos EQU SBY+8*14-16 17 | ;ScrollDownSC EQU 8*14 18 | ScrollUpPos EQU SBY+8*4 19 | ;ScrollUpSC EQU 0 20 | 21 | TurnWait EQU 5 22 | DriftWait EQU 30 23 | 24 | SmokeWait EQU 10 25 | 26 | BGPaletteCnt EQU 4*2 27 | ObjPaletteCnt EQU 4*1 -------------------------------------------------------------------------------- /car_game02/rom/car_game_v021.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game02/rom/car_game_v021.gbc -------------------------------------------------------------------------------- /car_game02/rom/car_game_v022.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game02/rom/car_game_v022.gbc -------------------------------------------------------------------------------- /car_game02/rom/car_game_v023.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game02/rom/car_game_v023.gbc -------------------------------------------------------------------------------- /car_game02/rom/car_game_v024.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game02/rom/car_game_v024.gbc -------------------------------------------------------------------------------- /car_game02/rom/car_game_v025.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game02/rom/car_game_v025.gbc -------------------------------------------------------------------------------- /car_game02/rom/car_game_v026.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game02/rom/car_game_v026.gbc -------------------------------------------------------------------------------- /car_game02/rom/car_game_v027.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game02/rom/car_game_v027.gbc -------------------------------------------------------------------------------- /car_game02/rom/car_game_v028-test01.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game02/rom/car_game_v028-test01.gbc -------------------------------------------------------------------------------- /car_game02/rom/car_game_v028-test02.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game02/rom/car_game_v028-test02.gbc -------------------------------------------------------------------------------- /car_game02/rom/car_game_v028-test03.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game02/rom/car_game_v028-test03.gbc -------------------------------------------------------------------------------- /car_game02/rom/car_game_v028-test04.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game02/rom/car_game_v028-test04.gbc -------------------------------------------------------------------------------- /car_game02/rom/car_game_v028-test05.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game02/rom/car_game_v028-test05.gbc -------------------------------------------------------------------------------- /car_game02/rom/car_game_v028-test06.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game02/rom/car_game_v028-test06.gbc -------------------------------------------------------------------------------- /car_game02/rom/car_game_v028-test07.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game02/rom/car_game_v028-test07.gbc -------------------------------------------------------------------------------- /car_game02/rom/car_game_v028.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game02/rom/car_game_v028.gbc -------------------------------------------------------------------------------- /car_game02/rom/car_game_v029-test01.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game02/rom/car_game_v029-test01.gbc -------------------------------------------------------------------------------- /car_game02/rom/car_game_v029.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game02/rom/car_game_v029.gbc -------------------------------------------------------------------------------- /car_game02/rom/car_game_v030-test01.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game02/rom/car_game_v030-test01.gbc -------------------------------------------------------------------------------- /car_game02/rom/car_game_v030.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game02/rom/car_game_v030.gbc -------------------------------------------------------------------------------- /car_game02/rom/car_game_v031.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game02/rom/car_game_v031.gbc -------------------------------------------------------------------------------- /car_game02/sprites.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game02/sprites.bin -------------------------------------------------------------------------------- /car_game02/sprites.gbr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game02/sprites.gbr -------------------------------------------------------------------------------- /car_game02/tiles.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game02/tiles.bin -------------------------------------------------------------------------------- /car_game02/tiles.gbr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game02/tiles.gbr -------------------------------------------------------------------------------- /car_game02/wram.inc: -------------------------------------------------------------------------------- 1 | SECTION "Shadow OAM",WRAM0[$C000] 2 | wShadowOAM: ds 4*40 ; This is the buffer we'll write sprite data to 3 | 4 | ;SECTION "State",WRAM0 5 | SECTION "State",WRAM0[$C100];debug 6 | wCarSpriteY: ds 1 7 | wCarSpriteX: ds 1 8 | 9 | wCarDir: ds 1 10 | wCarTurn: ds 1 11 | wCarSpeedY: ds 1 12 | wCarSpeedX: ds 1 13 | wCarSpeed: ds 1 14 | wCarShift: ds 1 15 | wTurnWait: ds 1 16 | wDriftWait: ds 1 17 | 18 | wSpeedWait: ds 1 19 | wSpeedWaitInit: ds 1 20 | wSpeedWaitCnt: ds 1 21 | 22 | wSmokeY: ds 1 23 | wSmokeX: ds 1 24 | wSmokeAddY: ds 1 25 | wSmokeAddX: ds 1 26 | wSmokeWait: ds 1 27 | 28 | wJoypad: ds 1 29 | wButton: ds 1 30 | 31 | SECTION "HRAM Variables",HRAM 32 | hOAMDMA: 33 | ds DMARoutineEnd - DMARoutine ; Reserve space to copy the routine to -------------------------------------------------------------------------------- /car_game03/RunLengthEncoder.php: -------------------------------------------------------------------------------- 1 | \n"; 10 | exit; 11 | } 12 | $inpit_file = $argv[1]; 13 | $output_file = $argv[2]; 14 | 15 | $in_array = str_split(bin2hex(file_get_contents($inpit_file)),2); 16 | 17 | $val_past = array_shift($in_array); 18 | $val_next = null; 19 | $out_array = array(); 20 | do{ 21 | echo $val_past; 22 | $out_array[] = $val_past; 23 | $val_next = array_shift($in_array); 24 | if($val_past!=$val_next){ 25 | $val_past = $val_next; 26 | continue; 27 | } 28 | echo $val_next; 29 | $out_array[] = $val_next; 30 | $cnt = 2; 31 | while(1){ 32 | $val_past = array_shift($in_array); 33 | if($val_next!=$val_past || $cnt==255){ 34 | echo ":$cnt\n"; 35 | $out_array[] = dechex($cnt); 36 | break; 37 | }else{ 38 | echo $val_past; 39 | } 40 | $cnt++; 41 | } 42 | }while(count($in_array)!=0); 43 | 44 | echo "\n----\ntotal: ".count($out_array)." bytes\n"; 45 | 46 | $bin = null; 47 | for($i=0; $i -------------------------------------------------------------------------------- /car_game03/a.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ -z "$2" ] 4 | then 5 | echo "Usage: ./a.sh <.asm filename> <.gb filename>" 6 | fi 7 | 8 | rgbasm -o $1.o $1.asm 9 | rgblink -t -o $2.gbc $1.o 10 | rgbfix -v -p 0 -C $2.gbc -------------------------------------------------------------------------------- /car_game03/bg_tile0.bin: -------------------------------------------------------------------------------- 1 | #'#'#'&%$ !! !%$%$89:;Rcdeab=@@=SPV`VVVV=AA=TQ>?? -------------------------------------------------------------------------------- /car_game03/convBin.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /car_game03/equ.inc: -------------------------------------------------------------------------------- 1 | DEF JBitRight EQU 0 2 | DEF JBitLeft EQU 1 3 | DEF JBitUp EQU 2 4 | DEF JBitDown EQU 3 5 | DEF JBitButtonA EQU 4 6 | DEF JBitButtonB EQU 5 7 | 8 | DEF SBY EQU 16 ; Screen Base Y 9 | DEF SBX EQU 8 ; Screen Base X 10 | DEF UseMaxOAM EQU 16 11 | DEF CarPosY EQU SBY+8*12 12 | DEF CarPosX EQU SBX+8*9 13 | DEF CarShiftMax EQU 5 14 | DEF CarCForceWait EQU 10 15 | DEF CarCForceLeft EQU 1 16 | DEF CarCForceRight EQU 2 17 | 18 | DEF GearHi EQU 1 19 | DEF GearHiY EQU 128 20 | DEF GearHiShift EQU 3 21 | DEF GearLow EQU 0 22 | DEF GearLowY EQU 145 23 | DEF GearLowShift EQU 4 24 | 25 | ;StartBgScrollY EQU -8*4 26 | DEF StartBgScrollY EQU 0 27 | DEF JoypadWait EQU 7 28 | DEF JoyPadPos EQU 8 ; L 1-7|8|9-15 R 29 | 30 | DEF ScrollSize EQU 8*18 31 | DEF ScrollBgSize EQU 8*3 32 | DEF ScrollRoadSize EQU 8*4 33 | DEF ScrollMaxSize EQU 154 34 | 35 | ;Scenario Pattern 36 | DEF SPP14Cnt EQU 7 37 | DEF SPP23Cnt EQU 16 -------------------------------------------------------------------------------- /car_game03/macro.inc: -------------------------------------------------------------------------------- 1 | MACRO mCheckJoypad 2 | ;wJoypad 3 | ;%76543210 4 | ; |||||||+ Right 5 | ; ||||||+- Left 6 | ; |||||+-- Up 7 | ; ||||+--- Down 8 | ; |||+---- A 9 | ; ||+----- B 10 | ; |+------ Select 11 | ; +------- Start 12 | ld a,P1F_4 13 | ldh [rP1],a ; Select P14 14 | ldh a,[rP1] 15 | ldh a,[rP1] ; Wait a few cycles 16 | cpl ; Complement A 17 | and %00001111 ; Get only first 4 bits 18 | swap a 19 | ld b,a 20 | ld a,P1F_5 21 | ldh [rP1],a ; Select P15 22 | ldh a,[rP1] 23 | ldh a,[rP1] 24 | ldh a,[rP1] 25 | ldh a,[rP1] 26 | ldh a,[rP1] 27 | ldh a,[rP1] ; Wait a few MORE cycles 28 | cpl 29 | and %00001111 30 | or a,b ; Put A and B together 31 | ld [wJoypad],a 32 | ld a,P1F_4|P1F_5 ; Deselect P14 and P15. 33 | ldh [rP1],a 34 | ENDM 35 | 36 | MACRO mWaitVBlank 37 | .loop\@ 38 | ldh a,[rLY] 39 | cp SCRN_Y ; 144 ; Check if the LCD is past VBlank 40 | jr nz,.loop\@ 41 | ENDM 42 | 43 | MACRO mSetOAM 44 | ; call the DMA subroutine we copied to HRAM 45 | ; which then copies the bytes to the OAM and sprites begin to draw 46 | ld a,HIGH(wShadowOAM) 47 | call hOAMDMA 48 | ENDM 49 | 50 | MACRO mInitwShadowOAM 51 | ld hl,wShadowOAM 52 | ld c,4*40 53 | xor a 54 | .loop\@ 55 | ld [hli],a 56 | dec c 57 | jr nz,.loop\@ 58 | ENDM 59 | 60 | MACRO mResetShadowOAM 61 | ld a,l 62 | rrca 63 | rrca 64 | ld c,a 65 | ld a,UseMaxOAM 66 | sub c 67 | cp 0 68 | jr z,.skip\@ 69 | ld c,a 70 | xor a 71 | .loop\@ 72 | ld [hli],a 73 | ld [hli],a 74 | inc l 75 | inc l 76 | dec c 77 | jr nz,.loop\@ 78 | .skip\@ 79 | ENDM 80 | 81 | MACRO mCopyDMARoutine 82 | ld hl,DMARoutine 83 | ld b,DMARoutineEnd - DMARoutine ; Number of bytes to copy 84 | ld c,LOW(hOAMDMA) ; Low byte of the destination address 85 | .loop\@ 86 | ld a,[hli] 87 | ldh [c],a 88 | inc c 89 | dec b 90 | jr nz,.loop\@ 91 | ENDM 92 | 93 | MACRO mInitWRoadXLR 94 | xor a 95 | ld hl,wRoadXLR 96 | REPT ScrollRoadSize 97 | ld [hli],a 98 | ENDR 99 | ENDM 100 | 101 | MACRO mCopyScrollRoad 102 | REPT ScrollRoadSize-1 103 | ld a,[hli] 104 | ld [de],a 105 | inc e 106 | ENDR 107 | ld a,[hl] 108 | ld [de],a 109 | ENDM 110 | 111 | MACRO mSetWBG 112 | REPT ScrollBgSize 113 | ld [hli],a 114 | ENDR 115 | ENDM 116 | 117 | MACRO mCalcWRoadY 118 | ld hl,wRoadYUD 119 | ld de,wRoadY 120 | REPT ScrollRoadSize-1 121 | ld c,[hl] 122 | ld a,[de] 123 | add a,c 124 | ld [de],a 125 | inc l 126 | inc e 127 | ENDR 128 | ld c,[hl] 129 | ld a,[de] 130 | add a,c 131 | ld [de],a 132 | ENDM 133 | 134 | MACRO mCalcWSCX 135 | ld de,wRoadX 136 | ld hl,wRoadXLR 137 | REPT ScrollRoadSize-1 138 | ld c,[hl] 139 | inc h 140 | ld a,[hli] 141 | add a,c 142 | ld [de],a 143 | dec h 144 | inc e 145 | ENDR 146 | ld c,[hl] 147 | inc h 148 | ld a,[hli] 149 | add a,c 150 | ld [de],a 151 | ENDM 152 | 153 | MACRO mSetCarCForceL 154 | ld a,[wCarShift] 155 | cp 4 156 | jr z,.shift4\@ 157 | cp 5 158 | jr z,.shift5\@ 159 | jr .skip\@ 160 | .shift4\@ 161 | ld a,CarCForceLeft 162 | ld [wCarCForce],a 163 | ld a,[wJoypad] 164 | bit JBitLeft,a 165 | jr nz,.skip\@ 166 | jr .setPos\@ 167 | .shift5\@ 168 | ld a,CarCForceLeft 169 | ld [wCarCForce],a 170 | ld a,[wJoypad] 171 | bit JBitLeft,a 172 | jr z,.setPos2\@ 173 | .setPos\@ 174 | ld a,[wCarCForceWait] 175 | cp 0 176 | jr z,.setPos2\@ 177 | dec a 178 | ld [wCarCForceWait],a 179 | jr .skip\@ 180 | .setPos2\@ 181 | ld a,[wJoyPadPos] 182 | cp 15 183 | jp z,.skip\@ 184 | inc a 185 | ld [wJoyPadPos],a 186 | ld a,CarCForceWait 187 | ld [wCarCForceWait],a 188 | .skip\@ 189 | ENDM 190 | 191 | MACRO mSetCarCForceR 192 | ld a,[wCarShift] 193 | cp 4 194 | jr z,.shift4\@ 195 | cp 5 196 | jr z,.shift5\@ 197 | jr .skip\@ 198 | .shift4\@ 199 | ld a,CarCForceRight 200 | ld [wCarCForce],a 201 | ld a,[wJoypad] 202 | bit JBitRight,a 203 | jr nz,.skip\@ 204 | jr .setPos\@ 205 | .shift5\@ 206 | ld a,CarCForceRight 207 | ld [wCarCForce],a 208 | ld a,[wJoypad] 209 | bit JBitRight,a 210 | jr z,.setPos2\@ 211 | .setPos\@ 212 | ld a,[wCarCForceWait] 213 | cp 0 214 | jr z,.setPos2\@ 215 | dec a 216 | ld [wCarCForceWait],a 217 | jr .skip\@ 218 | .setPos2\@ 219 | ld a,[wJoyPadPos] 220 | cp 1 221 | jp z,.skip\@ 222 | dec a 223 | ld [wJoyPadPos],a 224 | ld a,CarCForceWait 225 | ld [wCarCForceWait],a 226 | .skip\@ 227 | ENDM 228 | 229 | MACRO mJoypadWait 230 | ld a,[wCarShift] 231 | cp 0 232 | jp z,SetWJoyPadXLR 233 | ld a,[wJoypadWait] 234 | cp 0 235 | jr z,.next\@ 236 | dec a 237 | ld [wJoypadWait],a 238 | jp SetWJoyPadXLR 239 | .next\@ 240 | ld a,JoypadWait 241 | ld [wJoypadWait],a 242 | ENDM 243 | 244 | MACRO mCarShift 245 | ld h,HIGH(CarSpeedTbl) 246 | rlca 247 | rlca 248 | ld l,a 249 | ld a,[hli] 250 | ld [wCarShiftWait],a 251 | ld a,[hli] 252 | ld [wCarSpeed],a 253 | ld a,[hli] 254 | ld [wCarScroll],a 255 | ld a,[hl] 256 | ld [wRivalWaitDef],a 257 | ENDM 258 | 259 | MACRO mSetEngineSound 260 | ld a,[wEngineSound] 261 | ld c,a 262 | ld a,[wCarShift] 263 | cp c 264 | jr z,.exit\@ 265 | ld [wEngineSound],a 266 | rlca 267 | rlca 268 | ld hl,SoundTbl 269 | add a,l 270 | ld l,a 271 | ld a,[hli] 272 | ldh [rAUD3LEVEL],a ; Output level 273 | ld a,[hli] 274 | ldh [rAUD3LOW],a ; Frequency low 275 | ld a,[hl] 276 | ldh [rAUD3HIGH],a ; Frequency hi 277 | .exit\@ 278 | ENDM 279 | 280 | MACRO mSetRivalCarSprite 281 | ld a,[wRivalTblZ+\1] 282 | cp 0 283 | jr z,.skip\@ 284 | ld [wRivalPosZ],a 285 | ld a,[wRivalTblX+\1] 286 | ld [wRivalPosX],a 287 | ld a,[wRivalTblPal+\1] 288 | ld [wRivalPal],a 289 | call SetRivalCarSprite 290 | .skip\@ 291 | ENDM 292 | 293 | MACRO mSetPalette 294 | ld a,[hli] 295 | ld [de],a 296 | ld a,[hli] 297 | ld [de],a 298 | ENDM 299 | 300 | MACRO mJpScenario 301 | ld a,[wSPoint] 302 | ld l,a 303 | ld a,[wSPoint+1] 304 | ld h,a 305 | jp hl 306 | ENDM 307 | 308 | MACRO mSetLCDC 309 | ld a,LCDCF_ON|LCDCF_OBJON|LCDCF_BGON|LCDCF_OBJ16 310 | ENDM -------------------------------------------------------------------------------- /car_game03/rom/car_game_v032-test01.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game03/rom/car_game_v032-test01.gbc -------------------------------------------------------------------------------- /car_game03/rom/car_game_v032-test02.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game03/rom/car_game_v032-test02.gbc -------------------------------------------------------------------------------- /car_game03/rom/car_game_v032-test03.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game03/rom/car_game_v032-test03.gbc -------------------------------------------------------------------------------- /car_game03/rom/car_game_v032-test04.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game03/rom/car_game_v032-test04.gbc -------------------------------------------------------------------------------- /car_game03/rom/car_game_v032.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game03/rom/car_game_v032.gbc -------------------------------------------------------------------------------- /car_game03/rom/car_game_v033.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game03/rom/car_game_v033.gbc -------------------------------------------------------------------------------- /car_game03/rom/car_game_v034.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game03/rom/car_game_v034.gbc -------------------------------------------------------------------------------- /car_game03/rom/car_game_v035.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game03/rom/car_game_v035.gbc -------------------------------------------------------------------------------- /car_game03/rom/car_game_v036.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game03/rom/car_game_v036.gbc -------------------------------------------------------------------------------- /car_game03/rom/car_game_v037.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game03/rom/car_game_v037.gbc -------------------------------------------------------------------------------- /car_game03/rom/car_game_v038.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game03/rom/car_game_v038.gbc -------------------------------------------------------------------------------- /car_game03/rom/car_game_v039.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game03/rom/car_game_v039.gbc -------------------------------------------------------------------------------- /car_game03/rom/car_game_v040-test01.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game03/rom/car_game_v040-test01.gbc -------------------------------------------------------------------------------- /car_game03/rom/car_game_v040-test03.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game03/rom/car_game_v040-test03.gbc -------------------------------------------------------------------------------- /car_game03/rom/car_game_v040-test04.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game03/rom/car_game_v040-test04.gbc -------------------------------------------------------------------------------- /car_game03/rom/car_game_v040.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game03/rom/car_game_v040.gbc -------------------------------------------------------------------------------- /car_game03/rom/car_game_v041-test01.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game03/rom/car_game_v041-test01.gbc -------------------------------------------------------------------------------- /car_game03/rom/car_game_v041-test02.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game03/rom/car_game_v041-test02.gbc -------------------------------------------------------------------------------- /car_game03/rom/car_game_v041-test03.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game03/rom/car_game_v041-test03.gbc -------------------------------------------------------------------------------- /car_game03/rom/car_game_v041.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game03/rom/car_game_v041.gbc -------------------------------------------------------------------------------- /car_game03/rom/car_game_v042-test01.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game03/rom/car_game_v042-test01.gbc -------------------------------------------------------------------------------- /car_game03/rom/car_game_v042.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game03/rom/car_game_v042.gbc -------------------------------------------------------------------------------- /car_game03/rom/car_game_v043-test01.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game03/rom/car_game_v043-test01.gbc -------------------------------------------------------------------------------- /car_game03/rom/car_game_v043-test02.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game03/rom/car_game_v043-test02.gbc -------------------------------------------------------------------------------- /car_game03/rom/car_game_v043.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game03/rom/car_game_v043.gbc -------------------------------------------------------------------------------- /car_game03/rom/car_game_v044-test01.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game03/rom/car_game_v044-test01.gbc -------------------------------------------------------------------------------- /car_game03/rom/car_game_v044-test02.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game03/rom/car_game_v044-test02.gbc -------------------------------------------------------------------------------- /car_game03/rom/car_game_v044-test03.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game03/rom/car_game_v044-test03.gbc -------------------------------------------------------------------------------- /car_game03/rom/car_game_v044.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game03/rom/car_game_v044.gbc -------------------------------------------------------------------------------- /car_game03/rom/car_game_v045-test01.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game03/rom/car_game_v045-test01.gbc -------------------------------------------------------------------------------- /car_game03/rom/car_game_v045-test02.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game03/rom/car_game_v045-test02.gbc -------------------------------------------------------------------------------- /car_game03/rom/car_game_v045-test03.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game03/rom/car_game_v045-test03.gbc -------------------------------------------------------------------------------- /car_game03/rom/car_game_v045.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game03/rom/car_game_v045.gbc -------------------------------------------------------------------------------- /car_game03/rom/car_game_v046-test01.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game03/rom/car_game_v046-test01.gbc -------------------------------------------------------------------------------- /car_game03/rom/car_game_v046-test02.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game03/rom/car_game_v046-test02.gbc -------------------------------------------------------------------------------- /car_game03/rom/car_game_v046-test03.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game03/rom/car_game_v046-test03.gbc -------------------------------------------------------------------------------- /car_game03/rom/car_game_v046.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game03/rom/car_game_v046.gbc -------------------------------------------------------------------------------- /car_game03/rom/car_game_v047-test01.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game03/rom/car_game_v047-test01.gbc -------------------------------------------------------------------------------- /car_game03/sprites.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game03/sprites.bin -------------------------------------------------------------------------------- /car_game03/sprites.gbr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game03/sprites.gbr -------------------------------------------------------------------------------- /car_game03/sprites_comp.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game03/sprites_comp.bin -------------------------------------------------------------------------------- /car_game03/tiles.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game03/tiles.bin -------------------------------------------------------------------------------- /car_game03/tiles.gbr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game03/tiles.gbr -------------------------------------------------------------------------------- /car_game03/tiles_comp.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game03/tiles_comp.bin -------------------------------------------------------------------------------- /car_game03/wram.inc: -------------------------------------------------------------------------------- 1 | SECTION "Shadow OAM",WRAM0[$C000] 2 | wShadowOAM: ds 4*40 ; This is the buffer we'll write sprite data to 3 | 4 | State: 5 | wJoypad: ds 1 6 | wJoyPadPos: ds 1 7 | wJoypadWait: ds 1 8 | wRoadPTbl: ds 1 9 | wRoadPCnt: ds 1 10 | wRoadPWait: ds 1 11 | wRoadPWork: ds 1 12 | wRoadPLRCnt: ds 1 13 | wRoadPos: ds 1 14 | wRoadPPalH: ds 1 15 | wRoadPPalL: ds 1 16 | wSPoint: ds 2 17 | wSParam: ds 1 18 | wVBlankDone: ds 1 19 | wMainLoopFlg: ds 1 20 | wCarSprite: ds 1 21 | wCarSmoke: ds 1 22 | wCarSpeed: ds 1 23 | wCarSpeedWait: ds 1 24 | wCarGear: ds 1 25 | wCarGearY: ds 1 26 | wCarShift: ds 1 27 | wCarShiftWait: ds 1 28 | wCarCForce: ds 1 29 | wCarCForceWait: ds 1 30 | wCarScroll: ds 1 31 | wAddScroll: ds 1 32 | wEngineSound: ds 1 33 | wSmokeTbl: ds 1 34 | wRivalY: ds 1 35 | wRivalX: ds 1 36 | wRivalWaitDef: ds 1 37 | wRivalWait: ds 1 38 | wRivalPosZ: ds 1 39 | wRivalPosX: ds 1 40 | wRivalPal: ds 1 41 | wRivalTbl: ds 1 42 | wRivalCnt: ds 1 43 | wLapTimeMS: ds 1 44 | wLapTimeS: ds 1 45 | wLapTimeM: ds 1 46 | StateEnd: 47 | 48 | SECTION "Rival Car Scenario Table",WRAM0[$C100] 49 | wRivalTblZ: ds 4 50 | wRivalTblX: ds 4 51 | wRivalTblPal: ds 4 52 | ;244 53 | 54 | SECTION "rSCY Table",WRAM0[$C200] 55 | wSCY: ds 55 56 | wBgY: ds ScrollBgSize ;24 57 | wRoadY: ds ScrollRoadSize ;32 58 | ds 43 ;154 59 | 60 | wRoadYUD: ds ScrollRoadSize ;32 61 | ;70 62 | 63 | SECTION "rSCX Table",WRAM0[$C300] 64 | wSCX: ds 55 65 | wBgX: ds ScrollBgSize ;24 66 | wRoadX: ds ScrollRoadSize ;32 67 | ds 43 ;154 68 | ;102 69 | 70 | SECTION "RoadXLR",WRAM0[$C400] 71 | wRoadXLR: ds ScrollRoadSize ;32 72 | ;224 73 | SECTION "JoyPadXLR",WRAM0[$C500] 74 | wJoyPadXLR: ds ScrollRoadSize ;32 75 | ;224 76 | 77 | SECTION "HRAM Variables",HRAM 78 | hOAMDMA: 79 | ds DMARoutineEnd - DMARoutine ; Reserve space to copy the routine to -------------------------------------------------------------------------------- /car_game04/a.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ -z "$2" ] 4 | then 5 | echo "Usage: ./a.sh <.asm filename> <.gb filename>" 6 | fi 7 | 8 | rgbasm -o $1.o $1.asm 9 | rgblink -t -o $2.gbc $1.o 10 | rgbfix -v -p 0 -C $2.gbc -------------------------------------------------------------------------------- /car_game04/car_macro.inc: -------------------------------------------------------------------------------- 1 | MACRO mCopyScrollRoad 2 | REPT ScrollRoadSize-1 3 | ld a,[hli] 4 | ld [de],a 5 | inc e 6 | ENDR 7 | ld a,[hl] 8 | ld [de],a 9 | ENDM 10 | 11 | MACRO mSetCar 12 | ld hl,wShadowOAM 13 | ld d,CarPosX 14 | .loop\@ 15 | ld a,CarPosY 16 | ld [hli],a ; Y Position 17 | ld a,[bc] 18 | add a,d 19 | ld [hli],a ; X Position 20 | inc c 21 | ld a,[bc] 22 | ld [hli],a ; Tile Index 23 | inc c 24 | ld a,[bc] 25 | ld [hli],a ; Attributes/Flags 26 | inc c 27 | dec e 28 | jr nz,.loop\@ 29 | ; 30 | ld a,CarPosY 31 | ld [hli],a 32 | ld a,[bc] 33 | add a,d 34 | ld [hli],a 35 | inc c 36 | ld a,[wCarTireRef] 37 | ld e,a 38 | ld a,[bc] 39 | or e 40 | ld [hli],a 41 | inc c 42 | ld a,[bc] 43 | ld [hli],a 44 | inc c 45 | ; 46 | ld a,CarPosY 47 | ld [hli],a 48 | ld a,[bc] 49 | add a,d 50 | ld [hli],a 51 | inc c 52 | ld a,[wCarTireRef] 53 | ld e,a 54 | ld a,[bc] 55 | or e 56 | ld [hli],a 57 | inc c 58 | ld a,[bc] 59 | ld [hli],a 60 | ENDM 61 | 62 | MACRO mSetRCar 63 | ld a,[wRCarXPos+\1] 64 | ld d,a 65 | REPT 2 66 | ld a,[wRCarYPos+\1] 67 | ld [hli],a ; Y Position 68 | ld a,[bc] 69 | add a,d 70 | ld [hli],a ; X Position 71 | inc c 72 | ld a,[wCarTireRef] 73 | ld e,a 74 | ld a,[bc] 75 | or e 76 | ld [hli],a ; Tile Index 77 | inc c 78 | ld a,[bc] 79 | ld [hli],a ; Attributes/Flags 80 | inc c 81 | ENDR 82 | ld a,[wRCarYPos+\1] 83 | ld [hli],a 84 | ld a,[bc] 85 | add a,d 86 | ld [hli],a 87 | inc c 88 | ld a,[bc] 89 | ld [hli],a 90 | inc c 91 | ld a,[bc] 92 | ld [hli],a 93 | inc c 94 | ; 95 | ld a,[wRCarYPos+\1] 96 | ld [hli],a 97 | ld a,[bc] 98 | add a,d 99 | ld [hli],a 100 | inc c 101 | ld a,[bc] 102 | ld [hli],a 103 | inc c 104 | ld a,[bc] 105 | ld [hli],a 106 | ; reset 107 | xor a 108 | ld [hli],a 109 | ld [hli],a 110 | ld [hli],a 111 | ld [hli],a 112 | ENDM 113 | 114 | MACRO mJoypadWait 115 | ld a,[wJoypadWait] 116 | cp 0 117 | jr z,.next\@ 118 | dec a 119 | ld [wJoypadWait],a 120 | jp SetRoadScroll 121 | .next\@ 122 | ld a,JoypadWait 123 | ld [wJoypadWait],a 124 | ENDM 125 | 126 | MACRO mSetWBG 127 | REPT ScrollBgSize 128 | ld [hli],a 129 | ENDR 130 | ENDM -------------------------------------------------------------------------------- /car_game04/equ.inc: -------------------------------------------------------------------------------- 1 | DEF JBitRight EQU 0 2 | DEF JBitLeft EQU 1 3 | ;DEF JBitUp EQU 2 4 | ;DEF JBitDown EQU 3 5 | ;DEF JBitButtonA EQU 4 6 | ;DEF JBitButtonB EQU 5 7 | 8 | DEF SBY EQU 16 ; Screen Base Y 9 | DEF SBX EQU 8 ; Screen Base X 10 | DEF ScrollBaseX EQU 8*6 11 | DEF CarPosY EQU SBY+8*15+5 12 | DEF CarPosX EQU SBX+8*8 13 | DEF CarPosWait EQU 6 14 | 15 | DEF CarPosRightMin EQU 0 16 | DEF CarPosCenter EQU 3 17 | DEF CarPosLeftMax EQU 6 18 | 19 | DEF JoypadWait EQU 4 20 | DEF JoypadLeftMin EQU 1 21 | DEF JoypadRightMax EQU 15 22 | 23 | DEF ScrollBgSize EQU 8*3 24 | DEF ScrollRoadSize EQU 8*8 25 | DEF ScrollMaxSize EQU 154 26 | 27 | DEF SOAMCarTire EQU 4*2+2 28 | 29 | ;HBlank Scroll Position Table 30 | DEF S0 EQU 0 31 | DEF S1 EQU 8*8 32 | 33 | ;Rival Car 34 | DEF RCarPosY EQU SBY+8*10 35 | DEF RY00 EQU RCarPosY+0 36 | DEF RY01 EQU RCarPosY+1 37 | DEF RY02 EQU RCarPosY+2 38 | DEF RY03 EQU RCarPosY+3 39 | DEF RY04 EQU RCarPosY+4 40 | DEF RY05 EQU RCarPosY+5 41 | DEF RY06 EQU RCarPosY+6 42 | DEF RY07 EQU RCarPosY+7 43 | DEF RY08 EQU RCarPosY+8 44 | DEF RY09 EQU RCarPosY+9 45 | DEF RY10 EQU RCarPosY+10 46 | DEF RY11 EQU RCarPosY+11 47 | DEF RY12 EQU RCarPosY+13 48 | DEF RY13 EQU RCarPosY+15 49 | DEF RY14 EQU RCarPosY+17 50 | DEF RY15 EQU RCarPosY+19 51 | DEF RY16 EQU RCarPosY+21 52 | DEF RY17 EQU RCarPosY+23 53 | DEF RY18 EQU RCarPosY+25 54 | DEF RY19 EQU RCarPosY+27 55 | DEF RY20 EQU RCarPosY+29 56 | DEF RY21 EQU RCarPosY+31 57 | DEF RY22 EQU RCarPosY+33 58 | DEF RY23 EQU RCarPosY+36 59 | DEF RY24 EQU RCarPosY+39 60 | DEF RY25 EQU RCarPosY+42 61 | DEF RY26 EQU RCarPosY+45 62 | DEF RY27 EQU RCarPosY+48 63 | DEF RY28 EQU RCarPosY+51 64 | DEF RY29 EQU RCarPosY+54 65 | DEF RY30 EQU RCarPosY+57 66 | DEF RY31 EQU RCarPosY+60 -------------------------------------------------------------------------------- /car_game04/macro.inc: -------------------------------------------------------------------------------- 1 | MACRO mCheckJoypad 2 | ;wJoypad 3 | ;%76543210 4 | ; |||||||+ Right 5 | ; ||||||+- Left 6 | ; |||||+-- Up 7 | ; ||||+--- Down 8 | ; |||+---- A 9 | ; ||+----- B 10 | ; |+------ Select 11 | ; +------- Start 12 | ld a,P1F_4 13 | ldh [rP1],a ; Select P14 14 | ldh a,[rP1] 15 | ldh a,[rP1] ; Wait a few cycles 16 | cpl ; Complement A 17 | and %00001111 ; Get only first 4 bits 18 | swap a 19 | ld b,a 20 | ld a,P1F_5 21 | ldh [rP1],a ; Select P15 22 | ldh a,[rP1] 23 | ldh a,[rP1] 24 | ldh a,[rP1] 25 | ldh a,[rP1] 26 | ldh a,[rP1] 27 | ldh a,[rP1] ; Wait a few MORE cycles 28 | cpl 29 | and %00001111 30 | or a,b ; Put A and B together 31 | ld [wJoypad],a 32 | ld a,P1F_4|P1F_5 ; Deselect P14 and P15. 33 | ldh [rP1],a 34 | ENDM 35 | 36 | MACRO mWaitVBlank 37 | .loop\@ 38 | ldh a,[rLY] 39 | cp SCRN_Y ; 144 ; Check if the LCD is past VBlank 40 | jr nz,.loop\@ 41 | ENDM 42 | 43 | MACRO mSetOAM 44 | ; Call the DMA subroutine we copied to HRAM 45 | ; Which then copies the bytes to the OAM and sprites begin to draw 46 | ld a,HIGH(wShadowOAM) 47 | call hOAMDMA 48 | ENDM 49 | 50 | MACRO mInitwShadowOAM 51 | ld hl,wShadowOAM 52 | ld c,4*40 53 | xor a 54 | .loop\@ 55 | ld [hli],a 56 | dec c 57 | jr nz,.loop\@ 58 | ENDM 59 | 60 | MACRO mCopyDMARoutine 61 | ld hl,DMARoutine 62 | ld b,DMARoutineEnd - DMARoutine 63 | ld c,LOW(hOAMDMA) 64 | .loop\@ 65 | ld a,[hli] 66 | ldh [c],a 67 | inc c 68 | dec b 69 | jr nz,.loop\@ 70 | ENDM 71 | 72 | MACRO mSetWRam 73 | .loop\@ 74 | ld [hli],a 75 | dec c 76 | jr nz,.loop\@ 77 | ENDM 78 | 79 | MACRO mCopyData 80 | .loop\@ 81 | ld a,[de] 82 | ld [hli],a 83 | inc de 84 | dec bc 85 | ld a,b 86 | or c 87 | jr nz,.loop\@ 88 | ENDM 89 | 90 | MACRO mSetPalette 91 | .loop\@ 92 | ld a,[hli] 93 | ld [de],a 94 | ld a,[hli] 95 | ld [de],a 96 | dec c 97 | jr nz,.loop\@ 98 | ENDM 99 | 100 | MACRO mCopyDecompressionData 101 | ;ld hl, 102 | ;ld de, 103 | ;ld bc, 104 | .start\@ 105 | ld a,[de] 106 | inc de 107 | ld [hli],a 108 | push bc 109 | .loop\@ 110 | ld b,a 111 | ld a,[de] 112 | cp b 113 | jr z,.next\@ 114 | inc de 115 | ld [hli],a 116 | jr .loop\@ 117 | .next\@ 118 | inc de 119 | ld [hli],a 120 | ld a,[de] 121 | inc de 122 | sub 2 123 | cp 0 124 | jr z,.skip\@ 125 | ld c,a 126 | ld a,b 127 | .copy\@ 128 | ld [hli],a 129 | dec c 130 | jr nz,.copy\@ 131 | .skip\@ 132 | pop bc 133 | ld a,b 134 | cp d 135 | jr nz,.start\@ 136 | ld a,c 137 | cp e 138 | jr nc,.start\@ 139 | ENDM -------------------------------------------------------------------------------- /car_game04/p.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | cd resource 4 | php convBin.php 5 | cd ../ -------------------------------------------------------------------------------- /car_game04/resource/RunLengthEncoder.php: -------------------------------------------------------------------------------- 1 | \n"; 10 | exit; 11 | } 12 | $inpit_file = $argv[1]; 13 | $output_file = $argv[2]; 14 | 15 | $in_array = str_split(bin2hex(file_get_contents($inpit_file)),2); 16 | 17 | $val_past = array_shift($in_array); 18 | $val_next = null; 19 | $out_array = array(); 20 | do{ 21 | echo $val_past; 22 | $out_array[] = $val_past; 23 | $val_next = array_shift($in_array); 24 | if($val_past!=$val_next){ 25 | $val_past = $val_next; 26 | continue; 27 | } 28 | echo $val_next; 29 | $out_array[] = $val_next; 30 | $cnt = 2; 31 | while(1){ 32 | $val_past = array_shift($in_array); 33 | if($val_next!=$val_past || $cnt==255){ 34 | echo ":$cnt\n"; 35 | $out_array[] = dechex($cnt); 36 | break; 37 | }else{ 38 | echo $val_past; 39 | } 40 | $cnt++; 41 | } 42 | }while(count($in_array)!=0); 43 | 44 | echo "\n----\ntotal: ".count($out_array)." bytes\n"; 45 | 46 | $bin = null; 47 | for($i=0; $i -------------------------------------------------------------------------------- /car_game04/resource/bg_tile0.bin: -------------------------------------------------------------------------------- 1 | @ABCDE$%%&##""###""##""##""###""##""##""##)())()(())()()(()()()()(())(()()   2 |  3 |    4 |  5 |   -------------------------------------------------------------------------------- /car_game04/resource/bg_tile0_comp.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game04/resource/bg_tile0_comp.bin -------------------------------------------------------------------------------- /car_game04/resource/bg_tile1.bin: -------------------------------------------------------------------------------- 1 | """"""""#####! ! ! ! ! ! ! !! !!!!!!!!!!!!!!!!!!!!!!!! -------------------------------------------------------------------------------- /car_game04/resource/bg_tile1_comp.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game04/resource/bg_tile1_comp.bin -------------------------------------------------------------------------------- /car_game04/resource/car.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game04/resource/car.psd -------------------------------------------------------------------------------- /car_game04/resource/car2.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game04/resource/car2.psd -------------------------------------------------------------------------------- /car_game04/resource/convBin.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /car_game04/resource/createRoadXPosTbl.php: -------------------------------------------------------------------------------- 1 | $val){ 50 | if($val < 0){ 51 | $hex[] = sprintf("$%02x", 256 + $val); 52 | }else{ 53 | $hex[] = sprintf("$%02x", $val); 54 | } 55 | } 56 | printf(" db %s\n",implode(",", $hex)); 57 | } 58 | } 59 | 60 | echo "\nSECTION \"Rival Car X Position Table\",ROM0[$2000]\n"; 61 | echo "RCarXPosTbl:\n"; 62 | 63 | $int_x = 11; 64 | $x0 = 8*9; 65 | $x1_list = [ //L 1-7|8|9-15 R 66 | 0, //- 67 | $x0 + $int_x*7, //1 68 | $x0 + $int_x*6, //2 69 | $x0 + $int_x*5, //3 70 | $x0 + $int_x*4, //4 71 | $x0 + $int_x*3, //5 72 | $x0 + $int_x*2, //6 73 | $x0 + $int_x*1, //7 74 | 0, //8 75 | $x0 - $int_x*1, //9 76 | $x0 - $int_x*2, //10 77 | $x0 - $int_x*3, //11 78 | $x0 - $int_x*4, //12 79 | $x0 - $int_x*5, //13 80 | $x0 - $int_x*6, //14 81 | $x0 - $int_x*7 //15 82 | ]; 83 | 84 | $rCarYPosTbl = [ 85 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,13,15,17,19, 86 | 21,23,25,27,29,31,33,36,39,42,45,48,51,54,57,60 87 | ]; 88 | 89 | for($i=0; $i<=15; $i++){ 90 | if($x1_list[$i]==0){ 91 | $hex = []; 92 | for($j=0; $j<32; $j++){ 93 | $hex[] = sprintf("$%02x", $rCarPosX); 94 | } 95 | printf(" db %s\n",implode(",", $hex)); 96 | }else{ 97 | $x1 = $x1_list[$i]; 98 | $out = calcRoadLine($y0,$x0,$y1,$x1); 99 | $hex = []; 100 | $hex2 = []; 101 | foreach($out as $key=>$val){ 102 | if($val < 0){ 103 | $hex[] = sprintf("$%02x", 256 + $val); 104 | }else{ 105 | $hex[] = sprintf("$%02x", $val); 106 | } 107 | } 108 | for($k=0; $k=$x1 && $y0>=$y1) || ($y0>=$y1)){ 119 | list($y0,$x0,$y1,$x1) = array($y1,$x1,$y0,$x0); 120 | } 121 | 122 | $dy = $y1 - $y0; 123 | 124 | if($x0<=$x1 && $y0<=$y1){ 125 | $dx = $x1 - $x0; 126 | $ax = 1; 127 | }else{ 128 | $dx = $x0 - $x1; 129 | $ax = -1; 130 | } 131 | 132 | $dy2 = $dy *2; 133 | $dx2 = $dx *2; 134 | 135 | if($dx > $dy){ 136 | $d = -$dx; 137 | $y = $y0; 138 | if($ax==1){ 139 | for($x=$x0; $x<$x1; $x+=$ax){ 140 | if($d > 0){ 141 | $y += 1; 142 | $d -= $dx2; 143 | } 144 | $d += $dy2; 145 | $road_x[ $y ] = $x; 146 | } 147 | }else{ 148 | for($x=$x0; $x>$x1; $x+=$ax){ 149 | if($d > 0){ 150 | $y += 1; 151 | $d -= $dx2; 152 | } 153 | $d += $dy2; 154 | $road_x[ $y ] = $x; 155 | } 156 | } 157 | 158 | }else{ 159 | $d = -$dy; 160 | $x = $x0; 161 | for($y=$y0; $y<$y1; $y++){ 162 | if($d > 0){ 163 | $x += $ax; 164 | $d -= $dy2; 165 | } 166 | $d += $dx2; 167 | $road_x[ $y ] = $x; 168 | } 169 | } 170 | return $road_x; 171 | } 172 | 173 | ?> 174 | -------------------------------------------------------------------------------- /car_game04/resource/my_car.aseprite: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game04/resource/my_car.aseprite -------------------------------------------------------------------------------- /car_game04/resource/my_car2.aseprite: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game04/resource/my_car2.aseprite -------------------------------------------------------------------------------- /car_game04/resource/sprites.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game04/resource/sprites.bin -------------------------------------------------------------------------------- /car_game04/resource/sprites.gbr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game04/resource/sprites.gbr -------------------------------------------------------------------------------- /car_game04/resource/sprites_comp.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game04/resource/sprites_comp.bin -------------------------------------------------------------------------------- /car_game04/resource/tiles.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game04/resource/tiles.bin -------------------------------------------------------------------------------- /car_game04/resource/tiles.gbr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game04/resource/tiles.gbr -------------------------------------------------------------------------------- /car_game04/resource/tiles_comp.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game04/resource/tiles_comp.bin -------------------------------------------------------------------------------- /car_game04/rom/car_game04_v01.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game04/rom/car_game04_v01.gbc -------------------------------------------------------------------------------- /car_game04/rom/car_game04_v02.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game04/rom/car_game04_v02.gbc -------------------------------------------------------------------------------- /car_game04/rom/car_game04_v03.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game04/rom/car_game04_v03.gbc -------------------------------------------------------------------------------- /car_game04/rom/car_game04_v04-test01.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game04/rom/car_game04_v04-test01.gbc -------------------------------------------------------------------------------- /car_game04/rom/car_game04_v04-test02.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game04/rom/car_game04_v04-test02.gbc -------------------------------------------------------------------------------- /car_game04/rom/car_game04_v04-test03.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game04/rom/car_game04_v04-test03.gbc -------------------------------------------------------------------------------- /car_game04/rom/car_game04_v04.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game04/rom/car_game04_v04.gbc -------------------------------------------------------------------------------- /car_game04/rom/car_game04_v05.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/car_game04/rom/car_game04_v05.gbc -------------------------------------------------------------------------------- /car_game04/wram.inc: -------------------------------------------------------------------------------- 1 | SECTION "Shadow OAM",WRAM0[$C000] 2 | wShadowOAM: ds 4*40 ; This is the buffer we'll write sprite data to 3 | 4 | State: 5 | wRoadHi: ds 1 6 | wRoadLo: ds 1 7 | 8 | wJoypad: ds 1 9 | wJoyPadPos: ds 1 10 | wJoypadWait: ds 1 11 | wVBlankDone: ds 1 12 | wMainLoopFlg: ds 1 13 | wPosY: ds 1 14 | wPosX: ds 1 15 | wCarPos: ds 1 16 | wCarPosWait: ds 1 17 | wCarTireCnt: ds 1 18 | wCarTireRef: ds 1 19 | wRoadCnt: ds 1 20 | wRCarYPosTbl: ds 4 21 | wRCarYPos: ds 4 22 | wRCarXPos: ds 4 23 | 24 | wRCarTblCnt: ds 1;test 25 | StateEnd: 26 | 27 | SECTION "rSCY Table",WRAM0[$C200] 28 | wSCY: ds 8*7-1 29 | wBgY: ds ScrollBgSize ;24 30 | wRoadY: ds ScrollRoadSize ;64 31 | ds 10+1 ;=154 32 | ;102 33 | 34 | SECTION "rSCX Table",WRAM0[$C300] 35 | wSCX: ds 8*7-1 36 | wBgX: ds ScrollBgSize ;24 37 | wRoadX: ds ScrollRoadSize ;64 38 | ds 10+1 ;=154 39 | ;102 40 | 41 | SECTION "HRAM Variables",HRAM 42 | hOAMDMA: 43 | ds DMARoutineEnd - DMARoutine ; Reserve space to copy the routine to -------------------------------------------------------------------------------- /collision0.5/map.bin: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /collision0.5/map.gbm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/collision0.5/map.gbm -------------------------------------------------------------------------------- /collision0.5/tiles.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/collision0.5/tiles.bin -------------------------------------------------------------------------------- /collision0.5/tiles.gbr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/collision0.5/tiles.gbr -------------------------------------------------------------------------------- /collision1/CalculateMemoryAddressFromXY.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/collision1/CalculateMemoryAddressFromXY.png -------------------------------------------------------------------------------- /collision1/map.bin: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /collision1/map.gbm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/collision1/map.gbm -------------------------------------------------------------------------------- /collision1/tiles.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/collision1/tiles.bin -------------------------------------------------------------------------------- /collision1/tiles.gbr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/collision1/tiles.gbr -------------------------------------------------------------------------------- /move_speed_control/map.bin: -------------------------------------------------------------------------------- 1 | 23456<=>4 2 |     3 |  4 |  BBB27896@('*+  )) -------------------------------------------------------------------------------- /move_speed_control/map.gbm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/move_speed_control/map.gbm -------------------------------------------------------------------------------- /move_speed_control/move_speed_control.gb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/move_speed_control/move_speed_control.gb -------------------------------------------------------------------------------- /move_speed_control/tiles.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/move_speed_control/tiles.bin -------------------------------------------------------------------------------- /move_speed_control/tiles.gbr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/move_speed_control/tiles.gbr -------------------------------------------------------------------------------- /move_sprite/main.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; I used this Website/Document as a reference to create "main.asm". 3 | ; 4 | ; GB ASM Programming Tutorial: Hello World! 5 | ; https://eldred.fr/gb-asm-tutorial/hello-world.html 6 | ; 7 | ; The Cycle-Accurate Game Boy Docs (p25: 7. Joypad) 8 | ; https://github.com/AntonioND/giibiiadvance/blob/master/docs/TCAGBD.pdf 9 | ; 10 | ; Pan Docs: OAM 11 | ; https://gbdev.io/pandocs/OAM.html 12 | ; 13 | ; OAM DMA tutorial 14 | ; https://gbdev.gg8.se/wiki/articles/OAM_DMA_tutorial 15 | ; 16 | 17 | INCLUDE "hardware.inc" 18 | 19 | SECTION "Header", ROM0[$100] 20 | 21 | EntryPoint: 22 | di 23 | jp Start 24 | 25 | REPT $150 - $104 26 | db 0 27 | ENDR 28 | 29 | SECTION "Initialize", ROM0 30 | 31 | Start: 32 | ; move DMA subroutine to HRAM 33 | call CopyDMARoutine 34 | 35 | ; Turn off the LCD 36 | .waitVBlank 37 | ld a, [rLY] 38 | cp 144 ; Check if the LCD is past VBlank 39 | jr c, .waitVBlank 40 | 41 | xor a ; ld a, 0 ; We only need to reset a value with bit 7 reset, but 0 does the job 42 | ld [rLCDC], a ; We will have to write to LCDC again later, so it's not a bother, really. 43 | 44 | ; Set Sprites Data 45 | ld hl, _VRAM8000 46 | ld de, SpriteTiles 47 | ld bc, SpriteTilesEnd - SpriteTiles 48 | 49 | .copySprite 50 | ld a, [de] ; Grab 1 byte from the source 51 | ld [hli], a ; Place it at the destination, incrementing hl 52 | inc de ; Move to next byte 53 | dec bc ; Decrement count 54 | ld a, b ; Check if count is 0, since `dec bc` doesn't update flags 55 | or c 56 | jr nz, .copySprite 57 | 58 | ; Init display registers 59 | ld a, %11100100 60 | ld [rBGP], a 61 | 62 | xor a 63 | ld [rSCY], a 64 | ld [rSCX], a 65 | 66 | ; Shut sound down 67 | ld [rNR52], a 68 | 69 | ; Turn screen on, display background 70 | ld a, %10000010 ; LCDCF_ON,LCDCF_OBJON 71 | ld [rLCDC], a 72 | 73 | ; Initialize wShadowOAM 74 | ld hl, wShadowOAM 75 | ld bc, 4 * 40 76 | 77 | .iniwShadowOAM 78 | ld a, $00 79 | ld [hli], a 80 | dec bc 81 | ld a, b 82 | or c 83 | jr nz, .iniwShadowOAM 84 | 85 | ; Initialize Joypad State 86 | ld a, $00 87 | ld [JOYPAD_STATE], a 88 | ld a, 80 89 | ld [JOYPAD_YPOS], a 90 | ld a, 84 91 | ld [JOYPAD_XPOS], a 92 | 93 | ; Set OAM 94 | ld hl, wShadowOAM 95 | ld a, [JOYPAD_YPOS] 96 | ld [hli], a 97 | ld a, [JOYPAD_XPOS] 98 | ld [hli], a 99 | ld a, 0 ; Tile Index 100 | ld [hli], a 101 | 102 | jp MainLoop 103 | 104 | SECTION "Main", ROM0 105 | 106 | MainLoop: 107 | ; Reading Joypad 108 | ld a, P1F_4 109 | ld [rP1], a ; select P14 110 | ld a, [rP1] 111 | ldh a, [rP1] ; Wait a few cycles. 112 | cpl ; Complement A. 113 | and a, $0F ; Get only first 4 bits. 114 | swap a ; Swap it. 115 | ld b, a 116 | ld a, P1F_5 117 | ld [rP1], a ; Select P15. 118 | ldh a, [rP1] 119 | ldh a, [rP1] 120 | ldh a, [rP1] 121 | ldh a, [rP1] 122 | ldh a, [rP1] 123 | ldh a, [rP1] ; Wait a few MORE cycles. 124 | cpl 125 | and a, $0F 126 | or a, b ; Put A and B together. 127 | ld [JOYPAD_STATE], a ; Save joypad state. 128 | ld a, $30 ; Deselect P14 and P15. 129 | ld [rP1], a 130 | 131 | ; Check JOYPAD_STATE 132 | ld a, [JOYPAD_STATE] 133 | and %00000001 134 | jr nz, IncXPos 135 | 136 | ld a, [JOYPAD_STATE] 137 | and %00000010 138 | jr nz, DecXPos 139 | 140 | ld a, [JOYPAD_STATE] 141 | and %00000100 142 | jr nz, DecYPos 143 | 144 | ld a, [JOYPAD_STATE] 145 | and %00001000 146 | jr nz, IncYPos 147 | 148 | SetOAM: 149 | ld hl, wShadowOAM 150 | ld a, [JOYPAD_YPOS] 151 | ld [hli], a 152 | ld a, [JOYPAD_XPOS] 153 | ld [hli], a 154 | 155 | .waitVBlank 156 | ld a, [rLY] 157 | cp 144 ; Check if the LCD is past VBlank 158 | jr c, .waitVBlank 159 | 160 | ; call the DMA subroutine we copied to HRAM 161 | ; which then copies the bytes to the OAM and sprites begin to draw 162 | ld a, HIGH(wShadowOAM) 163 | call hOAMDMA 164 | 165 | jr MainLoop 166 | 167 | IncXPos: 168 | ld a, [JOYPAD_XPOS] 169 | inc a 170 | ld [JOYPAD_XPOS], a 171 | jr SetOAM 172 | 173 | DecXPos: 174 | ld a, [JOYPAD_XPOS] 175 | dec a 176 | ld [JOYPAD_XPOS], a 177 | jr SetOAM 178 | 179 | IncYPos: 180 | ld a, [JOYPAD_YPOS] 181 | inc a 182 | ld [JOYPAD_YPOS], a 183 | jr SetOAM 184 | 185 | DecYPos: 186 | ld a, [JOYPAD_YPOS] 187 | dec a 188 | ld [JOYPAD_YPOS], a 189 | jr SetOAM 190 | 191 | SECTION "OAM DMA routine", ROM0 192 | 193 | CopyDMARoutine: 194 | ld hl, DMARoutine 195 | ld b, DMARoutineEnd - DMARoutine ; Number of bytes to copy 196 | ld c, LOW(hOAMDMA) ; Low byte of the destination address 197 | .copy 198 | ld a, [hli] 199 | ldh [c], a 200 | inc c 201 | dec b 202 | jr nz, .copy 203 | ret 204 | 205 | DMARoutine: 206 | ldh [rDMA], a 207 | 208 | ld a, 40 209 | .wait 210 | dec a 211 | jr nz, .wait 212 | ret 213 | DMARoutineEnd: 214 | 215 | SECTION "Sprite", ROM0 216 | 217 | SpriteTiles: 218 | INCBIN "sprite.bin" 219 | SpriteTilesEnd: 220 | 221 | SECTION "Joypad", WRAM0[_RAM] 222 | 223 | JOYPAD_STATE: 224 | ds 1 225 | JOYPAD_YPOS: 226 | ds 1 227 | JOYPAD_XPOS: 228 | ds 1 229 | 230 | SECTION "Shadow OAM", WRAM0[_RAM+$100] 231 | 232 | wShadowOAM: 233 | ds 4 * 40 ; This is the buffer we'll write sprite data to 234 | 235 | SECTION "OAM DMA", HRAM 236 | 237 | hOAMDMA: 238 | ds DMARoutineEnd - DMARoutine ; Reserve space to copy the routine to -------------------------------------------------------------------------------- /move_sprite/sprite.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/move_sprite/sprite.bin -------------------------------------------------------------------------------- /raster_scroll0.1/map.bin: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /raster_scroll0.1/map.gbm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/raster_scroll0.1/map.gbm -------------------------------------------------------------------------------- /raster_scroll0.1/tiles.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/raster_scroll0.1/tiles.bin -------------------------------------------------------------------------------- /raster_scroll0.1/tiles.gbr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/raster_scroll0.1/tiles.gbr -------------------------------------------------------------------------------- /raster_scroll0.2/map.bin: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /raster_scroll0.2/map.gbm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/raster_scroll0.2/map.gbm -------------------------------------------------------------------------------- /raster_scroll0.2/tiles.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/raster_scroll0.2/tiles.bin -------------------------------------------------------------------------------- /raster_scroll0.2/tiles.gbr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/raster_scroll0.2/tiles.gbr -------------------------------------------------------------------------------- /raster_scroll0.3/map.bin: -------------------------------------------------------------------------------- 1 |          2 |         3 |  -------------------------------------------------------------------------------- /raster_scroll0.3/map.gbm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/raster_scroll0.3/map.gbm -------------------------------------------------------------------------------- /raster_scroll0.3/raster_scroll03.gb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/raster_scroll0.3/raster_scroll03.gb -------------------------------------------------------------------------------- /raster_scroll0.3/tiles.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/raster_scroll0.3/tiles.bin -------------------------------------------------------------------------------- /raster_scroll0.3/tiles.gbr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/raster_scroll0.3/tiles.gbr -------------------------------------------------------------------------------- /raster_scroll0.4/map.bin: -------------------------------------------------------------------------------- 1 |  2 |     3 |  4 |   -------------------------------------------------------------------------------- /raster_scroll0.4/map.gbm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/raster_scroll0.4/map.gbm -------------------------------------------------------------------------------- /raster_scroll0.4/raster_scroll04.gb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/raster_scroll0.4/raster_scroll04.gb -------------------------------------------------------------------------------- /raster_scroll0.4/tiles.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/raster_scroll0.4/tiles.bin -------------------------------------------------------------------------------- /raster_scroll0.4/tiles.gbr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/raster_scroll0.4/tiles.gbr -------------------------------------------------------------------------------- /raster_scroll0.5/map.bin: -------------------------------------------------------------------------------- 1 | 23456<=>4 2 |     3 |  4 |  BBB27896@('*+  )) -------------------------------------------------------------------------------- /raster_scroll0.5/map.gbm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/raster_scroll0.5/map.gbm -------------------------------------------------------------------------------- /raster_scroll0.5/raster_scroll05.gb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/raster_scroll0.5/raster_scroll05.gb -------------------------------------------------------------------------------- /raster_scroll0.5/tiles.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/raster_scroll0.5/tiles.bin -------------------------------------------------------------------------------- /raster_scroll0.5/tiles.gbr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/raster_scroll0.5/tiles.gbr -------------------------------------------------------------------------------- /raster_scroll1/map.bin: -------------------------------------------------------------------------------- 1 | 23456<=>4 2 |     3 |  4 |  BBB27896@('*+  )) -------------------------------------------------------------------------------- /raster_scroll1/map.gbm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/raster_scroll1/map.gbm -------------------------------------------------------------------------------- /raster_scroll1/raster_scroll1.gb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/raster_scroll1/raster_scroll1.gb -------------------------------------------------------------------------------- /raster_scroll1/tiles.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/raster_scroll1/tiles.bin -------------------------------------------------------------------------------- /raster_scroll1/tiles.gbr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/raster_scroll1/tiles.gbr -------------------------------------------------------------------------------- /reading_joypad/main.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; I used this Website/Document as a reference to create "main.asm". 3 | ; 4 | ; GB ASM Programming Tutorial: Hello World! 5 | ; https://eldred.fr/gb-asm-tutorial/hello-world.html 6 | ; 7 | ; The Cycle-Accurate Game Boy Docs (p25: 7. Joypad) 8 | ; https://github.com/AntonioND/giibiiadvance/blob/master/docs/TCAGBD.pdf 9 | ; 10 | 11 | INCLUDE "hardware.inc" 12 | 13 | JOYPAD_STATE EQU _RAM 14 | 15 | SECTION "Header", ROM0[$100] 16 | 17 | EntryPoint: 18 | di 19 | jp Start 20 | 21 | REPT $150 - $104 22 | db 0 23 | ENDR 24 | 25 | SECTION "Game code", ROM0 26 | 27 | Start: 28 | ; Turn off the LCD 29 | .waitVBlank 30 | ld a, [rLY] 31 | cp 144 ; Check if the LCD is past VBlank 32 | jr c, .waitVBlank 33 | 34 | xor a ; ld a, 0 ; We only need to reset a value with bit 7 reset, but 0 does the job 35 | ld [rLCDC], a ; We will have to write to LCDC again later, so it's not a bother, really. 36 | 37 | ld hl, $9000 38 | ld de, FontTiles 39 | ld bc, FontTilesEnd - FontTiles 40 | 41 | .copyFont 42 | ld a, [de] ; Grab 1 byte from the source 43 | ld [hli], a ; Place it at the destination, incrementing hl 44 | inc de ; Move to next byte 45 | dec bc ; Decrement count 46 | ld a, b ; Check if count is 0, since `dec bc` doesn't update flags 47 | or c 48 | jr nz, .copyFont 49 | ld hl, $9800 ; This will print the string at the top-left corner of the screen 50 | ld de, NoneStr 51 | 52 | .copyString 53 | ld a, [de] 54 | ld [hli], a 55 | inc de 56 | and a ; Check if the byte we just copied is zero 57 | jr nz, .copyString ; Continue if it's not 58 | 59 | ; Init display registers 60 | ld a, %11100100 61 | ld [rBGP], a 62 | 63 | xor a 64 | ld [rSCY], a 65 | ld [rSCX], a 66 | 67 | ; Shut sound down 68 | ld [rNR52], a 69 | 70 | ; Turn screen on, display background 71 | ld a, %10000001 72 | ld [rLCDC], a 73 | 74 | .lockup 75 | ; Reading Joypad 76 | ld a, P1F_4 77 | ld [rP1], a ; select P14 78 | ld a, [rP1] 79 | ldh a, [rP1] ; Wait a few cycles. 80 | cpl ; Complement A. 81 | and a, $0F ; Get only first 4 bits. 82 | swap a ; Swap it. 83 | ld b, a 84 | ld a, P1F_5 85 | ld [rP1], a ; Select P15. 86 | ldh a, [rP1] 87 | ldh a, [rP1] 88 | ldh a, [rP1] 89 | ldh a, [rP1] 90 | ldh a, [rP1] 91 | ldh a, [rP1] ; Wait a few MORE cycles. 92 | cpl 93 | and a, $0F 94 | or a, b ; Put A and B together. 95 | ld [JOYPAD_STATE], a ; Save joypad state. 96 | ld a, $30 ; Deselect P14 and P15. 97 | ld [rP1], a 98 | 99 | ; Check JOYPAD_STATE 100 | ld a, [JOYPAD_STATE] 101 | and %00000001 102 | jr nz, .printRightStr 103 | 104 | ld a, [JOYPAD_STATE] 105 | and %00000010 106 | jr nz, .printLeftStr 107 | 108 | ld a, [JOYPAD_STATE] 109 | and %00000100 110 | jr nz, .printUpStr 111 | 112 | ld a, [JOYPAD_STATE] 113 | and %00001000 114 | jr nz, .printDownStr 115 | 116 | jr .printNoneStr 117 | 118 | ; printStr 119 | .printRightStr 120 | ld hl, $9800 121 | ld de, RightStr 122 | jr .copyString2 123 | 124 | .printLeftStr 125 | ld hl, $9800 126 | ld de, LeftStr 127 | jr .copyString2 128 | 129 | .printUpStr 130 | ld hl, $9800 131 | ld de, UpStr 132 | jr .copyString2 133 | 134 | .printDownStr 135 | ld hl, $9800 136 | ld de, DownStr 137 | jr .copyString2 138 | 139 | .printNoneStr 140 | ld hl, $9800 141 | ld de, NoneStr 142 | jr .copyString2 143 | 144 | .copyString2 145 | ld a, [de] 146 | ld [hli], a 147 | inc de 148 | and a 149 | jr nz, .copyString2 150 | 151 | jr .lockup 152 | 153 | SECTION "Font", ROM0 154 | 155 | FontTiles: 156 | INCBIN "font.chr" 157 | FontTilesEnd: 158 | 159 | NoneStr: 160 | db "None ", 0 161 | LeftStr: 162 | db "Left ", 0 163 | RightStr: 164 | db "Right", 0 165 | UpStr: 166 | db "Up ", 0 167 | DownStr: 168 | db "Down ", 0 169 | 170 | -------------------------------------------------------------------------------- /rotation_object1/main.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; I used this Website/Document as a reference to create "main.asm". 3 | ; 4 | ; 三角関数と弾幕 (Trigonometric functions and barrage) 5 | ; https://codeknowledge.livedoor.blog/archives/12749420.html 6 | ; 7 | ; Z80 固定小数と三角関数 (Z80 Fixed decimals and trigonometric functions) 8 | ; https://codeknowledge.livedoor.blog/archives/12907986.html 9 | ; 10 | ; Pan Docs 11 | ; https://gbdev.io/pandocs/ 12 | ; 13 | ; OAM DMA tutorial 14 | ; https://gbdev.gg8.se/wiki/articles/OAM_DMA_tutorial 15 | ; 16 | 17 | INCLUDE "hardware.inc" 18 | 19 | Sprite1y EQU 84 ; Y Position 20 | Sprite1x EQU 84 ; X Position 21 | Sprite1i EQU 2 ; Tile Index 22 | Sprite2y EQU 84 23 | Sprite2x EQU 84 24 | Sprite2i EQU 1 25 | Sprite2r EQU 16 ; Range 26 | 27 | SECTION "Header",ROM0[$100] 28 | 29 | EntryPoint: 30 | di 31 | jp Start 32 | 33 | REPT $150 - $104 34 | db 0 35 | ENDR 36 | 37 | SECTION "Start",ROM0[$150] 38 | 39 | Start: 40 | call CopyDMARoutine ; move DMA subroutine to HRAM 41 | call WaitVBlank 42 | 43 | xor a 44 | ldh [rLCDC],a 45 | ldh [rIE],a 46 | ldh [rIF],a 47 | ldh [rSTAT],a 48 | ldh [rNR52],a ; disable the audio 49 | ldh [rSCY],a ; Scroll Y 50 | ldh [rSCX],a ; Scroll X 51 | 52 | ; Set Tiles data 53 | ld hl,_VRAM8000 54 | ld de,Tiles 55 | ld bc,TilesEnd - Tiles 56 | call CopyTiles 57 | 58 | ; Init display registers 59 | ld a,%11100100 60 | ldh [rBGP],a ; BG Palette 61 | ldh [rOBP0],a ; Object Palette 0 62 | ldh [rOBP1],a ; Object Palette 1 63 | 64 | ; Turn screen on, display background 65 | ld a,LCDCF_ON|LCDCF_OBJON 66 | ldh [rLCDC],a 67 | 68 | call InitWShadowOAM 69 | 70 | xor a 71 | ld [wAngle],a 72 | 73 | MainLoop: 74 | ld hl,wShadowOAM 75 | call DrawSprite 76 | call DrawSprite2 77 | call SetOAM 78 | ;call WaitDraw 79 | ;call WaitVBlank 80 | 81 | jp MainLoop 82 | 83 | DrawSprite: 84 | ld a,Sprite1y 85 | ld [hli],a ; Y Position 86 | ld a,Sprite1x 87 | ld [hli],a ; X Position 88 | ld a,Sprite1i 89 | ld [hli],a ; Tile Index 90 | inc hl ; Attributes/Flags 91 | ret 92 | 93 | DrawSprite2: 94 | push hl 95 | 96 | ; Get RotateTbl 97 | ld a,[wAngle] 98 | add a,a 99 | add a,a 100 | ld l,a 101 | ld h,HIGH(RotateTbl) 102 | ld c,[hl] 103 | inc l 104 | ld b,[hl] ; BC = RotateTbl Y 105 | inc l 106 | ld e,[hl] 107 | inc l 108 | ld d,[hl] ; DE = RotateTbl X 109 | 110 | ; Calculate rotation 111 | ld h,b 112 | ld l,c 113 | ld a,Sprite2r 114 | .calcRotationY 115 | add hl,bc 116 | dec a 117 | jr nz,.calcRotationY 118 | ld a,h 119 | add a,Sprite2y 120 | ld [wSpriteY],a 121 | 122 | ld h,d 123 | ld l,e 124 | ld a,Sprite2r 125 | .calcRotationX 126 | add hl,de 127 | dec a 128 | jr nz,.calcRotationX 129 | ld a,h 130 | add a,Sprite2x 131 | ld [wSpriteX],a 132 | 133 | pop hl 134 | ld a,[wSpriteY] 135 | ld [hli],a ; Y Position 136 | ld a,[wSpriteX] 137 | ld [hli],a ; X Position 138 | ld a,Sprite2i 139 | ld [hli],a ; Tile Index 140 | ;inc hl ; Attributes/Flags 141 | 142 | ld a,[wAngle] 143 | inc a 144 | ld [wAngle],a 145 | sub a,64 146 | ret nz 147 | xor a 148 | ld [wAngle],a 149 | ret 150 | 151 | WaitDraw: 152 | ld b,5 153 | .waitDraw 154 | call WaitVBlank 155 | dec b 156 | jr nz,.waitDraw 157 | ret 158 | 159 | SetOAM: 160 | call WaitVBlank 161 | ; call the DMA subroutine we copied to HRAM 162 | ; which then copies the bytes to the OAM and sprites begin to draw 163 | ld a,HIGH(wShadowOAM) 164 | call hOAMDMA 165 | ret 166 | 167 | WaitVBlank: 168 | ldh a,[rLY] 169 | cp SCRN_Y ; 144 ; Check if the LCD is past VBlank 170 | jr nz,WaitVBlank 171 | ret 172 | 173 | CopyTiles: 174 | ld a,[de] ; Grab 1 byte from the source 175 | ld [hli],a ; Place it at the destination, incrementing hl 176 | inc de ; Move to next byte 177 | dec bc ; Decrement count 178 | ld a,b ; Check if count is 0, since `dec bc` doesn't update flags 179 | or c 180 | jr nz,CopyTiles 181 | ret 182 | 183 | CopyDMARoutine: 184 | ld hl,DMARoutine 185 | ld b,DMARoutineEnd - DMARoutine ; Number of bytes to copy 186 | ld c,LOW(hOAMDMA) ; Low byte of the destination address 187 | .copy 188 | ld a,[hli] 189 | ldh [c],a 190 | inc c 191 | dec b 192 | jr nz,.copy 193 | ret 194 | 195 | DMARoutine: 196 | ldh [rDMA],a 197 | ld a,40 198 | .wait 199 | dec a 200 | jr nz,.wait 201 | ret 202 | DMARoutineEnd: 203 | 204 | InitWShadowOAM: 205 | ld hl,wShadowOAM 206 | ld bc,4*40 207 | .initWShadowOAM 208 | xor a 209 | ld [hli],a 210 | dec bc 211 | ld a,b 212 | or c 213 | jr nz,.initWShadowOAM 214 | ret 215 | 216 | Tiles: 217 | INCBIN "tiles.bin" 218 | TilesEnd: 219 | 220 | SECTION "Rotate Table",ROM0[$3000] 221 | RotateTbl: 222 | ; Y X Y X 223 | dw $0000, $0100, $0019, $00FE, 224 | dw $0031, $00FB, $004A, $00F4, 225 | dw $0061, $00EC, $0078, $00E1, 226 | dw $008E, $00D4, $00A2, $00C5, 227 | dw $00B5, $00B5, $00C5, $00A2, 228 | dw $00D4, $008E, $00E1, $0078, 229 | dw $00EC, $0061, $00F4, $004A, 230 | dw $00FB, $0031, $00FE, $0019, 231 | dw $0100, $0000, $00FE, $FFE6, 232 | dw $00FB, $FFCE, $00F4, $FFB5, 233 | dw $00EC, $FF9E, $00E1, $FF87, 234 | dw $00D4, $FF71, $00C5, $FF5D, 235 | dw $00B5, $FF4A, $00A2, $FF3A, 236 | dw $008E, $FF2B, $0078, $FF1E, 237 | dw $0061, $FF13, $004A, $FF0B, 238 | dw $0031, $FF04, $0019, $FF01, 239 | dw $0000, $FF00, $FFE6, $FF01, 240 | dw $FFCE, $FF04, $FFB5, $FF0B, 241 | dw $FF9E, $FF13, $FF87, $FF1E, 242 | dw $FF71, $FF2B, $FF5D, $FF3A, 243 | dw $FF4A, $FF4A, $FF3A, $FF5D, 244 | dw $FF2B, $FF71, $FF1E, $FF87, 245 | dw $FF13, $FF9E, $FF0B, $FFB5, 246 | dw $FF04, $FFCE, $FF01, $FFE6, 247 | dw $FF00, $FFFF, $FF01, $0019, 248 | dw $FF04, $0031, $FF0B, $004A, 249 | dw $FF13, $0061, $FF1E, $0078, 250 | dw $FF2B, $008E, $FF3A, $00A2, 251 | dw $FF4A, $00B5, $FF5D, $00C5, 252 | dw $FF71, $00D4, $FF87, $00E1, 253 | dw $FF9E, $00EC, $FFB5, $00F4, 254 | dw $FFCE, $00FB, $FFE6, $00FE, 255 | 256 | SECTION "Shadow OAM",WRAM0[_RAM] 257 | wShadowOAM: ds 4*40 ; This is the buffer we'll write sprite data to 258 | 259 | SECTION "Work RAM",WRAM0 260 | wSpriteY: ds 1 261 | wSpriteX: ds 1 262 | wAngle: ds 1 263 | 264 | SECTION "HRAM Variables",HRAM 265 | hOAMDMA: 266 | ds DMARoutineEnd - DMARoutine ; Reserve space to copy the routine to 267 | -------------------------------------------------------------------------------- /rotation_object1/rotation_object1.gb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/rotation_object1/rotation_object1.gb -------------------------------------------------------------------------------- /rotation_object1/tiles.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/rotation_object1/tiles.bin -------------------------------------------------------------------------------- /rotation_object1/tiles.gbr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/rotation_object1/tiles.gbr -------------------------------------------------------------------------------- /rotation_object2/rotation_object2.gb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/rotation_object2/rotation_object2.gb -------------------------------------------------------------------------------- /rotation_object2/tiles.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/rotation_object2/tiles.bin -------------------------------------------------------------------------------- /rotation_object2/tiles.gbr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/rotation_object2/tiles.gbr -------------------------------------------------------------------------------- /rotation_object3/rotation_object3.gbc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/rotation_object3/rotation_object3.gbc -------------------------------------------------------------------------------- /rotation_object3/tiles.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/rotation_object3/tiles.bin -------------------------------------------------------------------------------- /rotation_object3/tiles.gbr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/rotation_object3/tiles.gbr -------------------------------------------------------------------------------- /scrolling1/bg.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/scrolling1/bg.bin -------------------------------------------------------------------------------- /scrolling1/sprite.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/scrolling1/sprite.bin -------------------------------------------------------------------------------- /scrolling2/tiles.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/scrolling2/tiles.bin -------------------------------------------------------------------------------- /scrolling2/tiles.gbr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/scrolling2/tiles.gbr -------------------------------------------------------------------------------- /scrolling3/map.bin: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /scrolling3/map.gbm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/scrolling3/map.gbm -------------------------------------------------------------------------------- /scrolling3/tiles.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/scrolling3/tiles.bin -------------------------------------------------------------------------------- /scrolling3/tiles.gbr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emutyworks/Learning-GB-Programming/50c6592e3aa11e1472d5e4a9ab23e3650d88d145/scrolling3/tiles.gbr --------------------------------------------------------------------------------