summaryrefslogtreecommitdiffstats
path: root/gbdk/gbdk-lib
diff options
context:
space:
mode:
Diffstat (limited to 'gbdk/gbdk-lib')
-rw-r--r--gbdk/gbdk-lib/Makefile8
-rw-r--r--gbdk/gbdk-lib/Makefile.common39
-rw-r--r--gbdk/gbdk-lib/examples/Makefile17
-rw-r--r--gbdk/gbdk-lib/examples/ap/Makefile17
-rw-r--r--gbdk/gbdk-lib/examples/ap/bcd/Makefile17
-rw-r--r--gbdk/gbdk-lib/examples/ap/bcd/bcd.c36
-rw-r--r--gbdk/gbdk-lib/examples/ap/colorbar/Makefile30
-rw-r--r--gbdk/gbdk-lib/examples/ap/colorbar/bar_c.c102
-rw-r--r--gbdk/gbdk-lib/examples/ap/colorbar/bar_c.gbrbin0 -> 10079 bytes
-rw-r--r--gbdk/gbdk-lib/examples/ap/colorbar/bar_c.h105
-rw-r--r--gbdk/gbdk-lib/examples/ap/colorbar/bar_m.c62
-rw-r--r--gbdk/gbdk-lib/examples/ap/colorbar/bar_m.gbmbin0 -> 12054 bytes
-rw-r--r--gbdk/gbdk-lib/examples/ap/colorbar/bar_m.h24
-rw-r--r--gbdk/gbdk-lib/examples/ap/colorbar/colorbar.c73
-rw-r--r--gbdk/gbdk-lib/examples/ap/comm/Makefile17
-rw-r--r--gbdk/gbdk-lib/examples/ap/comm/comm.c90
-rw-r--r--gbdk/gbdk-lib/examples/ap/crash/Makefile17
-rw-r--r--gbdk/gbdk-lib/examples/ap/crash/crash.c7
-rw-r--r--gbdk/gbdk-lib/examples/ap/dscan/Makefile24
-rw-r--r--gbdk/gbdk-lib/examples/ap/dscan/bkg.c238
-rw-r--r--gbdk/gbdk-lib/examples/ap/dscan/bkg.gbrbin0 -> 18665 bytes
-rw-r--r--gbdk/gbdk-lib/examples/ap/dscan/bkg.h105
-rw-r--r--gbdk/gbdk-lib/examples/ap/dscan/bkg_c.c62
-rw-r--r--gbdk/gbdk-lib/examples/ap/dscan/bkg_c.gbmbin0 -> 12054 bytes
-rw-r--r--gbdk/gbdk-lib/examples/ap/dscan/bkg_m.c62
-rw-r--r--gbdk/gbdk-lib/examples/ap/dscan/bkg_m.gbmbin0 -> 12054 bytes
-rw-r--r--gbdk/gbdk-lib/examples/ap/dscan/dscan.c751
-rw-r--r--gbdk/gbdk-lib/examples/ap/dscan/fore.c306
-rw-r--r--gbdk/gbdk-lib/examples/ap/dscan/fore.gbrbin0 -> 10079 bytes
-rw-r--r--gbdk/gbdk-lib/examples/ap/dscan/fore.h105
-rw-r--r--gbdk/gbdk-lib/examples/ap/emu_debug/Makefile17
-rw-r--r--gbdk/gbdk-lib/examples/ap/emu_debug/emu_debug.c147
-rw-r--r--gbdk/gbdk-lib/examples/ap/filltest/Makefile17
-rw-r--r--gbdk/gbdk-lib/examples/ap/filltest/filltest.c60
-rw-r--r--gbdk/gbdk-lib/examples/ap/galaxy/Makefile17
-rw-r--r--gbdk/gbdk-lib/examples/ap/galaxy/galaxy.c632
-rw-r--r--gbdk/gbdk-lib/examples/ap/gb-dtmf/Makefile24
-rw-r--r--gbdk/gbdk-lib/examples/ap/gb-dtmf/brk_btn.c41
-rw-r--r--gbdk/gbdk-lib/examples/ap/gb-dtmf/brk_btn.gbrbin0 -> 8718 bytes
-rw-r--r--gbdk/gbdk-lib/examples/ap/gb-dtmf/cursor.c39
-rw-r--r--gbdk/gbdk-lib/examples/ap/gb-dtmf/cursor.gbrbin0 -> 8718 bytes
-rw-r--r--gbdk/gbdk-lib/examples/ap/gb-dtmf/dtmf_lcd.c123
-rw-r--r--gbdk/gbdk-lib/examples/ap/gb-dtmf/dtmf_lcd.gbrbin0 -> 8718 bytes
-rw-r--r--gbdk/gbdk-lib/examples/ap/gb-dtmf/frm_lcd.c41
-rw-r--r--gbdk/gbdk-lib/examples/ap/gb-dtmf/frm_lcd.gbrbin0 -> 8718 bytes
-rw-r--r--gbdk/gbdk-lib/examples/ap/gb-dtmf/gb-dtmf.c715
-rw-r--r--gbdk/gbdk-lib/examples/ap/gb-dtmf/key_num.c69
-rw-r--r--gbdk/gbdk-lib/examples/ap/gb-dtmf/key_num.gbrbin0 -> 8718 bytes
-rw-r--r--gbdk/gbdk-lib/examples/ap/gb-dtmf/prs_btn.c41
-rw-r--r--gbdk/gbdk-lib/examples/ap/gb-dtmf/prs_btn.gbrbin0 -> 8718 bytes
-rw-r--r--gbdk/gbdk-lib/examples/ap/gbdecompress/Makefile33
-rw-r--r--gbdk/gbdk-lib/examples/ap/gbdecompress/Readme.md8
-rw-r--r--gbdk/gbdk-lib/examples/ap/gbdecompress/main.c41
-rw-r--r--gbdk/gbdk-lib/examples/ap/gbdecompress/monalisa.gbmbin0 -> 5356 bytes
-rw-r--r--gbdk/gbdk-lib/examples/ap/gbdecompress/monalisa_map.c66
-rw-r--r--gbdk/gbdk-lib/examples/ap/gbdecompress/monalisa_map.h32
-rw-r--r--gbdk/gbdk-lib/examples/ap/gbdecompress/monalisa_tiles.gbrbin0 -> 19285 bytes
-rw-r--r--gbdk/gbdk-lib/examples/ap/gbdecompress/monalisa_tiles_comp.c467
-rw-r--r--gbdk/gbdk-lib/examples/ap/gbdecompress/monalisa_tiles_comp.h107
-rw-r--r--gbdk/gbdk-lib/examples/ap/irq/Makefile17
-rw-r--r--gbdk/gbdk-lib/examples/ap/irq/irq.c62
-rw-r--r--gbdk/gbdk-lib/examples/ap/large_map/Makefile11
-rw-r--r--gbdk/gbdk-lib/examples/ap/large_map/Readme.md14
-rw-r--r--gbdk/gbdk-lib/examples/ap/large_map/bigmap_map.c1661
-rw-r--r--gbdk/gbdk-lib/examples/ap/large_map/bigmap_map.h32
-rw-r--r--gbdk/gbdk-lib/examples/ap/large_map/bigmap_tiles.c512
-rw-r--r--gbdk/gbdk-lib/examples/ap/large_map/bigmap_tiles.h107
-rw-r--r--gbdk/gbdk-lib/examples/ap/large_map/large_map.c96
-rw-r--r--gbdk/gbdk-lib/examples/ap/lcd_isr_wobble/Makefile17
-rw-r--r--gbdk/gbdk-lib/examples/ap/lcd_isr_wobble/lcd_isr_wobble.c28
-rw-r--r--gbdk/gbdk-lib/examples/ap/linkerfile/Makefile70
-rw-r--r--gbdk/gbdk-lib/examples/ap/linkerfile/Readme.md18
-rw-r--r--gbdk/gbdk-lib/examples/ap/linkerfile/src/main.c15
-rw-r--r--gbdk/gbdk-lib/examples/ap/paint/Makefile17
-rw-r--r--gbdk/gbdk-lib/examples/ap/paint/paint.c528
-rw-r--r--gbdk/gbdk-lib/examples/ap/ram_function/Makefile32
-rw-r--r--gbdk/gbdk-lib/examples/ap/ram_function/ram_fn.c71
-rw-r--r--gbdk/gbdk-lib/examples/ap/rand/Makefile17
-rw-r--r--gbdk/gbdk-lib/examples/ap/rand/rand.c59
-rw-r--r--gbdk/gbdk-lib/examples/ap/rpn/Makefile17
-rw-r--r--gbdk/gbdk-lib/examples/ap/rpn/rpn.c102
-rw-r--r--gbdk/gbdk-lib/examples/ap/scroller/Makefile17
-rw-r--r--gbdk/gbdk-lib/examples/ap/scroller/text_scroller.c72
-rw-r--r--gbdk/gbdk-lib/examples/ap/sgb_border/Makefile11
-rw-r--r--gbdk/gbdk-lib/examples/ap/sgb_border/border.c18
-rw-r--r--gbdk/gbdk-lib/examples/ap/sgb_border/border_data.c192
-rw-r--r--gbdk/gbdk-lib/examples/ap/sgb_border/border_data.h14
-rw-r--r--gbdk/gbdk-lib/examples/ap/sgb_border/sgb_border.c69
-rw-r--r--gbdk/gbdk-lib/examples/ap/sgb_border/sgb_border.h24
-rw-r--r--gbdk/gbdk-lib/examples/ap/sgb_multiplayer/Makefile17
-rw-r--r--gbdk/gbdk-lib/examples/ap/sgb_multiplayer/sgb_multiplayer.c43
-rw-r--r--gbdk/gbdk-lib/examples/ap/sound/Makefile17
-rw-r--r--gbdk/gbdk-lib/examples/ap/sound/readme.md13
-rw-r--r--gbdk/gbdk-lib/examples/ap/sound/sound.c1067
-rw-r--r--gbdk/gbdk-lib/examples/ap/space/Makefile18
-rw-r--r--gbdk/gbdk-lib/examples/ap/space/space.s1296
-rw-r--r--gbdk/gbdk-lib/examples/ap/template_minimal/Makefile33
-rw-r--r--gbdk/gbdk-lib/examples/ap/template_minimal/Readme.md7
-rw-r--r--gbdk/gbdk-lib/examples/ap/template_minimal/main.c17
-rw-r--r--gbdk/gbdk-lib/examples/ap/template_subfolders/Makefile61
-rw-r--r--gbdk/gbdk-lib/examples/ap/template_subfolders/Readme.md18
-rw-r--r--gbdk/gbdk-lib/examples/ap/template_subfolders/res/dungeon_32x32.gbmbin0 -> 7348 bytes
-rw-r--r--gbdk/gbdk-lib/examples/ap/template_subfolders/res/dungeon_32x32.gbrbin0 -> 6613 bytes
-rw-r--r--gbdk/gbdk-lib/examples/ap/template_subfolders/res/dungeon_map.c133
-rw-r--r--gbdk/gbdk-lib/examples/ap/template_subfolders/res/dungeon_map.h28
-rw-r--r--gbdk/gbdk-lib/examples/ap/template_subfolders/res/dungeon_tiles.c188
-rw-r--r--gbdk/gbdk-lib/examples/ap/template_subfolders/res/dungeon_tiles.h103
-rw-r--r--gbdk/gbdk-lib/examples/ap/template_subfolders/src/main.c31
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/Makefile17
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/banks/Makefile82
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/banks/Makefile.targets50
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/banks/src/bank.ba0.bo0.c4
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/banks/src/bank.ba0.bo2.c10
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/banks/src/bank.ba1.bo1.c10
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/banks/src/bank.ba1.bo3.c10
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/banks/src/banks.c61
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/banks_autobank/Makefile82
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/banks_autobank/Makefile.targets55
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/banks_autobank/src/banks.c76
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/banks_autobank/src/srcfile_1.c62
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/banks_autobank/src/srcfile_1.h15
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/banks_autobank/src/srcfile_2.c302
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/banks_autobank/src/srcfile_2.h15
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/banks_autobank/src/srcfile_3.c26
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/banks_autobank/src/srcfile_3.h15
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/banks_autobank/src/srcfile_4_not-autobanked.c343
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/banks_autobank/src/srcfile_4_not-autobanked.h15
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/banks_farptr/Makefile78
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/banks_farptr/Makefile.targets50
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/banks_farptr/src/bank2code.c21
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/banks_farptr/src/banks_farptr.c48
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/banks_nonintrinsic/Makefile78
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/banks_nonintrinsic/Makefile.targets50
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/banks_nonintrinsic/src/banks_nonintrinsic.c90
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/emu_debug/Makefile78
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/emu_debug/Makefile.targets50
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/emu_debug/src/emu_debug.c164
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/fonts/Makefile78
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/fonts/Makefile.targets50
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/fonts/src/fonts.c61
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/gbdecompress/Makefile105
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/gbdecompress/Makefile.targets50
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/gbdecompress/Readme.md8
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/gbdecompress/res/monalisa.gbmbin0 -> 5356 bytes
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/gbdecompress/res/monalisa_tiles.gbrbin0 -> 19285 bytes
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/gbdecompress/src/main.c43
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/gbdecompress/src/monalisa_map.c66
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/gbdecompress/src/monalisa_map.h32
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/gbdecompress/src/monalisa_tiles_comp.c467
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/gbdecompress/src/monalisa_tiles_comp.h107
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/incbin/Makefile78
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/incbin/Makefile.targets50
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/incbin/res/blanktile.binbin0 -> 16 bytes
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/incbin/res/blanktile.pngbin0 -> 92 bytes
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/incbin/res/gbdk2020.binbin0 -> 800 bytes
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/incbin/res/gbdk2020.pngbin0 -> 364 bytes
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/incbin/res/gbdk2020_map.binbin0 -> 84 bytes
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/incbin/src/main.c58
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/large_map/Makefile85
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/large_map/Makefile.targets50
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/large_map/Readme.md14
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/large_map/src/bigmap_map.c1661
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/large_map/src/bigmap_map.h32
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/large_map/src/bigmap_tiles.c512
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/large_map/src/bigmap_tiles.h107
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/large_map/src/large_map.c104
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/logo/Makefile94
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/logo/Makefile.targets50
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/logo/Readme.md4
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/logo/res/CGB/logo.pngbin0 -> 1404 bytes
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/logo/res/DMG/logo.pngbin0 -> 1404 bytes
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/logo/res/SEGA/logo.pngbin0 -> 1891 bytes
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/logo/src/main.c24
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/metasprites/Makefile105
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/metasprites/Makefile.targets50
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/metasprites/res/sprite.pngbin0 -> 4293 bytes
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/metasprites/src/metasprites.c139
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/pong/Makefile78
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/pong/Makefile.targets50
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/pong/src/pong.c143
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/randtest/Makefile78
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/randtest/Makefile.targets50
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/randtest/src/testrand.c26
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/rle_map/Makefile92
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/rle_map/Makefile.targets50
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/rle_map/Readme.md21
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/rle_map/res/asset_sources/map.binbin0 -> 2160 bytes
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/rle_map/res/asset_sources/map.gbmbin0 -> 7776 bytes
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/rle_map/res/asset_sources/map.pngbin0 -> 5968 bytes
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/rle_map/res/asset_sources/map_tiles.gbrbin0 -> 10069 bytes
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/rle_map/res/map.bin.rlebin0 -> 1733 bytes
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/rle_map/res/map_tiles.binbin0 -> 1920 bytes
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/rle_map/src/main.c81
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/scroller/Makefile78
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/scroller/Makefile.targets50
-rw-r--r--gbdk/gbdk-lib/examples/cross-platform/scroller/src/text_scroller.c87
-rw-r--r--gbdk/gbdk-lib/examples/gb/Makefile17
-rw-r--r--gbdk/gbdk-lib/examples/gb/banks/Makefile63
-rw-r--r--gbdk/gbdk-lib/examples/gb/banks/bank_0.c4
-rw-r--r--gbdk/gbdk-lib/examples/gb/banks/bank_1.c10
-rw-r--r--gbdk/gbdk-lib/examples/gb/banks/bank_2.c10
-rw-r--r--gbdk/gbdk-lib/examples/gb/banks/bank_3.c10
-rw-r--r--gbdk/gbdk-lib/examples/gb/banks/banks.c61
-rw-r--r--gbdk/gbdk-lib/examples/gb/bcd/Makefile17
-rw-r--r--gbdk/gbdk-lib/examples/gb/bcd/bcd.c36
-rw-r--r--gbdk/gbdk-lib/examples/gb/colorbar/Makefile30
-rw-r--r--gbdk/gbdk-lib/examples/gb/colorbar/bar_c.c102
-rw-r--r--gbdk/gbdk-lib/examples/gb/colorbar/bar_c.gbrbin0 -> 10079 bytes
-rw-r--r--gbdk/gbdk-lib/examples/gb/colorbar/bar_c.h105
-rw-r--r--gbdk/gbdk-lib/examples/gb/colorbar/bar_m.c62
-rw-r--r--gbdk/gbdk-lib/examples/gb/colorbar/bar_m.gbmbin0 -> 12054 bytes
-rw-r--r--gbdk/gbdk-lib/examples/gb/colorbar/bar_m.h24
-rw-r--r--gbdk/gbdk-lib/examples/gb/colorbar/colorbar.c73
-rw-r--r--gbdk/gbdk-lib/examples/gb/comm/Makefile17
-rw-r--r--gbdk/gbdk-lib/examples/gb/comm/comm.c90
-rw-r--r--gbdk/gbdk-lib/examples/gb/crash/Makefile17
-rw-r--r--gbdk/gbdk-lib/examples/gb/crash/crash.c7
-rw-r--r--gbdk/gbdk-lib/examples/gb/dscan/Makefile24
-rw-r--r--gbdk/gbdk-lib/examples/gb/dscan/bkg.c238
-rw-r--r--gbdk/gbdk-lib/examples/gb/dscan/bkg.gbrbin0 -> 18665 bytes
-rw-r--r--gbdk/gbdk-lib/examples/gb/dscan/bkg.h105
-rw-r--r--gbdk/gbdk-lib/examples/gb/dscan/bkg_c.c62
-rw-r--r--gbdk/gbdk-lib/examples/gb/dscan/bkg_c.gbmbin0 -> 12054 bytes
-rw-r--r--gbdk/gbdk-lib/examples/gb/dscan/bkg_m.c62
-rw-r--r--gbdk/gbdk-lib/examples/gb/dscan/bkg_m.gbmbin0 -> 12054 bytes
-rw-r--r--gbdk/gbdk-lib/examples/gb/dscan/dscan.c751
-rw-r--r--gbdk/gbdk-lib/examples/gb/dscan/fore.c306
-rw-r--r--gbdk/gbdk-lib/examples/gb/dscan/fore.gbrbin0 -> 10079 bytes
-rw-r--r--gbdk/gbdk-lib/examples/gb/dscan/fore.h105
-rw-r--r--gbdk/gbdk-lib/examples/gb/filltest/Makefile17
-rw-r--r--gbdk/gbdk-lib/examples/gb/filltest/filltest.c60
-rw-r--r--gbdk/gbdk-lib/examples/gb/galaxy/Makefile17
-rw-r--r--gbdk/gbdk-lib/examples/gb/galaxy/galaxy.c632
-rw-r--r--gbdk/gbdk-lib/examples/gb/gb-dtmf/Makefile24
-rw-r--r--gbdk/gbdk-lib/examples/gb/gb-dtmf/brk_btn.c41
-rw-r--r--gbdk/gbdk-lib/examples/gb/gb-dtmf/brk_btn.gbrbin0 -> 8718 bytes
-rw-r--r--gbdk/gbdk-lib/examples/gb/gb-dtmf/cursor.c39
-rw-r--r--gbdk/gbdk-lib/examples/gb/gb-dtmf/cursor.gbrbin0 -> 8718 bytes
-rw-r--r--gbdk/gbdk-lib/examples/gb/gb-dtmf/dtmf_lcd.c123
-rw-r--r--gbdk/gbdk-lib/examples/gb/gb-dtmf/dtmf_lcd.gbrbin0 -> 8718 bytes
-rw-r--r--gbdk/gbdk-lib/examples/gb/gb-dtmf/frm_lcd.c41
-rw-r--r--gbdk/gbdk-lib/examples/gb/gb-dtmf/frm_lcd.gbrbin0 -> 8718 bytes
-rw-r--r--gbdk/gbdk-lib/examples/gb/gb-dtmf/gb-dtmf.c715
-rw-r--r--gbdk/gbdk-lib/examples/gb/gb-dtmf/key_num.c69
-rw-r--r--gbdk/gbdk-lib/examples/gb/gb-dtmf/key_num.gbrbin0 -> 8718 bytes
-rw-r--r--gbdk/gbdk-lib/examples/gb/gb-dtmf/prs_btn.c41
-rw-r--r--gbdk/gbdk-lib/examples/gb/gb-dtmf/prs_btn.gbrbin0 -> 8718 bytes
-rw-r--r--gbdk/gbdk-lib/examples/gb/gbdecompress/Makefile33
-rw-r--r--gbdk/gbdk-lib/examples/gb/gbdecompress/Readme.md8
-rw-r--r--gbdk/gbdk-lib/examples/gb/gbdecompress/main.c41
-rw-r--r--gbdk/gbdk-lib/examples/gb/gbdecompress/monalisa.gbmbin0 -> 5356 bytes
-rw-r--r--gbdk/gbdk-lib/examples/gb/gbdecompress/monalisa_map.c66
-rw-r--r--gbdk/gbdk-lib/examples/gb/gbdecompress/monalisa_map.h32
-rw-r--r--gbdk/gbdk-lib/examples/gb/gbdecompress/monalisa_tiles.gbrbin0 -> 19285 bytes
-rw-r--r--gbdk/gbdk-lib/examples/gb/gbdecompress/monalisa_tiles_comp.c467
-rw-r--r--gbdk/gbdk-lib/examples/gb/gbdecompress/monalisa_tiles_comp.h107
-rw-r--r--gbdk/gbdk-lib/examples/gb/incbin/Makefile60
-rw-r--r--gbdk/gbdk-lib/examples/gb/incbin/Readme.md8
-rw-r--r--gbdk/gbdk-lib/examples/gb/incbin/res/blanktile.binbin0 -> 16 bytes
-rw-r--r--gbdk/gbdk-lib/examples/gb/incbin/res/blanktile.pngbin0 -> 92 bytes
-rw-r--r--gbdk/gbdk-lib/examples/gb/incbin/res/gbdk2020.binbin0 -> 800 bytes
-rw-r--r--gbdk/gbdk-lib/examples/gb/incbin/res/gbdk2020.pngbin0 -> 364 bytes
-rw-r--r--gbdk/gbdk-lib/examples/gb/incbin/res/gbdk2020_map.binbin0 -> 84 bytes
-rw-r--r--gbdk/gbdk-lib/examples/gb/incbin/src/main.c58
-rw-r--r--gbdk/gbdk-lib/examples/gb/irq/Makefile17
-rw-r--r--gbdk/gbdk-lib/examples/gb/irq/irq.c63
-rw-r--r--gbdk/gbdk-lib/examples/gb/isr_vector/Makefile17
-rw-r--r--gbdk/gbdk-lib/examples/gb/isr_vector/lcd_isr_wobble.c22
-rw-r--r--gbdk/gbdk-lib/examples/gb/large_map/Makefile11
-rw-r--r--gbdk/gbdk-lib/examples/gb/large_map/Readme.md14
-rw-r--r--gbdk/gbdk-lib/examples/gb/large_map/bigmap_map.c1661
-rw-r--r--gbdk/gbdk-lib/examples/gb/large_map/bigmap_map.h32
-rw-r--r--gbdk/gbdk-lib/examples/gb/large_map/bigmap_tiles.c512
-rw-r--r--gbdk/gbdk-lib/examples/gb/large_map/bigmap_tiles.h107
-rw-r--r--gbdk/gbdk-lib/examples/gb/large_map/large_map.c96
-rw-r--r--gbdk/gbdk-lib/examples/gb/lcd_isr_wobble/Makefile17
-rw-r--r--gbdk/gbdk-lib/examples/gb/lcd_isr_wobble/lcd_isr_wobble.c28
-rw-r--r--gbdk/gbdk-lib/examples/gb/linkerfile/Makefile69
-rw-r--r--gbdk/gbdk-lib/examples/gb/linkerfile/Readme.md18
-rw-r--r--gbdk/gbdk-lib/examples/gb/linkerfile/src/main.c15
-rw-r--r--gbdk/gbdk-lib/examples/gb/metasprites/Makefile36
-rw-r--r--gbdk/gbdk-lib/examples/gb/metasprites/Readme.md20
-rw-r--r--gbdk/gbdk-lib/examples/gb/metasprites/metasprites.c153
-rw-r--r--gbdk/gbdk-lib/examples/gb/metasprites/sprite.pngbin0 -> 4293 bytes
-rw-r--r--gbdk/gbdk-lib/examples/gb/paint/Makefile17
-rw-r--r--gbdk/gbdk-lib/examples/gb/paint/paint.c528
-rw-r--r--gbdk/gbdk-lib/examples/gb/ram_function/Makefile32
-rw-r--r--gbdk/gbdk-lib/examples/gb/ram_function/ram_fn.c71
-rw-r--r--gbdk/gbdk-lib/examples/gb/rand/Makefile17
-rw-r--r--gbdk/gbdk-lib/examples/gb/rand/rand.c59
-rw-r--r--gbdk/gbdk-lib/examples/gb/rpn/Makefile17
-rw-r--r--gbdk/gbdk-lib/examples/gb/rpn/rpn.c102
-rw-r--r--gbdk/gbdk-lib/examples/gb/samptest/Makefile23
-rw-r--r--gbdk/gbdk-lib/examples/gb/samptest/sample.h20
-rw-r--r--gbdk/gbdk-lib/examples/gb/samptest/sample.s97
-rw-r--r--gbdk/gbdk-lib/examples/gb/samptest/samptest.c1641
-rw-r--r--gbdk/gbdk-lib/examples/gb/scroller/Makefile17
-rw-r--r--gbdk/gbdk-lib/examples/gb/scroller/text_scroller.c72
-rw-r--r--gbdk/gbdk-lib/examples/gb/sgb_border/Makefile13
-rw-r--r--gbdk/gbdk-lib/examples/gb/sgb_border/border.c18
-rw-r--r--gbdk/gbdk-lib/examples/gb/sgb_border/gb_border.pngbin0 -> 6585 bytes
-rw-r--r--gbdk/gbdk-lib/examples/gb/sgb_border/sgb_border.c69
-rw-r--r--gbdk/gbdk-lib/examples/gb/sgb_border/sgb_border.h24
-rw-r--r--gbdk/gbdk-lib/examples/gb/sgb_multiplayer/Makefile17
-rw-r--r--gbdk/gbdk-lib/examples/gb/sgb_multiplayer/sgb_multiplayer.c47
-rw-r--r--gbdk/gbdk-lib/examples/gb/sgb_pong/Makefile17
-rw-r--r--gbdk/gbdk-lib/examples/gb/sgb_pong/sgb_pong.c144
-rw-r--r--gbdk/gbdk-lib/examples/gb/simple_physics/Makefile17
-rw-r--r--gbdk/gbdk-lib/examples/gb/simple_physics/Readme.md3
-rw-r--r--gbdk/gbdk-lib/examples/gb/simple_physics/phys.c93
-rw-r--r--gbdk/gbdk-lib/examples/gb/sound/Makefile17
-rw-r--r--gbdk/gbdk-lib/examples/gb/sound/readme.md13
-rw-r--r--gbdk/gbdk-lib/examples/gb/sound/sound.c1067
-rw-r--r--gbdk/gbdk-lib/examples/gb/space/Makefile19
-rw-r--r--gbdk/gbdk-lib/examples/gb/space/space.s1296
-rw-r--r--gbdk/gbdk-lib/examples/gb/template_minimal/Makefile33
-rw-r--r--gbdk/gbdk-lib/examples/gb/template_minimal/Readme.md7
-rw-r--r--gbdk/gbdk-lib/examples/gb/template_minimal/main.c17
-rw-r--r--gbdk/gbdk-lib/examples/gb/template_subfolders/Makefile60
-rw-r--r--gbdk/gbdk-lib/examples/gb/template_subfolders/Readme.md18
-rw-r--r--gbdk/gbdk-lib/examples/gb/template_subfolders/res/dungeon_32x32.gbmbin0 -> 7348 bytes
-rw-r--r--gbdk/gbdk-lib/examples/gb/template_subfolders/res/dungeon_32x32.gbrbin0 -> 6613 bytes
-rw-r--r--gbdk/gbdk-lib/examples/gb/template_subfolders/res/dungeon_map.c133
-rw-r--r--gbdk/gbdk-lib/examples/gb/template_subfolders/res/dungeon_map.h28
-rw-r--r--gbdk/gbdk-lib/examples/gb/template_subfolders/res/dungeon_tiles.c188
-rw-r--r--gbdk/gbdk-lib/examples/gb/template_subfolders/res/dungeon_tiles.h103
-rw-r--r--gbdk/gbdk-lib/examples/gb/template_subfolders/src/main.c31
-rw-r--r--gbdk/gbdk-lib/examples/gg/Makefile17
-rw-r--r--gbdk/gbdk-lib/examples/gg/smoke/Makefile30
-rw-r--r--gbdk/gbdk-lib/examples/gg/smoke/assets.c46
-rw-r--r--gbdk/gbdk-lib/examples/gg/smoke/banked.c7
-rw-r--r--gbdk/gbdk-lib/examples/gg/smoke/smoketest.c90
-rw-r--r--gbdk/gbdk-lib/examples/msxdos/Makefile17
-rw-r--r--gbdk/gbdk-lib/examples/msxdos/hello/Makefile30
-rw-r--r--gbdk/gbdk-lib/examples/msxdos/hello/test.c13
-rw-r--r--gbdk/gbdk-lib/examples/msxdos/smoke/Makefile30
-rw-r--r--gbdk/gbdk-lib/examples/msxdos/smoke/assets.c46
-rw-r--r--gbdk/gbdk-lib/examples/msxdos/smoke/banked.c7
-rw-r--r--gbdk/gbdk-lib/examples/msxdos/smoke/ram_bank0.s6
-rw-r--r--gbdk/gbdk-lib/examples/msxdos/smoke/ram_bank1.s6
-rw-r--r--gbdk/gbdk-lib/examples/msxdos/smoke/smoketest.c90
-rw-r--r--gbdk/gbdk-lib/examples/msxdos/test/Makefile30
-rw-r--r--gbdk/gbdk-lib/examples/msxdos/test/test.c10
-rw-r--r--gbdk/gbdk-lib/examples/sms/Makefile17
-rw-r--r--gbdk/gbdk-lib/examples/sms/smoke/Makefile30
-rw-r--r--gbdk/gbdk-lib/examples/sms/smoke/assets.c46
-rw-r--r--gbdk/gbdk-lib/examples/sms/smoke/banked.c7
-rw-r--r--gbdk/gbdk-lib/examples/sms/smoke/ram_bank0.s6
-rw-r--r--gbdk/gbdk-lib/examples/sms/smoke/ram_bank1.s6
-rw-r--r--gbdk/gbdk-lib/examples/sms/smoke/smoketest.c90
-rw-r--r--gbdk/gbdk-lib/examples/sms/test/Makefile30
-rw-r--r--gbdk/gbdk-lib/examples/sms/test/test.c11
-rw-r--r--gbdk/gbdk-lib/include/asm/sm83/provides.h4
-rw-r--r--gbdk/gbdk-lib/include/asm/sm83/stdarg.h18
-rw-r--r--gbdk/gbdk-lib/include/asm/sm83/string.h150
-rw-r--r--gbdk/gbdk-lib/include/asm/sm83/types.h70
-rw-r--r--gbdk/gbdk-lib/include/asm/types.h90
-rw-r--r--gbdk/gbdk-lib/include/asm/z80/provides.h4
-rw-r--r--gbdk/gbdk-lib/include/asm/z80/stdarg.h18
-rw-r--r--gbdk/gbdk-lib/include/asm/z80/string.h144
-rw-r--r--gbdk/gbdk-lib/include/asm/z80/types.h76
-rw-r--r--gbdk/gbdk-lib/include/assert.h47
-rw-r--r--gbdk/gbdk-lib/include/ctype.h45
-rw-r--r--gbdk/gbdk-lib/include/gb/bcd.h61
-rw-r--r--gbdk/gbdk-lib/include/gb/bgb_emu.h13
-rw-r--r--gbdk/gbdk-lib/include/gb/cgb.h182
-rw-r--r--gbdk/gbdk-lib/include/gb/crash_handler.h25
-rw-r--r--gbdk/gbdk-lib/include/gb/drawing.h145
-rw-r--r--gbdk/gbdk-lib/include/gb/emu_debug.h13
-rw-r--r--gbdk/gbdk-lib/include/gb/gb.h1732
-rw-r--r--gbdk/gbdk-lib/include/gb/gbdecompress.h62
-rw-r--r--gbdk/gbdk-lib/include/gb/hardware.h420
-rw-r--r--gbdk/gbdk-lib/include/gb/isr.h74
-rw-r--r--gbdk/gbdk-lib/include/gb/metasprites.h245
-rw-r--r--gbdk/gbdk-lib/include/gb/sgb.h65
-rw-r--r--gbdk/gbdk-lib/include/gbdk/bcd.h12
-rw-r--r--gbdk/gbdk-lib/include/gbdk/console.h45
-rw-r--r--gbdk/gbdk-lib/include/gbdk/emu_debug.h179
-rw-r--r--gbdk/gbdk-lib/include/gbdk/far_ptr.h99
-rw-r--r--gbdk/gbdk-lib/include/gbdk/font.h78
-rw-r--r--gbdk/gbdk-lib/include/gbdk/gbdecompress.h12
-rw-r--r--gbdk/gbdk-lib/include/gbdk/gbdk-lib.h26
-rw-r--r--gbdk/gbdk-lib/include/gbdk/incbin.h84
-rw-r--r--gbdk/gbdk-lib/include/gbdk/metasprites.h14
-rw-r--r--gbdk/gbdk-lib/include/gbdk/platform.h16
-rw-r--r--gbdk/gbdk-lib/include/gbdk/rledecompress.h47
-rw-r--r--gbdk/gbdk-lib/include/gbdk/version.h6
-rw-r--r--gbdk/gbdk-lib/include/limits.h69
-rw-r--r--gbdk/gbdk-lib/include/msx/hardware.h201
-rw-r--r--gbdk/gbdk-lib/include/msx/metasprites.h118
-rw-r--r--gbdk/gbdk-lib/include/msx/msx.h751
-rw-r--r--gbdk/gbdk-lib/include/rand.h83
-rw-r--r--gbdk/gbdk-lib/include/setjmp.h83
-rw-r--r--gbdk/gbdk-lib/include/sms/gbdecompress.h24
-rw-r--r--gbdk/gbdk-lib/include/sms/hardware.h216
-rw-r--r--gbdk/gbdk-lib/include/sms/metasprites.h116
-rw-r--r--gbdk/gbdk-lib/include/sms/sms.h780
-rw-r--r--gbdk/gbdk-lib/include/stdarg.h12
-rw-r--r--gbdk/gbdk-lib/include/stdatomic.h21
-rw-r--r--gbdk/gbdk-lib/include/stdbool.h40
-rw-r--r--gbdk/gbdk-lib/include/stddef.h78
-rw-r--r--gbdk/gbdk-lib/include/stdint.h274
-rw-r--r--gbdk/gbdk-lib/include/stdio.h70
-rw-r--r--gbdk/gbdk-lib/include/stdlib.h143
-rw-r--r--gbdk/gbdk-lib/include/stdnoreturn.h7
-rw-r--r--gbdk/gbdk-lib/include/string.h17
-rw-r--r--gbdk/gbdk-lib/include/time.h38
-rw-r--r--gbdk/gbdk-lib/include/typeof.h54
-rw-r--r--gbdk/gbdk-lib/include/types.h25
-rw-r--r--gbdk/gbdk-lib/libc/Makefile53
-rw-r--r--gbdk/gbdk-lib/libc/Makefile.platform8
-rw-r--r--gbdk/gbdk-lib/libc/Makefile.rules19
-rw-r--r--gbdk/gbdk-lib/libc/__assert.c38
-rw-r--r--gbdk/gbdk-lib/libc/_divslong.c35
-rw-r--r--gbdk/gbdk-lib/libc/_divulong.c351
-rw-r--r--gbdk/gbdk-lib/libc/_modslong.c35
-rw-r--r--gbdk/gbdk-lib/libc/_modulong.c55
-rw-r--r--gbdk/gbdk-lib/libc/_mullong.c91
-rw-r--r--gbdk/gbdk-lib/libc/asm/Makefile.port11
-rw-r--r--gbdk/gbdk-lib/libc/asm/sm83/Makefile22
-rw-r--r--gbdk/gbdk-lib/libc/asm/sm83/__sdcc_call_hl.s38
-rw-r--r--gbdk/gbdk-lib/libc/asm/sm83/_memcmp.s45
-rw-r--r--gbdk/gbdk-lib/libc/asm/sm83/_memmove.c54
-rw-r--r--gbdk/gbdk-lib/libc/asm/sm83/_memset.s52
-rw-r--r--gbdk/gbdk-lib/libc/asm/sm83/_strcmp.s35
-rw-r--r--gbdk/gbdk-lib/libc/asm/sm83/_strcpy.s26
-rw-r--r--gbdk/gbdk-lib/libc/asm/sm83/abs.s19
-rw-r--r--gbdk/gbdk-lib/libc/asm/sm83/arand.s116
-rw-r--r--gbdk/gbdk-lib/libc/asm/sm83/atomic_flag_test_and_set.s46
-rw-r--r--gbdk/gbdk-lib/libc/asm/sm83/bcd.s233
-rw-r--r--gbdk/gbdk-lib/libc/asm/sm83/crt0_rle.s69
-rw-r--r--gbdk/gbdk-lib/libc/asm/sm83/div.s339
-rw-r--r--gbdk/gbdk-lib/libc/asm/sm83/itoa.s190
-rw-r--r--gbdk/gbdk-lib/libc/asm/sm83/labs.s70
-rw-r--r--gbdk/gbdk-lib/libc/asm/sm83/ltoa.s222
-rw-r--r--gbdk/gbdk-lib/libc/asm/sm83/memcpy.s94
-rw-r--r--gbdk/gbdk-lib/libc/asm/sm83/mul.s158
-rw-r--r--gbdk/gbdk-lib/libc/asm/sm83/rand.s117
-rw-r--r--gbdk/gbdk-lib/libc/asm/sm83/reverse.s84
-rw-r--r--gbdk/gbdk-lib/libc/asm/sm83/setjmp.s105
-rw-r--r--gbdk/gbdk-lib/libc/asm/sm83/shift.s89
-rw-r--r--gbdk/gbdk-lib/libc/asm/sm83/strlen.s44
-rw-r--r--gbdk/gbdk-lib/libc/asm/z80/Makefile27
-rw-r--r--gbdk/gbdk-lib/libc/asm/z80/__itoa.s231
-rw-r--r--gbdk/gbdk-lib/libc/asm/z80/__ltoa.s254
-rw-r--r--gbdk/gbdk-lib/libc/asm/z80/__sdcc_call_hl.s37
-rw-r--r--gbdk/gbdk-lib/libc/asm/z80/__sdcc_call_iy.s37
-rw-r--r--gbdk/gbdk-lib/libc/asm/z80/__sdcc_critical.s54
-rw-r--r--gbdk/gbdk-lib/libc/asm/z80/__strreverse.s63
-rw-r--r--gbdk/gbdk-lib/libc/asm/z80/__uitobcd.s87
-rw-r--r--gbdk/gbdk-lib/libc/asm/z80/__ultobcd.s122
-rw-r--r--gbdk/gbdk-lib/libc/asm/z80/abs.s61
-rw-r--r--gbdk/gbdk-lib/libc/asm/z80/arand.s78
-rw-r--r--gbdk/gbdk-lib/libc/asm/z80/atomic_flag_test_and_set.s44
-rw-r--r--gbdk/gbdk-lib/libc/asm/z80/crtenter.s41
-rw-r--r--gbdk/gbdk-lib/libc/asm/z80/divmixed.s49
-rw-r--r--gbdk/gbdk-lib/libc/asm/z80/divsigned.s124
-rw-r--r--gbdk/gbdk-lib/libc/asm/z80/divunsigned.s131
-rw-r--r--gbdk/gbdk-lib/libc/asm/z80/memcmp.s38
-rw-r--r--gbdk/gbdk-lib/libc/asm/z80/memcpy.s49
-rw-r--r--gbdk/gbdk-lib/libc/asm/z80/memmove.s65
-rw-r--r--gbdk/gbdk-lib/libc/asm/z80/memset.s30
-rw-r--r--gbdk/gbdk-lib/libc/asm/z80/modmixed.s53
-rw-r--r--gbdk/gbdk-lib/libc/asm/z80/modsigned.s46
-rw-r--r--gbdk/gbdk-lib/libc/asm/z80/modunsigned.s46
-rw-r--r--gbdk/gbdk-lib/libc/asm/z80/mul.s72
-rw-r--r--gbdk/gbdk-lib/libc/asm/z80/mulchar.s68
-rw-r--r--gbdk/gbdk-lib/libc/asm/z80/rand.s52
-rw-r--r--gbdk/gbdk-lib/libc/asm/z80/setjmp.s95
-rw-r--r--gbdk/gbdk-lib/libc/asm/z80/strcpy.s48
-rw-r--r--gbdk/gbdk-lib/libc/asm/z80/strlen.s47
-rw-r--r--gbdk/gbdk-lib/libc/atoi.c31
-rw-r--r--gbdk/gbdk-lib/libc/atol.c28
-rw-r--r--gbdk/gbdk-lib/libc/atomic_flag_clear.c41
-rw-r--r--gbdk/gbdk-lib/libc/bsearch.c51
-rw-r--r--gbdk/gbdk-lib/libc/calloc.c62
-rw-r--r--gbdk/gbdk-lib/libc/free.c80
-rw-r--r--gbdk/gbdk-lib/libc/isalpha.c7
-rw-r--r--gbdk/gbdk-lib/libc/isdigit.c7
-rw-r--r--gbdk/gbdk-lib/libc/islower.c7
-rw-r--r--gbdk/gbdk-lib/libc/isspace.c7
-rw-r--r--gbdk/gbdk-lib/libc/isupper.c7
-rw-r--r--gbdk/gbdk-lib/libc/malloc.c114
-rw-r--r--gbdk/gbdk-lib/libc/printf.c11
-rw-r--r--gbdk/gbdk-lib/libc/puts.c12
-rw-r--r--gbdk/gbdk-lib/libc/qsort.c61
-rw-r--r--gbdk/gbdk-lib/libc/realloc.c139
-rw-r--r--gbdk/gbdk-lib/libc/rules-asxxxx.mk18
-rw-r--r--gbdk/gbdk-lib/libc/scanf.c153
-rw-r--r--gbdk/gbdk-lib/libc/sprintf.c112
-rw-r--r--gbdk/gbdk-lib/libc/strcat.c14
-rw-r--r--gbdk/gbdk-lib/libc/string.c36
-rw-r--r--gbdk/gbdk-lib/libc/strncat.c21
-rw-r--r--gbdk/gbdk-lib/libc/strncmp.c16
-rw-r--r--gbdk/gbdk-lib/libc/strncpy.c18
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/___sdcc_bcall.s27
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/___sdcc_bcall_ehl.s15
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/ap/Makefile47
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/ap/crash_handler.s481
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/ap/crt0.s529
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/ap/global.s533
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/ap/sfr.s111
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/cgb.s37
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/cgb_compat.s21
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/cgb_palettes.s78
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/clock.s16
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/color.s32
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/cpy_data.s44
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/crlf.c1
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/delay.s73
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/digits.c1
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/drawing.s1767
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/drawing_isr.s23
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/duck/Makefile47
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/duck/crash_handler.s476
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/duck/crt0.s468
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/duck/global.s533
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/duck/sfr.s111
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/emu_debug.s20
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/emu_debug_printf.s43
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/f_ibm_full.s2616
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/f_ibm_sh.s174
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/f_italic.s956
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/f_min.s356
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/f_spect.s886
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/far_ptr.s71
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/fill_rect.s85
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/fill_rect_bk.s22
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/fill_rect_wi.s22
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/font.s558
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/font_color.s12
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/gb/Makefile47
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/gb/crash_handler.s481
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/gb/crt0.s538
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/gb/global.s532
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/gb/sfr.s111
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/gb_decompress.s108
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/gb_decompress_tiles.s165
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/get_addr.s39
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/get_bk_t.s24
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/get_data.s120
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/get_t.s26
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/get_tile.s51
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/get_wi_t.s26
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/get_xy_t.s86
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/gprint.c7
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/gprintf.c86
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/gprintln.c19
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/gprintn.c19
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/heap.s44
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/hiramcpy.s34
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/init_tt.s52
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/init_vram.s44
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/input.s639
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/joy.s47
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/lcd.s81
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/metasprites.s82
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/metasprites_flip.s203
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/metasprites_hide.s52
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/metasprites_hide_spr.s71
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/mode.s30
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/mv_spr.s18
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/nowait.s10
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/pad.s68
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/pad_ex.s132
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/rle_decompress.s116
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/serial.s140
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/set_1bit_data.s98
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/set_bk_t.s26
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/set_data.s58
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/set_prop.s16
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/set_spr.s16
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/set_t.s28
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/set_tile.s60
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/set_tile_submap.s150
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/set_wi_t.s27
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/set_win_tile_submap.s50
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/set_xy_t.s99
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/sgb.s128
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/tim.s25
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/tim_common.s28
-rw-r--r--gbdk/gbdk-lib/libc/targets/sm83/tim_nested.s29
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/clock.s12
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/cls.s34
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/color.s17
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/coords_to_address.s47
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/delay.s53
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/emu_debug_printf.s44
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/f_ibm_full.s2616
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/f_ibm_sh.s174
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/f_italic.s957
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/f_min.s355
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/f_spect.s886
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/far_ptr.s64
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/font.s170
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/gb_decompress.s90
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/gg/Makefile44
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/gg/__sdcc_bcall.s68
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/gg/crlf.c1
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/gg/crt0.s268
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/gg/global.s345
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/gg/nmi.s8
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/gg/pad.s43
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/gg/pad_ex.s76
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/gg/palette.s107
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/gotoxy.s34
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/heap.s44
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/memset_small.s14
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/mode.s22
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/msxdos/Makefile36
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/msxdos/__sdcc_bcall.s41
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/msxdos/__sdcc_bcall_abc.s59
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/msxdos/bdos_getchar.s10
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/msxdos/bdos_gets.s34
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/msxdos/bdos_putchar.s15
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/msxdos/crlf.c1
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/msxdos/crt0.s522
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/msxdos/global.s483
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/msxdos/msx_fill_rect.s25
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/msxdos/msx_fill_rect_xy.s93
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/msxdos/msx_int.s185
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/msxdos/msx_metasprites.s77
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/msxdos/msx_metasprites_hide.s37
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/msxdos/msx_metasprites_hide_spr.s39
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/msxdos/msx_refresh_oam.s27
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/msxdos/msx_set_1bpp_data.s77
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/msxdos/msx_set_1bpp_sprite_data.s52
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/msxdos/msx_set_native_data.s73
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/msxdos/msx_set_tile_map.s29
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/msxdos/msx_set_tile_map_xy.s100
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/msxdos/msx_write_vdp.s14
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/msxdos/pad.s66
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/outi.s20
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/putchar.s126
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/rle_decompress.s100
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/scroll.s61
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/set_interrupts.s46
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/set_palette.s23
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/set_tile.s70
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/set_tile_map.s33
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/set_tile_map_compat.s33
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/set_tile_map_xy.s98
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/set_tile_map_xy_compat.s115
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/set_tile_submap.s156
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/set_tile_submap_compat.s168
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/sms/Makefile44
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/sms/__sdcc_bcall.s68
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/sms/crlf.c1
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/sms/crt0.s275
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/sms/global.s310
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/sms/nmi.s8
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/sms/pad.s38
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/sms/pad_ex.s71
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/sms/palette.s103
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/sms_fill_rect.s30
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/sms_fill_rect_compat.s30
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/sms_fill_rect_xy.s98
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/sms_fill_rect_xy_compat.s101
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/sms_int.s197
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/sms_metasprites.s82
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/sms_metasprites_hide.s37
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/sms_metasprites_hide_spr.s41
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/sms_refresh_oam.s34
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/sms_set_1bpp_data.s108
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/sms_set_2bpp_data.s144
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/sms_set_native_data.s51
-rw-r--r--gbdk/gbdk-lib/libc/targets/z80/vmemcpy.s45
-rw-r--r--gbdk/gbdk-lib/libc/time.c17
-rw-r--r--gbdk/gbdk-lib/libc/tolower.c5
-rw-r--r--gbdk/gbdk-lib/libc/toupper.c5
670 files changed, 75988 insertions, 0 deletions
diff --git a/gbdk/gbdk-lib/Makefile b/gbdk/gbdk-lib/Makefile
new file mode 100644
index 00000000..5448c6c1
--- /dev/null
+++ b/gbdk/gbdk-lib/Makefile
@@ -0,0 +1,8 @@
+# Top level Makefile
+
+all:
+ make -C libc
+
+clean:
+ rm -rf build *~
+ make -C libc clean
diff --git a/gbdk/gbdk-lib/Makefile.common b/gbdk/gbdk-lib/Makefile.common
new file mode 100644
index 00000000..cfc1a6ad
--- /dev/null
+++ b/gbdk/gbdk-lib/Makefile.common
@@ -0,0 +1,39 @@
+# Common settings
+ifndef ASM
+ASM = asxxxx
+endif
+
+ifndef MODEL
+MODEL = small
+endif
+
+ifndef PORTS
+PORTS = sm83 z80
+endif
+ifndef PLATFORMS
+PLATFORMS = gb ap duck gg sms msxdos
+endif
+
+ifndef SDCCLIB
+SDCCLIB = $(SDCCDIR)
+endif
+
+SCC = $(SDCCLIB)/bin/sdcc
+GBCC = $(SDCCLIB)/bin/lcc
+SDAR = $(subst \,/,'$(SDCCLIB)')/bin/sdar
+
+
+AS_Z80 = $(SDCCLIB)/bin/sdasz80
+AS_SM83 = $(SDCCLIB)/bin/sdasgb
+
+CLEANSPEC = *.o *.cdb *.sym *.lst *~ *.asm
+
+CFLAGS = -I$(TOPDIR)/include -D__PORT_$(PORT) -D__TARGET_$(THIS)
+CFLAGS += -m$(PORT)
+CFLAGS += --max-allocs-per-node 50000
+CFLAGS += --fsigned-char
+CC = $(SCC)
+BUILD = $(TOPDIR)/build/$(MODEL)/$(ASM)/$(THIS)
+LIB = $(BUILD)/$(THIS).lib
+
+OBJ = $(CSRC:%.c=$(BUILD)/%.o) $(ASSRC:%.s=$(BUILD)/%.o)
diff --git a/gbdk/gbdk-lib/examples/Makefile b/gbdk/gbdk-lib/examples/Makefile
new file mode 100644
index 00000000..f891d672
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/Makefile
@@ -0,0 +1,17 @@
+# Register all subdirectories in the project's root directory.
+SUBDIRS := $(wildcard */.)
+
+# Top-level phony targets.
+all clean compile.bat: $(SUBDIRS) FORCE
+# Similar to:
+# .PHONY: all clean
+# all clean: $(SUBDIRS)
+# GNU's .PHONY target is more efficient in that it explicitly declares non-files.
+
+# Recurse `make` into each subdirectory
+# Pass along targets specified at command-line (if any).
+$(SUBDIRS): FORCE
+ $(MAKE) -C $@ $(MAKECMDGOALS)
+
+# Force targets.
+FORCE: \ No newline at end of file
diff --git a/gbdk/gbdk-lib/examples/ap/Makefile b/gbdk/gbdk-lib/examples/ap/Makefile
new file mode 100644
index 00000000..f891d672
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/Makefile
@@ -0,0 +1,17 @@
+# Register all subdirectories in the project's root directory.
+SUBDIRS := $(wildcard */.)
+
+# Top-level phony targets.
+all clean compile.bat: $(SUBDIRS) FORCE
+# Similar to:
+# .PHONY: all clean
+# all clean: $(SUBDIRS)
+# GNU's .PHONY target is more efficient in that it explicitly declares non-files.
+
+# Recurse `make` into each subdirectory
+# Pass along targets specified at command-line (if any).
+$(SUBDIRS): FORCE
+ $(MAKE) -C $@ $(MAKECMDGOALS)
+
+# Force targets.
+FORCE: \ No newline at end of file
diff --git a/gbdk/gbdk-lib/examples/ap/bcd/Makefile b/gbdk/gbdk-lib/examples/ap/bcd/Makefile
new file mode 100644
index 00000000..19539f35
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/bcd/Makefile
@@ -0,0 +1,17 @@
+CC = ../../../bin/lcc -msm83:ap -Wl-j -Wm-yS
+
+BINS = bcd.pocket
+
+all: $(BINS)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+# Compile and link single file in one pass
+%.pocket: %.c
+ $(CC) -o $@ $<
+
+clean:
+ rm -f *.o *.lst *.map *.pocket *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi
+
diff --git a/gbdk/gbdk-lib/examples/ap/bcd/bcd.c b/gbdk/gbdk-lib/examples/ap/bcd/bcd.c
new file mode 100644
index 00000000..c4d57766
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/bcd/bcd.c
@@ -0,0 +1,36 @@
+#include <stdint.h>
+#include <stdio.h>
+
+#include <gbdk/platform.h>
+#include <gbdk/font.h>
+#include <gbdk/bcd.h>
+
+BCD bcd = MAKE_BCD(10203040);
+BCD bcd2 = MAKE_BCD(05060708);
+BCD bcd3 = MAKE_BCD(11111111);
+
+uint8_t len = 0;
+unsigned char buf[10];
+
+void main() {
+ font_init();
+ font_set(font_load(font_spect));
+
+ len = bcd2text(&bcd, 0x10, buf);
+ set_bkg_tiles(5, 5, len, 1, buf);
+
+ bcd_add(&bcd, &bcd2);
+
+ len = bcd2text(&bcd, 0x10, buf);
+ set_bkg_tiles(5, 6, len, 1, buf);
+
+ bcd_sub(&bcd, &bcd3);
+
+ len = bcd2text(&bcd, 0x10, buf);
+ set_bkg_tiles(5, 7, len, 1, buf);
+
+ uint2bcd(12345, &bcd);
+
+ len = bcd2text(&bcd, 0x10, buf);
+ set_bkg_tiles(5, 8, len, 1, buf);
+} \ No newline at end of file
diff --git a/gbdk/gbdk-lib/examples/ap/colorbar/Makefile b/gbdk/gbdk-lib/examples/ap/colorbar/Makefile
new file mode 100644
index 00000000..3cd0e48d
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/colorbar/Makefile
@@ -0,0 +1,30 @@
+CC = ../../../bin/lcc -msm83:ap -Wl-j -Wm-yS
+
+# CFLAGS =
+
+BINS = colorbar.pocket
+
+all: $(BINS)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+%.o: %.c
+ $(CC) $(CFLAGS) -c -o $@ $<
+
+%.o: %.s
+ $(CC) $(CFLAGS) -c -o $@ $<
+
+%.s: %.c
+ $(CC) $(CFLAGS) -S -o $@ $<
+
+%.pocket: %.o
+ $(CC) -o $@ $<
+
+clean:
+ rm -f *.o *.lst *.map *.pocket *.ihx *.sym *.cdb *.adb *.asm
+
+# Link file, and write 0x80 at position 0x143 in header
+colorbar.pocket: colorbar.o
+ $(CC) $(CFLAGS) -Wm-yC -o colorbar.pocket colorbar.o
diff --git a/gbdk/gbdk-lib/examples/ap/colorbar/bar_c.c b/gbdk/gbdk-lib/examples/ap/colorbar/bar_c.c
new file mode 100644
index 00000000..959253d7
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/colorbar/bar_c.c
@@ -0,0 +1,102 @@
+/*
+
+ BAR_C.C
+
+ Tile Source File.
+
+ Info:
+ Form : All tiles as one unit.
+ Format : Gameboy 4 color.
+ Compression : None.
+ Counter : None.
+ Tile size : 8 x 8
+ Tiles : 0 to 31
+
+ Palette colors : Included.
+ SGB Palette : None.
+ CGB Palette : 1 Byte per entry.
+
+ Convert to metatiles : No.
+
+ This file was generated by GBTD v1.6
+
+*/
+
+/* CGBpalette entries. */
+const unsigned char bar_cCGB[] =
+{
+ 0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,
+ 0x02,0x02,0x02,0x02,0x03,0x03,0x03,0x03,
+ 0x04,0x04,0x04,0x04,0x05,0x05,0x05,0x05,
+ 0x06,0x06,0x06,0x06,0x07,0x07,0x07,0x07
+};
+/* Start of tile array. */
+const unsigned char bar_c[] =
+{
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,
+ 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,
+ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
+ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0x00,0xF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xFF,0xFF,0xFF,0xFF,0xFF,0xFF
+};
+
+/* End of BAR_C.C */
diff --git a/gbdk/gbdk-lib/examples/ap/colorbar/bar_c.gbr b/gbdk/gbdk-lib/examples/ap/colorbar/bar_c.gbr
new file mode 100644
index 00000000..5274487d
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/colorbar/bar_c.gbr
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/ap/colorbar/bar_c.h b/gbdk/gbdk-lib/examples/ap/colorbar/bar_c.h
new file mode 100644
index 00000000..50db73b8
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/colorbar/bar_c.h
@@ -0,0 +1,105 @@
+/*
+
+ BAR_C.H
+
+ Include File.
+
+ Info:
+ Form : All tiles as one unit.
+ Format : Gameboy 4 color.
+ Compression : None.
+ Counter : None.
+ Tile size : 8 x 8
+ Tiles : 0 to 31
+
+ Palette colors : Included.
+ SGB Palette : None.
+ CGB Palette : 1 Byte per entry.
+
+ Convert to metatiles : No.
+
+ This file was generated by GBTD v1.6
+
+*/
+
+
+/* Bank of tiles. */
+#define bar_cBank 0
+
+/* Super Gameboy palette 0 */
+#define bar_cSGBPal0c0 0
+#define bar_cSGBPal0c1 0
+#define bar_cSGBPal0c2 0
+#define bar_cSGBPal0c3 0
+
+/* Super Gameboy palette 1 */
+#define bar_cSGBPal1c0 25368
+#define bar_cSGBPal1c1 0
+#define bar_cSGBPal1c2 4104
+#define bar_cSGBPal1c3 6
+
+/* Super Gameboy palette 2 */
+#define bar_cSGBPal2c0 0
+#define bar_cSGBPal2c1 0
+#define bar_cSGBPal2c2 4104
+#define bar_cSGBPal2c3 6
+
+/* Super Gameboy palette 3 */
+#define bar_cSGBPal3c0 0
+#define bar_cSGBPal3c1 0
+#define bar_cSGBPal3c2 4104
+#define bar_cSGBPal3c3 6
+
+/* Gameboy Color palette 0 */
+#define bar_cCGBPal0c0 32767
+#define bar_cCGBPal0c1 25368
+#define bar_cCGBPal0c2 19026
+#define bar_cCGBPal0c3 0
+
+/* Gameboy Color palette 1 */
+#define bar_cCGBPal1c0 18
+#define bar_cCGBPal1c1 24
+#define bar_cCGBPal1c2 31
+#define bar_cCGBPal1c3 12
+
+/* Gameboy Color palette 2 */
+#define bar_cCGBPal2c0 384
+#define bar_cCGBPal2c1 576
+#define bar_cCGBPal2c2 768
+#define bar_cCGBPal2c3 992
+
+/* Gameboy Color palette 3 */
+#define bar_cCGBPal3c0 12288
+#define bar_cCGBPal3c1 18432
+#define bar_cCGBPal3c2 24576
+#define bar_cCGBPal3c3 31744
+
+/* Gameboy Color palette 4 */
+#define bar_cCGBPal4c0 792
+#define bar_cCGBPal4c1 1023
+#define bar_cCGBPal4c2 396
+#define bar_cCGBPal4c3 594
+
+/* Gameboy Color palette 5 */
+#define bar_cCGBPal5c0 24600
+#define bar_cCGBPal5c1 31775
+#define bar_cCGBPal5c2 12300
+#define bar_cCGBPal5c3 18450
+
+/* Gameboy Color palette 6 */
+#define bar_cCGBPal6c0 19008
+#define bar_cCGBPal6c1 25344
+#define bar_cCGBPal6c2 32736
+#define bar_cCGBPal6c3 12672
+
+/* Gameboy Color palette 7 */
+#define bar_cCGBPal7c0 32767
+#define bar_cCGBPal7c1 25368
+#define bar_cCGBPal7c2 19026
+#define bar_cCGBPal7c3 12684
+/* CGBpalette entries. */
+extern const unsigned char bar_cCGB[];
+/* Start of tile array. */
+extern const unsigned char bar_c[];
+
+/* End of BAR_C.H */
diff --git a/gbdk/gbdk-lib/examples/ap/colorbar/bar_m.c b/gbdk/gbdk-lib/examples/ap/colorbar/bar_m.c
new file mode 100644
index 00000000..b31920ad
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/colorbar/bar_m.c
@@ -0,0 +1,62 @@
+/*
+
+ BAR_M.C
+
+ Map Source File.
+
+ Info:
+ Section :
+ Bank : 0
+ Map size : 20 x 18
+ Tile set : C:\SDK\gb-gb\tmp\bar_c.gbr
+ Plane count : 1 plane (8 bits)
+ Plane order : Tiles are continues
+
+ This file was generated by GBMB v0.8
+
+*/
+
+#define bar_mWidth 20
+#define bar_mHeight 18
+
+const unsigned char bar_m[] =
+{
+ 0x1F,0x1F,0x12,0x12,0x12,0x1B,0x1B,0x1B,0x08,0x08,
+ 0x08,0x16,0x16,0x16,0x07,0x07,0x07,0x0C,0x0C,0x0C,
+ 0x1E,0x1E,0x13,0x13,0x13,0x18,0x18,0x18,0x09,0x09,
+ 0x09,0x17,0x17,0x17,0x04,0x04,0x04,0x0D,0x0D,0x0D,
+ 0x1D,0x1D,0x10,0x10,0x10,0x19,0x19,0x19,0x0A,0x0A,
+ 0x0A,0x14,0x14,0x14,0x05,0x05,0x05,0x0E,0x0E,0x0E,
+ 0x1C,0x1C,0x11,0x11,0x11,0x1A,0x1A,0x1A,0x0B,0x0B,
+ 0x0B,0x15,0x15,0x15,0x06,0x06,0x06,0x0F,0x0F,0x0F,
+ 0x1C,0x1C,0x11,0x11,0x11,0x1A,0x1A,0x1A,0x0B,0x0B,
+ 0x0B,0x15,0x15,0x15,0x06,0x06,0x06,0x0F,0x0F,0x0F,
+ 0x1C,0x1C,0x11,0x11,0x11,0x1A,0x1A,0x1A,0x0B,0x0B,
+ 0x0B,0x15,0x15,0x15,0x06,0x06,0x06,0x0F,0x0F,0x0F,
+ 0x1C,0x1C,0x11,0x11,0x11,0x1A,0x1A,0x1A,0x0B,0x0B,
+ 0x0B,0x15,0x15,0x15,0x06,0x06,0x06,0x0F,0x0F,0x0F,
+ 0x1C,0x1C,0x11,0x11,0x11,0x1A,0x1A,0x1A,0x0B,0x0B,
+ 0x0B,0x15,0x15,0x15,0x06,0x06,0x06,0x0F,0x0F,0x0F,
+ 0x1C,0x1C,0x11,0x11,0x11,0x1A,0x1A,0x1A,0x0B,0x0B,
+ 0x0B,0x15,0x15,0x15,0x06,0x06,0x06,0x0F,0x0F,0x0F,
+ 0x1C,0x1C,0x11,0x11,0x11,0x1A,0x1A,0x1A,0x0B,0x0B,
+ 0x0B,0x15,0x15,0x15,0x06,0x06,0x06,0x0F,0x0F,0x0F,
+ 0x1C,0x1C,0x11,0x11,0x11,0x1A,0x1A,0x1A,0x0B,0x0B,
+ 0x0B,0x15,0x15,0x15,0x06,0x06,0x06,0x0F,0x0F,0x0F,
+ 0x1C,0x1C,0x11,0x11,0x11,0x1A,0x1A,0x1A,0x0B,0x0B,
+ 0x0B,0x15,0x15,0x15,0x06,0x06,0x06,0x0F,0x0F,0x0F,
+ 0x1C,0x1C,0x11,0x11,0x11,0x1A,0x1A,0x1A,0x0B,0x0B,
+ 0x0B,0x15,0x15,0x15,0x06,0x06,0x06,0x0F,0x0F,0x0F,
+ 0x1C,0x1C,0x11,0x11,0x11,0x1A,0x1A,0x1A,0x0B,0x0B,
+ 0x0B,0x15,0x15,0x15,0x06,0x06,0x06,0x0F,0x0F,0x0F,
+ 0x0F,0x0F,0x03,0x03,0x03,0x15,0x15,0x15,0x03,0x03,
+ 0x03,0x1A,0x1A,0x1A,0x03,0x03,0x03,0x1C,0x1C,0x1C,
+ 0x0D,0x0D,0x0D,0x0D,0x00,0x00,0x00,0x00,0x16,0x16,
+ 0x16,0x16,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
+ 0x0D,0x0D,0x0D,0x0D,0x00,0x00,0x00,0x00,0x16,0x16,
+ 0x16,0x16,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
+ 0x0D,0x0D,0x0D,0x0D,0x00,0x00,0x00,0x00,0x16,0x16,
+ 0x16,0x16,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
+};
+
+/* End of BAR_M.C */
diff --git a/gbdk/gbdk-lib/examples/ap/colorbar/bar_m.gbm b/gbdk/gbdk-lib/examples/ap/colorbar/bar_m.gbm
new file mode 100644
index 00000000..bea96c12
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/colorbar/bar_m.gbm
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/ap/colorbar/bar_m.h b/gbdk/gbdk-lib/examples/ap/colorbar/bar_m.h
new file mode 100644
index 00000000..0d42d703
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/colorbar/bar_m.h
@@ -0,0 +1,24 @@
+/*
+
+ BAR_M.H
+
+ Map Include File.
+
+ Info:
+ Section :
+ Bank : 0
+ Map size : 20 x 18
+ Tile set : C:\SDK\gb-gb\tmp\bar_c.gbr
+ Plane count : 1 plane (8 bits)
+ Plane order : Tiles are continues
+
+ This file was generated by GBMB v0.8
+
+*/
+
+#define bar_mWidth 20
+#define bar_mHeight 18
+
+extern const unsigned char bar_m[];
+
+/* End of BAR_M.H */
diff --git a/gbdk/gbdk-lib/examples/ap/colorbar/colorbar.c b/gbdk/gbdk-lib/examples/ap/colorbar/colorbar.c
new file mode 100644
index 00000000..14ad1bb0
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/colorbar/colorbar.c
@@ -0,0 +1,73 @@
+#include <gb/gb.h>
+#include <gb/cgb.h>
+#include <stdint.h>
+
+#include "bar_c.h"
+#include "bar_c.c"
+#include "bar_m.c"
+
+const uint16_t bar_p[] =
+{
+ bar_cCGBPal0c0,bar_cCGBPal0c1,bar_cCGBPal0c2,bar_cCGBPal0c3,
+ bar_cCGBPal1c0,bar_cCGBPal1c1,bar_cCGBPal1c2,bar_cCGBPal1c3,
+ bar_cCGBPal2c0,bar_cCGBPal2c1,bar_cCGBPal2c2,bar_cCGBPal2c3,
+ bar_cCGBPal3c0,bar_cCGBPal3c1,bar_cCGBPal3c2,bar_cCGBPal3c3,
+ bar_cCGBPal4c0,bar_cCGBPal4c1,bar_cCGBPal4c2,bar_cCGBPal4c3,
+ bar_cCGBPal5c0,bar_cCGBPal5c1,bar_cCGBPal5c2,bar_cCGBPal5c3,
+ bar_cCGBPal6c0,bar_cCGBPal6c1,bar_cCGBPal6c2,bar_cCGBPal6c3,
+ bar_cCGBPal7c0,bar_cCGBPal7c1,bar_cCGBPal7c2,bar_cCGBPal7c3
+};
+
+const unsigned char bar_a[] =
+{
+ 7,7,4,4,4,6,6,6,2,2,2,5,5,5,1,1,1,3,3,3,
+ 7,7,4,4,4,6,6,6,2,2,2,5,5,5,1,1,1,3,3,3,
+ 7,7,4,4,4,6,6,6,2,2,2,5,5,5,1,1,1,3,3,3,
+ 7,7,4,4,4,6,6,6,2,2,2,5,5,5,1,1,1,3,3,3,
+ 7,7,4,4,4,6,6,6,2,2,2,5,5,5,1,1,1,3,3,3,
+ 7,7,4,4,4,6,6,6,2,2,2,5,5,5,1,1,1,3,3,3,
+ 7,7,4,4,4,6,6,6,2,2,2,5,5,5,1,1,1,3,3,3,
+ 7,7,4,4,4,6,6,6,2,2,2,5,5,5,1,1,1,3,3,3,
+ 7,7,4,4,4,6,6,6,2,2,2,5,5,5,1,1,1,3,3,3,
+ 7,7,4,4,4,6,6,6,2,2,2,5,5,5,1,1,1,3,3,3,
+ 7,7,4,4,4,6,6,6,2,2,2,5,5,5,1,1,1,3,3,3,
+ 7,7,4,4,4,6,6,6,2,2,2,5,5,5,1,1,1,3,3,3,
+ 7,7,4,4,4,6,6,6,2,2,2,5,5,5,1,1,1,3,3,3,
+ 7,7,4,4,4,6,6,6,2,2,2,5,5,5,1,1,1,3,3,3,
+ 3,3,0,0,0,5,5,5,0,0,0,6,6,6,0,0,0,7,7,7,
+ 3,3,3,3,0,0,0,0,5,5,5,5,0,0,0,0,0,0,0,0,
+ 3,3,3,3,0,0,0,0,5,5,5,5,0,0,0,0,0,0,0,0,
+ 3,3,3,3,0,0,0,0,5,5,5,5,0,0,0,0,0,0,0,0
+};
+
+int main(void)
+{
+ /* Transfer color palettes */
+ set_bkg_palette( 7, 1, &bar_p[0] );
+ set_bkg_palette( 6, 1, &bar_p[4] );
+ set_bkg_palette( 5, 1, &bar_p[8] );
+ set_bkg_palette( 4, 1, &bar_p[12] );
+ set_bkg_palette( 3, 1, &bar_p[16] );
+ set_bkg_palette( 2, 1, &bar_p[20] );
+ set_bkg_palette( 1, 1, &bar_p[24] );
+ set_bkg_palette( 0, 1, &bar_p[28] );
+
+ /* CHR code transfer */
+ set_bkg_data( 0x0, 32, bar_c );
+
+ /* Select VRAM bank 1 */
+ VBK_REG = 1;
+ /* Set attributes */
+ set_bkg_tiles( 0, 0, bar_mWidth, bar_mHeight, bar_a );
+
+ /* Select VRAM bank 0 */
+ VBK_REG = 0;
+ /* Set data */
+ set_bkg_tiles( 0, 0, bar_mWidth, bar_mHeight, bar_m );
+
+ SHOW_BKG;
+ enable_interrupts();
+ DISPLAY_ON;
+
+ return 0;
+}
diff --git a/gbdk/gbdk-lib/examples/ap/comm/Makefile b/gbdk/gbdk-lib/examples/ap/comm/Makefile
new file mode 100644
index 00000000..bb124324
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/comm/Makefile
@@ -0,0 +1,17 @@
+CC = ../../../bin/lcc -msm83:ap -Wl-j -Wm-yS
+
+BINS = comm.pocket
+
+all: $(BINS)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+# Compile and link single file in one pass
+%.pocket: %.c
+ $(CC) -o $@ $<
+
+clean:
+ rm -f *.o *.lst *.map *.pocket *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi
+
diff --git a/gbdk/gbdk-lib/examples/ap/comm/comm.c b/gbdk/gbdk-lib/examples/ap/comm/comm.c
new file mode 100644
index 00000000..f3928016
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/comm/comm.c
@@ -0,0 +1,90 @@
+#include <gb/gb.h>
+#include <stdint.h>
+#include <stdio.h>
+
+unsigned char str[] = "Hello World!";
+unsigned char buffer[32];
+
+void main(void)
+{
+ uint8_t i, n = 0;
+ unsigned char *s;
+
+ puts("Byte");
+ puts(" A : Send");
+ puts(" B : Receive");
+ puts("String");
+ puts(" START : Send");
+ puts(" SELECT : Receive");
+
+ CRITICAL {
+ add_SIO(nowait_int_handler); // disable waiting VRAM state before return
+ }
+ set_interrupts(SIO_IFLAG); // disable other interrupts. note: this disables sprite movement
+
+ while(1) {
+ i = waitpad(J_A | J_B | J_START | J_SELECT);
+ waitpadup();
+
+ if (i == J_A) {
+ /* Send 1 byte */
+ printf("Sending b... ");
+ _io_out = n++;
+ send_byte();
+ /* Wait for IO completion... */
+ while((_io_status == IO_SENDING) && (joypad() == 0));
+ if(_io_status == IO_IDLE)
+ printf("OK\n");
+ else
+ printf("#%d\n", _io_status);
+ } else if (i == J_B) {
+ /* Receive 1 byte */
+ printf("Receiving b... ");
+ receive_byte();
+ /* Wait for IO completion... */
+ while((_io_status == IO_RECEIVING) && (joypad() == 0));
+ if(_io_status == IO_IDLE)
+ printf("OK\n%d\n", _io_in);
+ else
+ printf("#%d\n", _io_status);
+ } else if (i == J_START) {
+ /* Send a string */
+ printf("Sending s... ");
+ s = str;
+ while(1) {
+ _io_out = *s;
+ do {
+ send_byte();
+ /* Wait for IO completion... */
+ while((_io_status == IO_SENDING) && (joypad() == 0));
+ } while((_io_status != IO_IDLE) && (joypad() == 0));
+ if(_io_status != IO_IDLE) {
+ printf("#%d\n", _io_status);
+ break;
+ }
+ if(*s == 0) break;
+ s++;
+ }
+ if(_io_status == IO_IDLE) printf("OK\n");
+ } else if (i == J_SELECT) {
+ /* Receive a string */
+ printf("Receiving s... ");
+ s = buffer;
+ while(1) {
+ receive_byte();
+ /* Wait for IO completion... */
+ while((_io_status == IO_RECEIVING) && (joypad() == 0));
+ if(_io_status != IO_IDLE) {
+ printf("#%d\n", _io_status);
+ break;
+ }
+ *s = _io_in;
+ if(*s == 0) break;
+ s++;
+ }
+ if(_io_status == IO_IDLE) printf("OK\n%s\n", buffer);
+ }
+ /* In case of user cancellation */
+ waitpadup();
+ }
+}
diff --git a/gbdk/gbdk-lib/examples/ap/crash/Makefile b/gbdk/gbdk-lib/examples/ap/crash/Makefile
new file mode 100644
index 00000000..99ed1165
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/crash/Makefile
@@ -0,0 +1,17 @@
+CC = ../../../bin/lcc -msm83:ap -Wl-j -Wm-yS
+
+BINS = crash.pocket
+
+all: $(BINS)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+# Compile and link single file in one pass
+%.pocket: %.c
+ $(CC) -o $@ $<
+
+clean:
+ rm -f *.o *.lst *.map *.pocket *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi
+
diff --git a/gbdk/gbdk-lib/examples/ap/crash/crash.c b/gbdk/gbdk-lib/examples/ap/crash/crash.c
new file mode 100644
index 00000000..995b6f69
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/crash/crash.c
@@ -0,0 +1,7 @@
+#include <gb/crash_handler.h>
+
+typedef void (*somefunc_t)(void);
+
+void main() {
+ ((somefunc_t)0x3000)(); // call something in the middle of nowhere
+} \ No newline at end of file
diff --git a/gbdk/gbdk-lib/examples/ap/dscan/Makefile b/gbdk/gbdk-lib/examples/ap/dscan/Makefile
new file mode 100644
index 00000000..0aa60048
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/dscan/Makefile
@@ -0,0 +1,24 @@
+CC = ../../../bin/lcc -msm83:ap -Wm-yc -Wl-j -Wm-yS
+
+BINS = dscan.pocket
+
+all: $(BINS)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+%.o: %.c
+ $(CC) -c -o $@ $<
+
+%.s: %.c
+ $(CC) -S -o $@ $<
+
+%.o: %.s
+ $(CC) -c -o $@ $<
+
+%.pocket: %.o
+ $(CC) -o $@ $<
+
+clean:
+ rm -f *.o *.lst *.map *.pocket *.ihx *.sym *.cdb *.adb *.asm
diff --git a/gbdk/gbdk-lib/examples/ap/dscan/bkg.c b/gbdk/gbdk-lib/examples/ap/dscan/bkg.c
new file mode 100644
index 00000000..97397a58
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/dscan/bkg.c
@@ -0,0 +1,238 @@
+/*
+
+ BKG.C
+
+ Tile Source File.
+
+ Info:
+ Form : All tiles as one unit.
+ Format : Gameboy 4 color.
+ Compression : None.
+ Counter : None.
+ Tile size : 8 x 8
+ Tiles : 0 to 95
+
+ Palette colors : Included.
+ SGB Palette : None.
+ CGB Palette : 1 Byte per entry.
+
+ Convert to metatiles : No.
+
+ This file was generated by GBTD v1.6
+
+*/
+
+/* CGBpalette entries. */
+const unsigned char bkgCGB[] =
+{
+ 0x00,0x00,0x00,0x00,0x01,0x02,0x03,0x04,
+ 0x01,0x02,0x03,0x04,0x01,0x02,0x03,0x04,
+ 0x05,0x06,0x05,0x06,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+};
+/* Start of tile array. */
+const unsigned char bkg[] =
+{
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,
+ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
+ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,
+ 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,
+ 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,
+ 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,
+ 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,
+ 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,
+ 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,
+ 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0x00,0xFF,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
+ 0x10,0x10,0x00,0x00,0x10,0x10,0x00,0x00,
+ 0x6C,0x6C,0x24,0x24,0x48,0x48,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x44,0x44,0xFE,0xFE,0x44,0x44,0x44,0x44,
+ 0x44,0x44,0xFE,0xFE,0x44,0x44,0x00,0x00,
+ 0x28,0x28,0x7E,0x7E,0xA8,0xA8,0x7C,0x7C,
+ 0x2A,0x2A,0xFC,0xFC,0x28,0x28,0x00,0x00,
+ 0x40,0x40,0xA4,0xA4,0x48,0x48,0x10,0x10,
+ 0x24,0x24,0x4A,0x4A,0x04,0x04,0x00,0x00,
+ 0x70,0x70,0x88,0x88,0x50,0x50,0x64,0x64,
+ 0x94,0x94,0x88,0x88,0x76,0x76,0x00,0x00,
+ 0x18,0x18,0x08,0x08,0x10,0x10,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x08,0x08,0x10,0x10,0x20,0x20,0x20,0x20,
+ 0x20,0x20,0x10,0x10,0x08,0x08,0x00,0x00,
+ 0x20,0x20,0x10,0x10,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x10,0x10,0x20,0x20,0x00,0x00,
+ 0x10,0x10,0x54,0x54,0x38,0x38,0x10,0x10,
+ 0x38,0x38,0x54,0x54,0x10,0x10,0x00,0x00,
+ 0x00,0x00,0x10,0x10,0x10,0x10,0x7C,0x7C,
+ 0x10,0x10,0x10,0x10,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x18,0x18,0x08,0x08,0x10,0x10,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x7C,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x08,0x08,0x00,0x00,
+ 0x00,0x00,0x04,0x04,0x08,0x08,0x10,0x10,
+ 0x20,0x20,0x40,0x40,0x00,0x00,0x00,0x00,
+ 0x7C,0x7C,0x82,0x82,0x82,0x82,0x82,0x82,
+ 0x82,0x82,0x82,0x82,0x7C,0x7C,0x00,0x00,
+ 0x10,0x10,0x30,0x30,0x10,0x10,0x10,0x10,
+ 0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00,
+ 0x7C,0x7C,0x82,0x82,0x82,0x82,0x0C,0x0C,
+ 0x30,0x30,0xC0,0xC0,0xFE,0xFE,0x00,0x00,
+ 0x7C,0x7C,0x82,0x82,0x02,0x02,0x1C,0x1C,
+ 0x02,0x02,0x82,0x82,0x7C,0x7C,0x00,0x00,
+ 0x0C,0x0C,0x14,0x14,0x24,0x24,0x44,0x44,
+ 0x84,0x84,0xFE,0xFE,0x04,0x04,0x00,0x00,
+ 0xFE,0xFE,0x80,0x80,0xFC,0xFC,0x02,0x02,
+ 0x02,0x02,0x82,0x82,0x7C,0x7C,0x00,0x00,
+ 0x7C,0x7C,0x82,0x82,0x80,0x80,0xFC,0xFC,
+ 0x82,0x82,0x82,0x82,0x7C,0x7C,0x00,0x00,
+ 0xFE,0xFE,0x82,0x82,0x04,0x04,0x08,0x08,
+ 0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00,
+ 0x7C,0x7C,0x82,0x82,0x82,0x82,0x7C,0x7C,
+ 0x82,0x82,0x82,0x82,0x7C,0x7C,0x00,0x00,
+ 0x7C,0x7C,0x82,0x82,0x82,0x82,0x7E,0x7E,
+ 0x02,0x02,0x82,0x82,0x7C,0x7C,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,
+ 0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,
+ 0x18,0x18,0x08,0x08,0x10,0x10,0x00,0x00,
+ 0x08,0x08,0x10,0x10,0x20,0x20,0x40,0x40,
+ 0x20,0x20,0x10,0x10,0x08,0x08,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x7C,0x7C,0x00,0x00,
+ 0x7C,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x40,0x40,0x20,0x20,0x10,0x10,0x08,0x08,
+ 0x10,0x10,0x20,0x20,0x40,0x40,0x00,0x00,
+ 0x7C,0x7C,0x82,0x82,0x82,0x82,0x0C,0x0C,
+ 0x10,0x10,0x00,0x00,0x10,0x10,0x00,0x00,
+ 0x7C,0x7C,0x82,0x82,0xBA,0xBA,0xAA,0xAA,
+ 0xBE,0xBE,0x80,0x80,0x7E,0x7E,0x00,0x00,
+ 0x38,0x38,0x44,0x44,0x82,0x82,0x82,0x82,
+ 0xFE,0xFE,0x82,0x82,0x82,0x82,0x00,0x00,
+ 0xFC,0xFC,0x82,0x82,0x82,0x82,0xFC,0xFC,
+ 0x82,0x82,0x82,0x82,0xFC,0xFC,0x00,0x00,
+ 0x3C,0x3C,0x42,0x42,0x80,0x80,0x80,0x80,
+ 0x80,0x80,0x42,0x42,0x3C,0x3C,0x00,0x00,
+ 0xF8,0xF8,0x84,0x84,0x82,0x82,0x82,0x82,
+ 0x82,0x82,0x84,0x84,0xF8,0xF8,0x00,0x00,
+ 0xFE,0xFE,0x80,0x80,0x80,0x80,0xFC,0xFC,
+ 0x80,0x80,0x80,0x80,0xFE,0xFE,0x00,0x00,
+ 0xFE,0xFE,0x80,0x80,0x80,0x80,0xFC,0xFC,
+ 0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,
+ 0x3C,0x3C,0x42,0x42,0x80,0x80,0x80,0x80,
+ 0x8E,0x8E,0x42,0x42,0x3E,0x3E,0x00,0x00,
+ 0x82,0x82,0x82,0x82,0x82,0x82,0xFE,0xFE,
+ 0x82,0x82,0x82,0x82,0x82,0x82,0x00,0x00,
+ 0x38,0x38,0x10,0x10,0x10,0x10,0x10,0x10,
+ 0x10,0x10,0x10,0x10,0x38,0x38,0x00,0x00,
+ 0x3C,0x3C,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x48,0x48,0x30,0x30,0x00,0x00,
+ 0x84,0x84,0x88,0x88,0x90,0x90,0xE0,0xE0,
+ 0x90,0x90,0x88,0x88,0x84,0x84,0x00,0x00,
+ 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,
+ 0x40,0x40,0x40,0x40,0x7E,0x7E,0x00,0x00,
+ 0xC6,0xC6,0xC6,0xC6,0xAA,0xAA,0xAA,0xAA,
+ 0x92,0x92,0x92,0x92,0x82,0x82,0x00,0x00,
+ 0xC2,0xC2,0xC2,0xC2,0xA2,0xA2,0x92,0x92,
+ 0x8A,0x8A,0x86,0x86,0x86,0x86,0x00,0x00,
+ 0x7C,0x7C,0x82,0x82,0x82,0x82,0x82,0x82,
+ 0x82,0x82,0x82,0x82,0x7C,0x7C,0x00,0x00,
+ 0xFC,0xFC,0x82,0x82,0x82,0x82,0x82,0x82,
+ 0xFC,0xFC,0x80,0x80,0x80,0x80,0x00,0x00,
+ 0x7C,0x7C,0x82,0x82,0x82,0x82,0x82,0x82,
+ 0xBA,0xBA,0xC4,0xC4,0x7A,0x7A,0x00,0x00,
+ 0xFC,0xFC,0x82,0x82,0x82,0x82,0x82,0x82,
+ 0xFC,0xFC,0x84,0x84,0x82,0x82,0x00,0x00,
+ 0x7C,0x7C,0x82,0x82,0x80,0x80,0x7C,0x7C,
+ 0x02,0x02,0x82,0x82,0x7C,0x7C,0x00,0x00,
+ 0xFE,0xFE,0x10,0x10,0x10,0x10,0x10,0x10,
+ 0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00,
+ 0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,
+ 0x82,0x82,0x82,0x82,0x7C,0x7C,0x00,0x00,
+ 0x82,0x82,0x82,0x82,0x44,0x44,0x44,0x44,
+ 0x28,0x28,0x28,0x28,0x10,0x10,0x00,0x00,
+ 0x82,0x82,0x82,0x82,0x82,0x82,0x92,0x92,
+ 0x92,0x92,0x92,0x92,0x6C,0x6C,0x00,0x00,
+ 0x82,0x82,0x44,0x44,0x28,0x28,0x10,0x10,
+ 0x28,0x28,0x44,0x44,0x82,0x82,0x00,0x00,
+ 0x82,0x82,0x44,0x44,0x28,0x28,0x10,0x10,
+ 0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00,
+ 0xFE,0xFE,0x02,0x02,0x0C,0x0C,0x10,0x10,
+ 0x60,0x60,0x80,0x80,0xFE,0xFE,0x00,0x00,
+ 0x38,0x38,0x20,0x20,0x20,0x20,0x20,0x20,
+ 0x20,0x20,0x20,0x20,0x38,0x38,0x00,0x00,
+ 0x00,0x00,0x40,0x40,0x20,0x20,0x10,0x10,
+ 0x08,0x08,0x04,0x04,0x00,0x00,0x00,0x00,
+ 0x38,0x38,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x38,0x38,0x00,0x00,
+ 0x7C,0x7C,0x82,0x82,0xBA,0xBA,0xA2,0xA2,
+ 0xBA,0xBA,0x82,0x82,0x7C,0x7C,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x7E,0x7E,0x00,0x00
+};
+
+/* End of BKG.C */
diff --git a/gbdk/gbdk-lib/examples/ap/dscan/bkg.gbr b/gbdk/gbdk-lib/examples/ap/dscan/bkg.gbr
new file mode 100644
index 00000000..754bfbd4
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/dscan/bkg.gbr
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/ap/dscan/bkg.h b/gbdk/gbdk-lib/examples/ap/dscan/bkg.h
new file mode 100644
index 00000000..9ad52052
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/dscan/bkg.h
@@ -0,0 +1,105 @@
+/*
+
+ BKG.H
+
+ Include File.
+
+ Info:
+ Form : All tiles as one unit.
+ Format : Gameboy 4 color.
+ Compression : None.
+ Counter : None.
+ Tile size : 8 x 8
+ Tiles : 0 to 95
+
+ Palette colors : Included.
+ SGB Palette : None.
+ CGB Palette : 1 Byte per entry.
+
+ Convert to metatiles : No.
+
+ This file was generated by GBTD v1.6
+
+*/
+
+
+/* Bank of tiles. */
+#define bkgBank 0
+
+/* Super Gameboy palette 0 */
+#define bkgSGBPal0c0 0
+#define bkgSGBPal0c1 0
+#define bkgSGBPal0c2 0
+#define bkgSGBPal0c3 0
+
+/* Super Gameboy palette 1 */
+#define bkgSGBPal1c0 4104
+#define bkgSGBPal1c1 6
+#define bkgSGBPal1c2 0
+#define bkgSGBPal1c3 0
+
+/* Super Gameboy palette 2 */
+#define bkgSGBPal2c0 4104
+#define bkgSGBPal2c1 6
+#define bkgSGBPal2c2 0
+#define bkgSGBPal2c3 0
+
+/* Super Gameboy palette 3 */
+#define bkgSGBPal3c0 4104
+#define bkgSGBPal3c1 6
+#define bkgSGBPal3c2 0
+#define bkgSGBPal3c3 0
+
+/* Gameboy Color palette 0 */
+#define bkgCGBPal0c0 32767
+#define bkgCGBPal0c1 25368
+#define bkgCGBPal0c2 16912
+#define bkgCGBPal0c3 0
+
+/* Gameboy Color palette 1 */
+#define bkgCGBPal1c0 31744
+#define bkgCGBPal1c1 25600
+#define bkgCGBPal1c2 15360
+#define bkgCGBPal1c3 31
+
+/* Gameboy Color palette 2 */
+#define bkgCGBPal2c0 29696
+#define bkgCGBPal2c1 21504
+#define bkgCGBPal2c2 13312
+#define bkgCGBPal2c3 31
+
+/* Gameboy Color palette 3 */
+#define bkgCGBPal3c0 27648
+#define bkgCGBPal3c1 19456
+#define bkgCGBPal3c2 11264
+#define bkgCGBPal3c3 31
+
+/* Gameboy Color palette 4 */
+#define bkgCGBPal4c0 23552
+#define bkgCGBPal4c1 17408
+#define bkgCGBPal4c2 9216
+#define bkgCGBPal4c3 31
+
+/* Gameboy Color palette 5 */
+#define bkgCGBPal5c0 16896
+#define bkgCGBPal5c1 25344
+#define bkgCGBPal5c2 0
+#define bkgCGBPal5c3 31
+
+/* Gameboy Color palette 6 */
+#define bkgCGBPal6c0 21120
+#define bkgCGBPal6c1 29568
+#define bkgCGBPal6c2 31744
+#define bkgCGBPal6c3 31
+
+/* Gameboy Color palette 7 */
+#define bkgCGBPal7c0 32767
+#define bkgCGBPal7c1 32736
+#define bkgCGBPal7c2 0
+#define bkgCGBPal7c3 31744
+/* CGBpalette entries. */
+extern const unsigned char bkgCGB[];
+/* Start of tile array. */
+extern const unsigned char bkg[];
+
+/* End of BKG.H */
diff --git a/gbdk/gbdk-lib/examples/ap/dscan/bkg_c.c b/gbdk/gbdk-lib/examples/ap/dscan/bkg_c.c
new file mode 100644
index 00000000..e02e2957
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/dscan/bkg_c.c
@@ -0,0 +1,62 @@
+/*
+
+ BKG_C.C
+
+ Map Source File.
+
+ Info:
+ Section :
+ Bank : 0
+ Map size : 20 x 18
+ Tile set : C:\SDK\gb-gb\2-0-15\examples\dscan\bkg.gbr
+ Plane count : 1 plane (8 bits)
+ Plane order : Tiles are continues
+
+ This file was generated by GBMB v0.8
+
+*/
+
+#define bkg_cWidth 20
+#define bkg_cHeight 18
+
+const unsigned char bkg_c[] =
+{
+ 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
+ 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,
+ 0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,
+ 0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,
+ 0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,
+ 0x02,0x02,0x02,0x02,0x02,0x04,0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04,0x04,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x04,0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04,0x04,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x05,0x05,0x05,0x05,0x05,
+ 0x05,0x05,0x05,0x05,0x05,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x07,0x07,0x07,0x07,0x07,
+ 0x07,0x07,0x07,0x07,0x07,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x09,0x09,0x09,0x09,0x09,
+ 0x09,0x09,0x09,0x09,0x09,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x0A,0x0A,0x0A,0x0A,0x0A,
+ 0x0A,0x0A,0x0A,0x0A,0x0A,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x0B,0x0B,0x0B,0x0B,0x0B,
+ 0x0B,0x0B,0x0B,0x0B,0x0B,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x0C,0x0C,0x0C,0x0C,0x0C,
+ 0x0C,0x0C,0x0C,0x0C,0x0C,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x0D,0x0D,0x0D,0x0D,0x0D,
+ 0x0D,0x0D,0x0D,0x0D,0x0D,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x0E,0x0E,0x0E,0x0E,0x0E,
+ 0x0E,0x0E,0x0E,0x0E,0x0E,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x0F,0x0F,0x0F,0x0F,0x0F,
+ 0x0F,0x0F,0x0F,0x0F,0x0F,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
+};
+
+/* End of BKG_C.C */
diff --git a/gbdk/gbdk-lib/examples/ap/dscan/bkg_c.gbm b/gbdk/gbdk-lib/examples/ap/dscan/bkg_c.gbm
new file mode 100644
index 00000000..aab831a5
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/dscan/bkg_c.gbm
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/ap/dscan/bkg_m.c b/gbdk/gbdk-lib/examples/ap/dscan/bkg_m.c
new file mode 100644
index 00000000..6eb9178c
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/dscan/bkg_m.c
@@ -0,0 +1,62 @@
+/*
+
+ BKG_M.C
+
+ Map Source File.
+
+ Info:
+ Section :
+ Bank : 0
+ Map size : 20 x 18
+ Tile set : C:\SDK\gb-gb\2-0-15\examples\dscan\bkg.gbr
+ Plane count : 1 plane (8 bits)
+ Plane order : Tiles are continues
+
+ This file was generated by GBMB v0.8
+
+*/
+
+#define bkg_mWidth 20
+#define bkg_mHeight 18
+
+const unsigned char bkg_m[] =
+{
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
+ 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
+ 0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x01,0x01,0x01,0x01,0x01,
+ 0x01,0x01,0x01,0x01,0x01,0x02,0x02,0x02,0x02,0x02,
+};
+
+/* End of BKG_M.C */
diff --git a/gbdk/gbdk-lib/examples/ap/dscan/bkg_m.gbm b/gbdk/gbdk-lib/examples/ap/dscan/bkg_m.gbm
new file mode 100644
index 00000000..a910fe48
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/dscan/bkg_m.gbm
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/ap/dscan/dscan.c b/gbdk/gbdk-lib/examples/ap/dscan/dscan.c
new file mode 100644
index 00000000..4a08fe9a
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/dscan/dscan.c
@@ -0,0 +1,751 @@
+/********************************************************************
+ * Color Deep Scan *
+ * by *
+ * Mr. N.U. of TeamKNOx *
+ ********************************************************************/
+
+#include <gb/gb.h>
+#include <gb/cgb.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <rand.h>
+
+/* bitmaps */
+#include "bkg.h"
+#include "bkg.c"
+#include "bkg_m.c"
+#include "bkg_c.c"
+#include "fore.h"
+#include "fore.c"
+
+/* ************************************************************ */
+
+const uint16_t bkg_p[] =
+{
+ bkgCGBPal0c0,bkgCGBPal0c1,bkgCGBPal0c2,bkgCGBPal0c3,
+ bkgCGBPal1c0,bkgCGBPal1c1,bkgCGBPal1c2,bkgCGBPal1c3,
+ bkgCGBPal2c0,bkgCGBPal2c1,bkgCGBPal2c2,bkgCGBPal2c3,
+ bkgCGBPal3c0,bkgCGBPal3c1,bkgCGBPal3c2,bkgCGBPal3c3,
+ bkgCGBPal4c0,bkgCGBPal4c1,bkgCGBPal4c2,bkgCGBPal4c3,
+ bkgCGBPal5c0,bkgCGBPal5c1,bkgCGBPal5c2,bkgCGBPal5c3,
+ bkgCGBPal6c0,bkgCGBPal6c1,bkgCGBPal6c2,bkgCGBPal6c3,
+ bkgCGBPal7c0,bkgCGBPal7c1,bkgCGBPal7c2,bkgCGBPal7c3
+};
+
+const uint16_t obj_p[] =
+{
+ foreCGBPal0c0,foreCGBPal0c1,foreCGBPal0c2,foreCGBPal0c3,
+ foreCGBPal1c0,foreCGBPal1c1,foreCGBPal1c2,foreCGBPal1c3,
+ foreCGBPal2c0,foreCGBPal2c1,foreCGBPal2c2,foreCGBPal2c3,
+ foreCGBPal3c0,foreCGBPal3c1,foreCGBPal3c2,foreCGBPal3c3,
+ foreCGBPal4c0,foreCGBPal4c1,foreCGBPal4c2,foreCGBPal4c3,
+ foreCGBPal5c0,foreCGBPal5c1,foreCGBPal5c2,foreCGBPal5c3,
+ foreCGBPal6c0,foreCGBPal6c1,foreCGBPal6c2,foreCGBPal6c3,
+ foreCGBPal7c0,foreCGBPal7c1,foreCGBPal7c2,foreCGBPal7c3
+};
+
+/* screen size */
+#define MIN_SX 5U /* min x (char) */
+#define MAX_SX (20U-MIN_SX) /* max x (char) */
+#define MIN_SY 5U /* min y (char) */
+#define MAX_SY (MIN_SY+13U) /* max y (char) */
+
+#define DEF_SP 30U /* sprite null char code */
+
+/* player */
+#define MIN_PX (MIN_SX*8U+8U) /* min x (dot) */
+#define MAX_PX (MAX_SX*8U-8U) /* max x (dot) */
+#define DEF_PX 80U /* ship x pos (dot) */
+#define DEF_PY (MIN_SY*8U) /* ship y pos (dot) */
+#define DEF_PC0 14U
+#define DEF_PC1 15U
+#define DEF_PF 8U
+
+/* bomb */
+#define MAX_TT 6U /* number */
+#define DEF_TS 2U /* sprite tile id */
+#define DEF_TC 2U /* sprite data id */
+#define DEF_TX (80U-6U) /* bomb x pos (dot) */
+#define DEF_TY (DEF_PY-14U) /* bomb y pos (dot) */
+#define MAX_TY (MAX_SY*8U) /* max y pos (dot) */
+
+/* enemy */
+#define MAX_ET 10U /* number */
+#define DEF_ES0 (DEF_TS+MAX_TT) /* sprite tile id */
+#define DEF_ES1 (DEF_ES0+1U)
+#define DEF_1EC0 32U
+#define DEF_1EC1 48U
+#define DEF_2EC0 64U
+#define DEF_2EC1 80U
+#define DEF_XEC0 96U /* sprite data(X) id */
+#define DEF_XEC1 112U /* sprite data(X) id */
+#define DEF_EY (DEF_PY+12U)
+#define DEF_EH 10U
+#define SUB_EX0 20U
+#define SUB_EX1 (SUB_EX0-8U)
+#define MIN_EX (SUB_EX0-16U)
+#define MAX_EX (SUB_EX0+180U)
+#define SPEED_EY (DEF_EY+DEF_EH*3U)
+#define DEF_BC1 4U
+#define DEF_BC2 5U
+
+/* kirai */
+#define MAX_KT 12U
+#define DEF_KS (DEF_ES0+MAX_ET*2U) /* sprite tile id */
+#define DEF_KC 4U /* sprite data id */
+#define DEF_KX 0U /* bomb x pos (default_dot) */
+#define DEF_KY 0U /* bomb y pos (default_dot) */
+#define MIN_KY (DEF_PY+1U) /* min y pos (dot) */
+
+unsigned char msg_tile[64];
+
+const unsigned char * const msg_1up = "1UP";
+const unsigned char * const msg_lv = "LV";
+
+const unsigned char * const msg_gover = "GAMEOVER";
+const unsigned char * const msg_pause = " PAUSE! ";
+const unsigned char * const msg_start = " ";
+
+uint8_t pf, px, pp, pl;
+uint16_t pw;
+uint16_t ps;
+uint8_t tf[MAX_TT];
+uint8_t tx[MAX_TT], ty[MAX_TT];
+uint8_t ef[MAX_ET], ex[MAX_ET], ey[MAX_ET];
+uint8_t kf[MAX_KT], kx[MAX_KT], ky[MAX_KT];
+uint8_t rnd_enemy, rnd_kirai;
+uint8_t k_right, k_left;
+
+void set_sprite_attrb( uint8_t nb, uint8_t tile )
+{
+ if(DEVICE_SUPPORTS_COLOR) {
+ set_sprite_prop( nb, tile );
+ }
+}
+
+
+void set_bkg_attr( uint8_t x, uint8_t y, uint8_t sx, uint8_t sy, unsigned char *d )
+{
+ uint8_t xx, yy;
+
+ VBK_REG = 1; /* select palette bank */
+ for( yy=0; yy<sy; yy++ ) {
+ for( xx=0; xx<sx; xx++ ) {
+ msg_tile[xx] = bkgCGB[(unsigned int)*d];
+ d++;
+ }
+ set_bkg_tiles( x, y+yy, sx, 1, msg_tile );
+ }
+ VBK_REG = 0; /* select data bank */
+}
+
+uint8_t make_rnd( uint8_t i )
+{
+ return( arand()%(i+1) );
+}
+
+void show_score( uint16_t s )
+{
+ uint16_t m;
+ uint8_t i, n, f;
+ unsigned char score[6];
+
+ f = 0; m = 10000;
+ for( i=0; i<5; i++ ) {
+ n = s/m; s = s%m; m = m/10;
+ if( (n==0)&&(f==0) ) {
+ score[i] = 0x20; /* ' ' */
+ } else {
+ f = 1;
+ score[i] = 0x30+n; /* '0' - '9' */
+ }
+ }
+ score[5] = 0x30; /* '0' */
+ set_bkg_tiles( 4, 0, 6, 1, score );
+}
+
+void set_level( uint8_t i )
+{
+ /* level */
+ if( i < 9 ) {
+ rnd_enemy = 100-(i*12); /* 1% - */
+ rnd_kirai = 50-(i*6); /* 2% - */
+ } else {
+ rnd_enemy = 0; /* 100 % */
+ rnd_kirai = 0; /* 100 % */
+ }
+}
+
+void show_level( uint8_t i )
+{
+ unsigned char level[2];
+
+ if( i < 9 ) {
+ level[0] = 0x31+i;
+ } else {
+ level[0] = 0x41+i-9;
+ }
+ set_bkg_tiles( 19, 0, 1, 1, level );
+ set_level( i );
+}
+
+void show_gover()
+{
+ set_bkg_tiles( 6, 9, 8, 1, (unsigned char *)msg_gover );
+ pf = DEF_PF;
+}
+
+void show_pause()
+{
+ set_bkg_tiles( 6, 9, 8, 1, (unsigned char *)msg_pause );
+}
+
+void hide_msg()
+{
+ set_bkg_tiles( 6, 9, 8, 1, (unsigned char *)msg_start );
+}
+
+void init_score()
+{
+ ps = 0;
+ show_score( ps );
+ pp = 0; pl = 0;
+ show_level( pl );
+}
+
+void init_screen()
+{
+ uint8_t n;
+
+ if(DEVICE_SUPPORTS_COLOR) {
+ /* Transfer color palette */
+ set_bkg_palette( 0, 1, &bkg_p[0] );
+ set_bkg_palette( 1, 1, &bkg_p[4] );
+ set_bkg_palette( 2, 1, &bkg_p[8] );
+ set_bkg_palette( 3, 1, &bkg_p[12] );
+ set_bkg_palette( 4, 1, &bkg_p[16] );
+ set_bkg_palette( 5, 1, &bkg_p[20] );
+ set_bkg_palette( 6, 1, &bkg_p[24] );
+ set_bkg_palette( 7, 1, &bkg_p[28] );
+ set_sprite_palette( 0, 1, &obj_p[0] );
+ set_sprite_palette( 1, 1, &obj_p[4] );
+ set_sprite_palette( 2, 1, &obj_p[8] );
+ set_sprite_palette( 3, 1, &obj_p[12] );
+ set_sprite_palette( 4, 1, &obj_p[16] );
+ set_sprite_palette( 5, 1, &obj_p[20] );
+ set_sprite_palette( 6, 1, &obj_p[24] );
+ set_sprite_palette( 7, 1, &obj_p[28] );
+
+ /* set attributes */
+ set_bkg_attr( 0, 0, 20, 18, bkg_c );
+ set_bkg_tiles( 0, 0, 20, 18, bkg_c );
+ } else {
+ set_bkg_tiles( 0, 0, 20, 18, bkg_m );
+ }
+
+ pw = 50;
+ set_bkg_data( 0, 96, bkg );
+ set_bkg_tiles( 0, 0, 3, 1, (unsigned char *)msg_1up );
+ set_bkg_tiles( 16, 0, 2, 1, (unsigned char *)msg_lv );
+ SHOW_BKG;
+ SPRITES_8x8;
+ set_sprite_data( 0, 128, fore );
+ SHOW_SPRITES;
+ for( n=0; n<40; n++ ) {
+ set_sprite_tile( n, DEF_SP );
+ move_sprite( n, 0, 0 );
+ }
+}
+
+void init_player()
+{
+ pf = 0; px = DEF_PX;
+ set_sprite_tile( 0, 0 );
+ set_sprite_attrb( 0, foreCGB[0] );
+ move_sprite( 0, px, DEF_PY );
+ set_sprite_tile( 1, 1 );
+ set_sprite_attrb( 1, foreCGB[1] );
+ move_sprite( 1, px+8, DEF_PY );
+}
+
+void init_tama()
+{
+ uint8_t i;
+
+ for( i=0; i<MAX_TT; i++ ) {
+ tf[i] = 0;
+ tx[i] = i*4+DEF_TX;
+ ty[i] = DEF_TY;
+ set_sprite_tile( i+DEF_TS, tf[i]+DEF_TC );
+ set_sprite_attrb( i+DEF_TS, foreCGB[tf[i]+DEF_TC] );
+ move_sprite( i+DEF_TS, tx[i], ty[i] );
+ }
+}
+
+void init_enemy()
+{
+ uint8_t i;
+
+ for( i=0; i<MAX_ET; i++ ) {
+ ef[i] = 0;
+ ex[i] = 0;
+ ey[i] = 0;
+ set_sprite_tile( i*2+DEF_ES0, DEF_SP );
+ set_sprite_tile( i*2+DEF_ES1, DEF_SP );
+ move_sprite( i*2+DEF_ES0, ex[i], ey[i] );
+ move_sprite( i*2+DEF_ES1, ex[i], ey[i] );
+ }
+}
+
+void init_kirai()
+{
+ uint8_t i;
+
+ for( i=0; i<MAX_KT; i++ ) {
+ kf[i] = 0;
+ kx[i] = DEF_KX;
+ ky[i] = DEF_KY;
+ set_sprite_tile( i+DEF_KS, DEF_SP );
+ move_sprite( i+DEF_KS, kx[i], ky[i] );
+ }
+}
+
+/* player */
+void player()
+{
+ uint8_t key;
+ uint8_t i;
+ uint16_t seed;
+
+ key = joypad();
+ /* pause */
+ if( key & J_START ) {
+ if( pf == DEF_PF ) {
+ /* Initialize the random number generator */
+ seed = DIV_REG;
+ waitpadup();
+ seed |= ((uint16_t)DIV_REG << 8);
+ initarand(seed);
+ hide_msg();
+ init_score();
+ init_player();
+ init_tama();
+ init_enemy();
+ init_kirai();
+ delay( 500 );
+ } else {
+ show_pause();
+ waitpadup();
+ key = joypad();
+ while( !(key & J_START) ) {
+ key = joypad();
+ if( key & J_DOWN ) {
+ if(pl > 0)
+ pl--;
+ show_level( pl );
+ waitpadup();
+ } else if( key & J_UP ) {
+ if(pl < 8)
+ pl++;
+ show_level( pl );
+ waitpadup();
+ } else if( key & J_LEFT ) {
+ while( joypad() & J_LEFT ) {
+ if(pw > 0)
+ pw--;
+ show_score( pw );
+ delay( 250 );
+ }
+ show_score( ps );
+ } else if( key & J_RIGHT ) {
+ while( joypad() & J_RIGHT ) {
+ if(pw < 99)
+ pw++;
+ show_score( pw );
+ delay( 250 );
+ }
+ show_score( ps );
+ } else if( key & J_SELECT ) {
+ i = k_right;
+ k_right = k_left;
+ k_left = i;
+ waitpadup();
+ }
+ }
+ waitpadup();
+ hide_msg();
+ delay( 500 );
+ }
+ return;
+ }
+
+ /* dead */
+ if( pf > 1 ) {
+ if( pf < DEF_PF ) {
+ set_sprite_tile( 0, pf*2+DEF_PC0 );
+ set_sprite_attrb( 0, foreCGB[pf*2+DEF_PC0] );
+ set_sprite_tile( 1, pf*2+DEF_PC1 );
+ set_sprite_attrb( 1, foreCGB[pf*2+DEF_PC1] );
+ pf++;
+ } else {
+ set_sprite_tile( 0, DEF_SP );
+ set_sprite_tile( 1, DEF_SP );
+ show_gover();
+ }
+ return;
+ }
+
+ /* move */
+ if( (key&J_LEFT)&&(px>MIN_PX) ) {
+ px--;
+ move_sprite( 0, px, DEF_PY ); move_sprite( 1, px+8, DEF_PY );
+ } else if( (key&J_RIGHT)&&(px<MAX_PX) ) {
+ px++;
+ move_sprite( 0, px, DEF_PY ); move_sprite( 1, px+8, DEF_PY );
+ }
+ /* shot */
+ if( key & k_left ) { /* change J_B to J_A */
+ if( pf == 0 ) {
+ pf = 1;
+ for( i=0; i<MAX_TT; i++ ) {
+ if( tf[i] == 0 ) {
+ tf[i] = 1; tx[i] = px-4; ty[i] = DEF_PY;
+ break;
+ }
+ }
+ }
+ } else if( key & k_right ) { /* change J_A to J_B */
+ if( pf == 0 ) {
+ pf = 1;
+ for( i=0; i<MAX_TT; i++ ) {
+ if( tf[i] == 0 ) {
+ tf[i] = 1; tx[i] = px+12; ty[i] = DEF_PY;
+ break;
+ }
+ }
+ }
+ } else if( pf == 1 ) {
+ pf = 0;
+ }
+}
+
+/* bombs */
+void bombs()
+{
+ uint8_t i;
+
+ for( i=0; i<MAX_TT; i++ ) {
+ if( tf[i] != 0 ) {
+ ty[i]++;
+ if( ty[i] > MAX_TY ) {
+ tf[i] = 0; tx[i] = i*4+DEF_TX; ty[i] = DEF_TY;
+ } else {
+ tf[i] = 3-tf[i];
+ }
+ set_sprite_tile( i+DEF_TS, tf[i]+DEF_TC );
+ set_sprite_attrb( i+DEF_TS, foreCGB[tf[i]+DEF_TC] );
+ move_sprite( i+DEF_TS, tx[i], ty[i] );
+ }
+ }
+}
+
+/* enemys */
+void enemys()
+{
+ uint8_t i, j;
+
+ for( i=0; i<MAX_ET; i++ ) {
+ if( ef[i] == 1 ) {
+ /* move right to left */
+ ex[i]--;
+ if( (pl>0)&&(ey[i]<SPEED_EY) ) ex[i]--;
+ if( ex[i] <= MIN_EX ) {
+ ef[i] = 0;
+ set_sprite_tile( i*2+DEF_ES0, DEF_SP );
+ set_sprite_tile( i*2+DEF_ES1, DEF_SP );
+ } else {
+ /* new */
+ if( ex[i]<MIN_SX*8+13 ) {
+ set_sprite_tile( i*2+DEF_ES0, DEF_1EC0 );
+ set_sprite_tile( i*2+DEF_ES1, DEF_1EC1 );
+ } else if( ex[i]<MIN_SX*8+20 ) {
+ set_sprite_tile( i*2+DEF_ES0, DEF_1EC0 );
+ set_sprite_tile( i*2+DEF_ES1, DEF_1EC1+(ex[i]-MIN_SX*8-13) );
+ } else if( ex[i]<MIN_SX*8+28 ) {
+ set_sprite_tile( i*2+DEF_ES0, DEF_1EC0+(ex[i]-MIN_SX*8-20) );
+ set_sprite_tile( i*2+DEF_ES1, DEF_1EC1+8 );
+ } else if( ex[i]<MAX_SX*8+13 ) {
+ set_sprite_tile( i*2+DEF_ES0, DEF_1EC0+8 );
+ set_sprite_tile( i*2+DEF_ES1, DEF_1EC1+8 );
+ } else if( ex[i]<MAX_SX*8+20 ) {
+ set_sprite_tile( i*2+DEF_ES0, DEF_1EC0+8 );
+ set_sprite_tile( i*2+DEF_ES1, DEF_1EC1+(ex[i]-MAX_SX*8-12)+7 );
+ } else if( ex[i]<MAX_SX*8+28 ) {
+ set_sprite_tile( i*2+DEF_ES0, DEF_1EC0+(ex[i]-MAX_SX*8-20)+8 );
+ set_sprite_tile( i*2+DEF_ES1, DEF_1EC1 );
+ } else {
+ set_sprite_tile( i*2+DEF_ES0, DEF_1EC0 );
+ set_sprite_tile( i*2+DEF_ES1, DEF_1EC1 );
+ }
+ /* new */
+ move_sprite( i*2+DEF_ES0, ex[i]-SUB_EX0, ey[i] );
+ move_sprite( i*2+DEF_ES1, ex[i]-SUB_EX1, ey[i] );
+ /* check bomb */
+ for( j=0; j<MAX_TT; j++ ) {
+ if( tf[j] != 0 ) {
+ if( (ty[j]>ey[i]-2)&&(ty[j]<ey[i]+2) ) {
+ if( (tx[j]>(ex[i]-SUB_EX0-5))&&(tx[j]<(ex[i]-SUB_EX1+5)) ) {
+ /* hit */
+ tf[j] = 0; tx[j] = j*4+DEF_TX; ty[j] = DEF_TY;
+ set_sprite_tile( j+DEF_TS, tf[j]+DEF_TC );
+ set_sprite_attrb( j+DEF_TS, foreCGB[tf[j]+DEF_TC] );
+ move_sprite( j+DEF_TS, tx[j], ty[j] );
+ ef[i] = 3;
+ set_sprite_tile( i*2+DEF_ES0, ef[i]*2+DEF_BC1 );
+ set_sprite_attrb( i*2+DEF_ES0, foreCGB[ef[i]*2+DEF_BC1] );
+ set_sprite_tile( i*2+DEF_ES1, ef[i]*2+DEF_BC2 );
+ set_sprite_attrb( i*2+DEF_ES1, foreCGB[ef[i]*2+DEF_BC2] );
+ }
+ }
+ }
+ }
+ if( make_rnd(rnd_kirai) == 0 ) {
+ if( ((ex[i]-SUB_EX0)>MIN_PX)&&((ex[i]-SUB_EX0)<MAX_PX) ) {
+ if( kf[i] == 0 ) {
+ /* shot kirai */
+ kf[i] = 1;
+ kx[i] = ex[i]-SUB_EX0+4;
+ ky[i] = ey[i]-4;
+ } else if( kf[i+1] == 0 ) {
+ /* shot kirai */
+ kf[i+1] = 1;
+ kx[i+1] = ex[i]-SUB_EX0+4;
+ ky[i+1] = ey[i]-4;
+ } else if( kf[i+2] == 0 ) {
+ /* shot kirai */
+ kf[i+2] = 1;
+ kx[i+2] = ex[i]-SUB_EX0+4;
+ ky[i+2] = ey[i]-4;
+ }
+ }
+ }
+ }
+ } else if( ef[i] == 2 ) {
+ /* move left to right */
+ ex[i]++;
+ if( (pl>0)&&(ey[i]<SPEED_EY) ) ex[i]++;
+ if( ex[i] >= MAX_EX ) {
+ ef[i] = 0;
+ set_sprite_tile( i*2+DEF_ES0, DEF_SP );
+ set_sprite_tile( i*2+DEF_ES1, DEF_SP );
+ } else {
+ /* new */
+ if( i==9 ) {
+ if( ex[i]<MIN_SX*8+13 ) {
+ set_sprite_tile( i*2+DEF_ES0, DEF_XEC0 );
+ set_sprite_tile( i*2+DEF_ES1, DEF_XEC1 );
+ } else if( ex[i]<MIN_SX*8+20 ) {
+ set_sprite_tile( i*2+DEF_ES0, DEF_XEC0 );
+ set_sprite_tile( i*2+DEF_ES1, DEF_XEC1+(ex[i]-MIN_SX*8-13) );
+ } else if( ex[i]<MIN_SX*8+28 ) {
+ set_sprite_tile( i*2+DEF_ES0, DEF_XEC0+(ex[i]-MIN_SX*8-20) );
+ set_sprite_tile( i*2+DEF_ES1, DEF_XEC1+8 );
+ } else if( ex[i]<MAX_SX*8+13 ) {
+ set_sprite_tile( i*2+DEF_ES0, DEF_XEC0+8 );
+ set_sprite_tile( i*2+DEF_ES1, DEF_XEC1+8 );
+ } else if( ex[i]<MAX_SX*8+20 ) {
+ set_sprite_tile( i*2+DEF_ES0, DEF_XEC0+8 );
+ set_sprite_tile( i*2+DEF_ES1, DEF_XEC1+(ex[i]-MAX_SX*8-12)+7 );
+ } else if( ex[i]<MAX_SX*8+28 ) {
+ set_sprite_tile( i*2+DEF_ES0, DEF_XEC0+(ex[i]-MAX_SX*8-20)+8 );
+ set_sprite_tile( i*2+DEF_ES1, DEF_XEC1 );
+ } else {
+ set_sprite_tile( i*2+DEF_ES0, DEF_XEC0 );
+ set_sprite_tile( i*2+DEF_ES1, DEF_XEC1 );
+ }
+ } else {
+ if( ex[i]<MIN_SX*8+13 ) {
+ set_sprite_tile( i*2+DEF_ES0, DEF_2EC0 );
+ set_sprite_tile( i*2+DEF_ES1, DEF_2EC1 );
+ } else if( ex[i]<MIN_SX*8+20 ) {
+ set_sprite_tile( i*2+DEF_ES0, DEF_2EC0 );
+ set_sprite_tile( i*2+DEF_ES1, DEF_2EC1+(ex[i]-MIN_SX*8-13) );
+ } else if( ex[i]<MIN_SX*8+28 ) {
+ set_sprite_tile( i*2+DEF_ES0, DEF_2EC0+(ex[i]-MIN_SX*8-20) );
+ set_sprite_tile( i*2+DEF_ES1, DEF_2EC1+8 );
+ } else if( ex[i]<MAX_SX*8+13 ) {
+ set_sprite_tile( i*2+DEF_ES0, DEF_2EC0+8 );
+ set_sprite_tile( i*2+DEF_ES1, DEF_2EC1+8 );
+ } else if( ex[i]<MAX_SX*8+20 ) {
+ set_sprite_tile( i*2+DEF_ES0, DEF_2EC0+8 );
+ set_sprite_tile( i*2+DEF_ES1, DEF_2EC1+(ex[i]-MAX_SX*8-12)+7 );
+ } else if( ex[i]<MAX_SX*8+28 ) {
+ set_sprite_tile( i*2+DEF_ES0, DEF_2EC0+(ex[i]-MAX_SX*8-20)+8 );
+ set_sprite_tile( i*2+DEF_ES1, DEF_2EC1 );
+ } else {
+ set_sprite_tile( i*2+DEF_ES0, DEF_2EC0 );
+ set_sprite_tile( i*2+DEF_ES1, DEF_2EC1 );
+ }
+ }
+ /* new */
+ move_sprite( i*2+DEF_ES0, ex[i]-SUB_EX0, ey[i] );
+ move_sprite( i*2+DEF_ES1, ex[i]-SUB_EX1, ey[i] );
+ /* check bomb */
+ for( j=0; j<MAX_TT; j++ ) {
+ if( tf[j] != 0 ) {
+ if( (ty[j]>ey[i]-2)&&(ty[j]<ey[i]+2) ) {
+ if( (tx[j]>(ex[i]-SUB_EX0-5))&&(tx[j]<(ex[i]-SUB_EX1+5)) ) {
+ /* hit */
+ tf[j] = 0; tx[j] = j*4+DEF_TX; ty[j] = DEF_TY;
+ set_sprite_tile( j+DEF_TS, tf[j]+DEF_TC );
+ set_sprite_attrb( j+DEF_TS, foreCGB[tf[j]+DEF_TC] );
+ move_sprite( j+DEF_TS, tx[j], ty[j] );
+ ef[i] = 3;
+ set_sprite_tile( i*2+DEF_ES0, ef[i]*2+DEF_BC1 );
+ set_sprite_attrb( i*2+DEF_ES0, foreCGB[ef[i]*2+DEF_BC1] );
+ set_sprite_tile( i*2+DEF_ES1, ef[i]*2+DEF_BC2 );
+ set_sprite_attrb( i*2+DEF_ES1, foreCGB[ef[i]*2+DEF_BC2] );
+ }
+ }
+ }
+ }
+ if( make_rnd(rnd_kirai) == 0 ) {
+ if( ((ex[i]-SUB_EX0)>MIN_PX)&&((ex[i]-SUB_EX0)<MAX_PX) ) {
+ if( kf[i] == 0 ) {
+ /* shot kirai */
+ kf[i] = 1;
+ kx[i] = ex[i]-SUB_EX0+4;
+ ky[i] = ey[i]-4;
+ } else if( kf[i+1] == 0 ) {
+ /* shot kirai */
+ kf[i+1] = 1;
+ kx[i+1] = ex[i]-SUB_EX0+4;
+ ky[i+1] = ey[i]-4;
+ } else if( kf[i+2] == 0 ) {
+ /* shot kirai */
+ kf[i+2] = 1;
+ kx[i+2] = ex[i]-SUB_EX0+4;
+ ky[i+2] = ey[i]-4;
+ }
+ }
+ }
+ }
+ } else if( ef[i] >= 3 ) {
+ if( ef[i] > 4 ) {
+ ef[i] = 0;
+ set_sprite_tile( i*2+DEF_ES0, DEF_SP );
+ set_sprite_tile( i*2+DEF_ES1, DEF_SP );
+ if( i == 9 ) {
+ ps += 100; show_score( ps ); pp++;
+ set_level( pl-1 );
+ } else {
+ ps += (i+1); show_score( ps ); pp++;
+ }
+ } else {
+ set_sprite_tile( i*2+DEF_ES0, ef[i]*2+DEF_BC1 );
+ set_sprite_attrb( i*2+DEF_ES0, foreCGB[ef[i]*2+DEF_BC1] );
+ set_sprite_tile( i*2+DEF_ES1, ef[i]*2+DEF_BC2 );
+ set_sprite_attrb( i*2+DEF_ES1, foreCGB[ef[i]*2+DEF_BC2] );
+ ef[i]++;
+ }
+ } else if( i == 9 ) {
+ if( pp > 20 ) {
+ pp = 0;
+ pl++; show_level( pl );
+ /* X */
+ ey[i] = i*DEF_EH+DEF_EY;
+ ef[i] = i%2+1;
+ ex[i] = MIN_EX;
+ set_sprite_tile( i*2+DEF_ES0, DEF_XEC0 );
+ set_sprite_attrb( i*2+DEF_ES0, foreCGB[DEF_XEC0] );
+ set_sprite_tile( i*2+DEF_ES1, DEF_XEC1 );
+ set_sprite_attrb( i*2+DEF_ES1, foreCGB[DEF_XEC1] );
+ move_sprite( i*2+DEF_ES0, ex[i]-SUB_EX0, ey[i] );
+ move_sprite( i*2+DEF_ES1, ex[i]-SUB_EX1, ey[i] );
+ }
+ } else if( make_rnd(rnd_enemy) == 0 ) {
+ if( !((pl<4)&&(i==0)) ) {
+ /* create */
+ ey[i] = i*DEF_EH+DEF_EY;
+ ef[i] = i%2+1;
+ if( ef[i] == 1 ) {
+ ex[i] = MAX_EX;
+ set_sprite_tile( i*2+DEF_ES0, DEF_1EC0 );
+ set_sprite_attrb( i*2+DEF_ES0, foreCGB[DEF_1EC0] );
+ set_sprite_tile( i*2+DEF_ES1, DEF_1EC1 );
+ set_sprite_attrb( i*2+DEF_ES1, foreCGB[DEF_1EC1] );
+ } else {
+ ex[i] = MIN_EX;
+ set_sprite_tile( i*2+DEF_ES0, DEF_2EC0 );
+ set_sprite_attrb( i*2+DEF_ES0, foreCGB[DEF_2EC0] );
+ set_sprite_tile( i*2+DEF_ES1, DEF_2EC1 );
+ set_sprite_attrb( i*2+DEF_ES1, foreCGB[DEF_2EC1] );
+ }
+ move_sprite( i*2+DEF_ES0, ex[i]-SUB_EX0, ey[i] );
+ move_sprite( i*2+DEF_ES1, ex[i]-SUB_EX1, ey[i] );
+ }
+ }
+ }
+}
+
+/* kirai */
+void kirai()
+{
+ uint8_t i;
+
+ for( i=0; i<MAX_KT; i++ ) {
+ if( kf[i] != 0 ) {
+ ky[i]--;
+ if( kf[i] >=3 ) {
+ kf[i]++;
+ if( (kx[i]>(px-5))&&(kx[i]<(px+12)) ) {
+ if( pf < 2 ) {
+ /* out!! */
+ pf = 2;
+ }
+ }
+ if( kf[i] >= 6 ) {
+ kf[i] = 0; kx[i] = DEF_KX; ky[i] = DEF_KY;
+ }
+ } else if( ky[i] <= MIN_KY ) {
+ kf[i] = 3;
+ } else {
+ kf[i] = 3-kf[i];
+ }
+ set_sprite_tile( i+DEF_KS, kf[i]+DEF_KC );
+ set_sprite_attrb( i+DEF_KS, foreCGB[kf[i]+DEF_KC] );
+ move_sprite( i+DEF_KS, kx[i], ky[i] );
+ }
+ }
+}
+
+/*--------------------------------------------------------------------------*
+ | main program |
+ *--------------------------------------------------------------------------*/
+void main()
+{
+ disable_interrupts();
+ DISPLAY_OFF;
+
+ initarand(((uint16_t)DIV_REG << 8));
+
+ init_screen();
+ init_score();
+ init_player();
+ init_tama();
+ init_enemy();
+ init_kirai();
+ show_gover();
+ k_right = J_A;
+ k_left = J_B;
+ DISPLAY_ON;
+ enable_interrupts();
+
+ while(1) {
+ delay( pw );
+ player();
+ bombs();
+ enemys();
+ kirai();
+ }
+}
diff --git a/gbdk/gbdk-lib/examples/ap/dscan/fore.c b/gbdk/gbdk-lib/examples/ap/dscan/fore.c
new file mode 100644
index 00000000..24ac988d
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/dscan/fore.c
@@ -0,0 +1,306 @@
+/*
+
+ FORE.C
+
+ Tile Source File.
+
+ Info:
+ Form : All tiles as one unit.
+ Format : Gameboy 4 color.
+ Compression : None.
+ Counter : None.
+ Tile size : 8 x 8
+ Tiles : 0 to 127
+
+ Palette colors : Included.
+ SGB Palette : None.
+ CGB Palette : 1 Byte per entry.
+
+ Convert to metatiles : No.
+
+ This file was generated by GBTD v1.6
+
+*/
+
+/* CGBpalette entries. */
+const unsigned char foreCGB[] =
+{
+ 0x01,0x01,0x02,0x02,0x02,0x02,0x02,0x05,
+ 0x05,0x05,0x01,0x01,0x01,0x01,0x01,0x01,
+ 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
+ 0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,
+ 0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
+ 0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04
+};
+/* Start of tile array. */
+const unsigned char fore[] =
+{
+ 0x00,0x00,0x01,0x01,0x01,0x01,0x03,0x03,
+ 0x7F,0x7F,0x3F,0x3F,0x1F,0x1F,0x00,0x00,
+ 0x00,0x00,0x80,0x80,0x80,0x80,0xC0,0xC0,
+ 0xFE,0xFE,0xFC,0xFC,0xF8,0xF8,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x18,0x18,0x18,0x18,
+ 0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x10,0x30,0x38,
+ 0x0C,0x1C,0x00,0x08,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x08,0x0C,0x1C,
+ 0x30,0x38,0x00,0x10,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x04,0x04,0x08,0x08,0x14,0x14,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x10,0x10,0x08,0x08,0x14,0x14,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x08,0x08,0x14,0x1C,0x1C,0x14,0x00,0x00,
+ 0x08,0x08,0x08,0x08,0x41,0x41,0x2A,0x2A,
+ 0x2A,0x3E,0x14,0x1C,0x1C,0x14,0x08,0x00,
+ 0x00,0x00,0x00,0x00,0x08,0x08,0x00,0x00,
+ 0x41,0x41,0x00,0x00,0x1C,0x1C,0x22,0x3E,
+ 0x00,0x00,0x08,0x00,0x04,0x00,0x11,0x00,
+ 0x11,0x00,0x04,0x00,0x08,0x00,0x00,0x00,
+ 0x00,0x00,0x10,0x00,0x20,0x00,0x88,0x00,
+ 0x88,0x00,0x20,0x00,0x10,0x00,0x00,0x00,
+ 0x10,0x00,0x08,0x00,0x21,0x00,0x02,0x00,
+ 0x02,0x00,0x21,0x00,0x08,0x00,0x10,0x00,
+ 0x08,0x00,0x10,0x00,0x84,0x00,0x40,0x00,
+ 0x40,0x00,0x84,0x00,0x10,0x00,0x08,0x00,
+ 0x10,0x00,0x01,0x00,0x40,0x00,0x04,0x00,
+ 0x04,0x00,0x40,0x00,0x01,0x00,0x10,0x00,
+ 0x08,0x00,0x80,0x00,0x02,0x00,0x20,0x00,
+ 0x20,0x00,0x02,0x00,0x80,0x00,0x08,0x00,
+ 0x00,0x10,0x01,0x0B,0x01,0x3E,0x64,0x7B,
+ 0x73,0x7C,0x3F,0x38,0x1F,0x1C,0x00,0x00,
+ 0x00,0x08,0x80,0xD0,0x80,0x7C,0x26,0xDE,
+ 0xCE,0x3E,0xFC,0x1C,0xF8,0x38,0x00,0x00,
+ 0x00,0x22,0x05,0x93,0x01,0x7E,0x5E,0x61,
+ 0x1F,0x70,0x2F,0xB0,0x1F,0x30,0x00,0x00,
+ 0x00,0x44,0xA0,0xC9,0x80,0x7E,0x7A,0x86,
+ 0xF8,0x0E,0xF4,0x0D,0xF8,0x0C,0x00,0x00,
+ 0x00,0x21,0x05,0x90,0x06,0x78,0x6A,0x76,
+ 0x10,0x7F,0x20,0xBF,0x18,0x37,0x00,0x00,
+ 0x00,0x84,0xA0,0x09,0x60,0x1E,0x56,0x6E,
+ 0x08,0xFE,0x04,0xFD,0x18,0xEC,0x00,0x00,
+ 0x00,0x00,0x60,0x60,0x70,0x74,0xFE,0xFE,
+ 0xDC,0xFE,0x7E,0x7E,0x37,0x3F,0x00,0x00,
+ 0x00,0x00,0x06,0x06,0x0E,0x2E,0x7F,0x7F,
+ 0x3B,0x7F,0x7E,0x7E,0xEC,0xFC,0x00,0x00,
+ 0x00,0x00,0x00,0x04,0x40,0x40,0x40,0x62,
+ 0xF0,0xF0,0xF4,0xFC,0x7E,0x7E,0x00,0x00,
+ 0x00,0x00,0x00,0x20,0x02,0x02,0x02,0x46,
+ 0x0F,0x0F,0x2F,0x3F,0x7E,0x7E,0x00,0x00,
+ 0x00,0x04,0x00,0x00,0x00,0x20,0x00,0x00,
+ 0x40,0x48,0x40,0x40,0xF0,0xF0,0x00,0x00,
+ 0x00,0x20,0x00,0x00,0x00,0x04,0x00,0x00,
+ 0x02,0x12,0x02,0x02,0x0F,0x0F,0x00,0x00,
+ 0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x40,0x40,0x00,0x00,
+ 0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x02,0x02,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
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0x70,0x70,0x70,0x30,0x3F,0x00,0x00,
+ 0x00,0x00,0x00,0x02,0x00,0x0D,0x20,0x30,
+ 0x60,0x60,0x60,0x60,0x20,0x3F,0x00,0x00,
+ 0x00,0x00,0x00,0x02,0x00,0x0D,0x00,0x30,
+ 0x40,0x40,0x40,0x40,0x00,0x3F,0x00,0x00,
+ 0x00,0x00,0x00,0x02,0x00,0x0D,0x00,0x30,
+ 0x00,0x40,0x00,0x40,0x00,0x3F,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x72,
+ 0x00,0x0E,0x00,0x12,0x00,0xE0,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x80,0x02,0x72,
+ 0x02,0x0E,0x02,0x12,0x00,0xE0,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x80,0x02,0x72,
+ 0x06,0x0E,0x02,0x12,0x00,0xE0,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x80,0x02,0x72,
+ 0x0E,0x0E,0x02,0x12,0x00,0xE0,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x80,0x12,0x72,
+ 0x1E,0x1E,0x12,0x12,0x00,0xE0,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x80,0x32,0x72,
+ 0x3E,0x3E,0x32,0x32,0x20,0xE0,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x80,0x72,0x72,
+ 0x7E,0x7E,0x72,0x72,0x60,0xE0,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x80,0x80,0xF2,0xF2,
+ 0xFE,0xFE,0xF2,0xF2,0xE0,0xE0,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x80,0x80,0xF2,0xF2,
+ 0xFE,0xFE,0xF2,0xF2,0xE0,0xE0,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x80,0x80,0xF0,0xF2,
+ 0xFC,0xFE,0xF0,0xF2,0xE0,0xE0,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x80,0x80,0xF0,0xF2,
+ 0xF8,0xFE,0xF0,0xF2,0xE0,0xE0,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x80,0x80,0xF0,0xF2,
+ 0xF0,0xFE,0xF0,0xF2,0xE0,0xE0,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x80,0x80,0xE0,0xF2,
+ 0xE0,0xEE,0xE0,0xF2,0xE0,0xE0,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x80,0x80,0xC0,0xF2,
+ 0xC0,0xCE,0xC0,0xD2,0xC0,0xE0,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x80,0x80,0x80,0xF2,
+ 0x80,0x8E,0x80,0x92,0x80,0xE0,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x72,
+ 0x00,0x0E,0x00,0x12,0x00,0xE0,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x4E,
+ 0x00,0x70,0x00,0x48,0x00,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x4F,
+ 0x01,0x71,0x01,0x49,0x01,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x01,0x01,0x03,0x4F,
+ 0x03,0x73,0x03,0x4B,0x03,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x01,0x01,0x07,0x4F,
+ 0x07,0x77,0x07,0x4F,0x07,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x01,0x01,0x0F,0x4F,
+ 0x0F,0x7F,0x0F,0x4F,0x07,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x01,0x01,0x0F,0x4F,
+ 0x1F,0x7F,0x0F,0x4F,0x07,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x01,0x01,0x0F,0x4F,
+ 0x3F,0x7F,0x0F,0x4F,0x07,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x01,0x01,0x4F,0x4F,
+ 0x7F,0x7F,0x4F,0x4F,0x07,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x01,0x01,0x4F,0x4F,
+ 0x7F,0x7F,0x4F,0x4F,0x07,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x01,0x4E,0x4E,
+ 0x7E,0x7E,0x4E,0x4E,0x06,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x01,0x4C,0x4E,
+ 0x7C,0x7C,0x4C,0x4C,0x04,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x01,0x48,0x4E,
+ 0x78,0x78,0x48,0x48,0x00,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x01,0x40,0x4E,
+ 0x70,0x70,0x40,0x48,0x00,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x01,0x40,0x4E,
+ 0x60,0x70,0x40,0x48,0x00,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x01,0x40,0x4E,
+ 0x40,0x70,0x40,0x48,0x00,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x4E,
+ 0x00,0x70,0x00,0x48,0x00,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x40,0x00,0xB0,0x00,0x0C,
+ 0x00,0x02,0x00,0x02,0x00,0xFC,0x00,0x00,
+ 0x00,0x00,0x00,0x40,0x00,0xB0,0x00,0x0C,
+ 0x02,0x02,0x02,0x02,0x00,0xFC,0x00,0x00,
+ 0x00,0x00,0x00,0x40,0x00,0xB0,0x04,0x0C,
+ 0x06,0x06,0x06,0x06,0x04,0xFC,0x00,0x00,
+ 0x00,0x00,0x00,0x40,0x00,0xB0,0x0C,0x0C,
+ 0x0E,0x0E,0x0E,0x0E,0x0C,0xFC,0x00,0x00,
+ 0x00,0x00,0x00,0x40,0x10,0xB0,0x1C,0x1C,
+ 0x1E,0x1E,0x1E,0x1E,0x1C,0xFC,0x00,0x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0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x01,0x01,0x03,0x03,
+ 0x03,0x03,0x03,0x03,0x03,0x03,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x01,0x01,0x07,0x07,
+ 0x07,0x07,0x07,0x07,0x07,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x01,0x01,0x0F,0x0F,
+ 0x0F,0x0F,0x0F,0x0F,0x07,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x01,0x01,0x0F,0x0F,
+ 0x1F,0x1F,0x0F,0x0F,0x07,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x01,0x01,0x0F,0x0F,
+ 0x3F,0x3F,0x0F,0x0F,0x07,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x01,0x01,0x4F,0x4F,
+ 0x7F,0x7F,0x4F,0x4F,0x07,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x01,0x01,0x4F,0x4F,
+ 0x7F,0x7F,0x4F,0x4F,0x07,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x4E,0x4E,
+ 0x7E,0x7E,0x4E,0x4E,0x06,0x06,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x4C,0x4C,
+ 0x7C,0x7C,0x4C,0x4C,0x04,0x04,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x48,0x48,
+ 0x78,0x78,0x48,0x48,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x40,
+ 0x70,0x70,0x40,0x40,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x40,
+ 0x60,0x60,0x40,0x40,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x40,
+ 0x40,0x40,0x40,0x40,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+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0xA0,0xE0,0x40,0xE0,0xE0,0x00,0x00,
+ 0x00,0x00,0x40,0x40,0xC0,0xC0,0xC0,0x40,
+ 0xC0,0x80,0xC0,0x40,0xC0,0xC0,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x00,
+ 0x80,0x80,0x80,0x00,0x80,0x80,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+};
+
+/* End of FORE.C */
diff --git a/gbdk/gbdk-lib/examples/ap/dscan/fore.gbr b/gbdk/gbdk-lib/examples/ap/dscan/fore.gbr
new file mode 100644
index 00000000..4d905c7a
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/dscan/fore.gbr
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/ap/dscan/fore.h b/gbdk/gbdk-lib/examples/ap/dscan/fore.h
new file mode 100644
index 00000000..3c73215b
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/dscan/fore.h
@@ -0,0 +1,105 @@
+/*
+
+ FORE.H
+
+ Include File.
+
+ Info:
+ Form : All tiles as one unit.
+ Format : Gameboy 4 color.
+ Compression : None.
+ Counter : None.
+ Tile size : 8 x 8
+ Tiles : 0 to 127
+
+ Palette colors : Included.
+ SGB Palette : None.
+ CGB Palette : 1 Byte per entry.
+
+ Convert to metatiles : No.
+
+ This file was generated by GBTD v1.6
+
+*/
+
+
+/* Bank of tiles. */
+#define foreBank 0
+
+/* Super Gameboy palette 0 */
+#define foreSGBPal0c0 0
+#define foreSGBPal0c1 0
+#define foreSGBPal0c2 0
+#define foreSGBPal0c3 18
+
+/* Super Gameboy palette 1 */
+#define foreSGBPal1c0 6108
+#define foreSGBPal1c1 8935
+#define foreSGBPal1c2 6596
+#define foreSGBPal1c3 6368
+
+/* Super Gameboy palette 2 */
+#define foreSGBPal2c0 6108
+#define foreSGBPal2c1 8935
+#define foreSGBPal2c2 6596
+#define foreSGBPal2c3 6368
+
+/* Super Gameboy palette 3 */
+#define foreSGBPal3c0 6108
+#define foreSGBPal3c1 8935
+#define foreSGBPal3c2 6596
+#define foreSGBPal3c3 6368
+
+/* Gameboy Color palette 0 */
+#define foreCGBPal0c0 32767
+#define foreCGBPal0c1 25368
+#define foreCGBPal0c2 19026
+#define foreCGBPal0c3 0
+
+/* Gameboy Color palette 1 */
+#define foreCGBPal1c0 32344
+#define foreCGBPal1c1 31
+#define foreCGBPal1c2 0
+#define foreCGBPal1c3 32767
+
+/* Gameboy Color palette 2 */
+#define foreCGBPal2c0 32344
+#define foreCGBPal2c1 31
+#define foreCGBPal2c2 25368
+#define foreCGBPal2c3 32767
+
+/* Gameboy Color palette 3 */
+#define foreCGBPal3c0 32344
+#define foreCGBPal3c1 32767
+#define foreCGBPal3c2 992
+#define foreCGBPal3c3 1023
+
+/* Gameboy Color palette 4 */
+#define foreCGBPal4c0 32344
+#define foreCGBPal4c1 32767
+#define foreCGBPal4c2 31744
+#define foreCGBPal4c3 31
+
+/* Gameboy Color palette 5 */
+#define foreCGBPal5c0 32344
+#define foreCGBPal5c1 31
+#define foreCGBPal5c2 0
+#define foreCGBPal5c3 31744
+
+/* Gameboy Color palette 6 */
+#define foreCGBPal6c0 32767
+#define foreCGBPal6c1 25368
+#define foreCGBPal6c2 19026
+#define foreCGBPal6c3 0
+
+/* Gameboy Color palette 7 */
+#define foreCGBPal7c0 32767
+#define foreCGBPal7c1 25368
+#define foreCGBPal7c2 19026
+#define foreCGBPal7c3 0
+/* CGBpalette entries. */
+extern const unsigned char foreCGB[];
+/* Start of tile array. */
+extern const unsigned char fore[];
+
+/* End of FORE.H */
diff --git a/gbdk/gbdk-lib/examples/ap/emu_debug/Makefile b/gbdk/gbdk-lib/examples/ap/emu_debug/Makefile
new file mode 100644
index 00000000..960c2025
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/emu_debug/Makefile
@@ -0,0 +1,17 @@
+CC = ../../../bin/lcc -msm83:ap -Wl-j -Wm-yS -Wm-yc
+
+BINS = emu_debug.pocket
+
+all: $(BINS)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+# Compile and link single file in one pass
+%.pocket: %.c
+ $(CC) -o $@ $<
+
+clean:
+ rm -f *.o *.lst *.map *.pocket *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi
+
diff --git a/gbdk/gbdk-lib/examples/ap/emu_debug/emu_debug.c b/gbdk/gbdk-lib/examples/ap/emu_debug/emu_debug.c
new file mode 100644
index 00000000..ccb5cfbb
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/emu_debug/emu_debug.c
@@ -0,0 +1,147 @@
+#include <gb/gb.h>
+#include <stdint.h>
+#include <stdio.h> // Just for printf()
+#include <gb/cgb.h> // Just for the cpu_fast()/slow() calls in CGB 2x example
+
+#include <gb/emu_debug.h> // Use this include to add the Emu debug functions
+
+
+// This example shows how to use support for profiling
+// and logging to the debug window in the emulator (BGB or Emulicious).
+//
+// 1. Build this ROM (emu_debug.gb) then load it in the emulator (BGB or Emulicious)
+// 2. Open the internal debugger by pressing the "ESC" or "F1" key
+// 3. From the debugger menu choose "debug messages" to open the debug messages window
+// 4. Reset the gameboy (you may need to press F9 in the debugger to resume running)
+// 5. The debug window will show the debug messages
+//
+// See the BGB Manual for more information
+// ("expressions, breakpoint conditions, and debug messages")
+// https://bgb.bircd.org/manual.html#expressions
+
+int main(void)
+{
+ int c;
+
+ SHOW_BKG;
+ DISPLAY_ON;
+ enable_interrupts();
+
+ // Display a message on the GameBoy's screen
+ printf("Message to the \nGameBoy screen\n");
+
+ // Log a message to the Emulator debug message window
+ EMU_MESSAGE(""); // new line
+ EMU_MESSAGE("Message to the EMU console");
+
+ // ==== Normal Speed Mode ====
+ // Profile code: a single NOP instruction
+ //
+ // The clock units are "1 nop in [CGB] doublespeed mode".
+ // So when *not* running in CGB doublespeed mode you
+ // have to divide by 2 to get the correct cycle count.
+ //
+ // You should see the message "NOP TIME: 2".
+ //
+ // So in this case, divide the printed value by 2 = The NOP took "1" cycle
+
+ __critical { // Temporarily turn off interrupts for more accurate measurements
+ EMU_PROFILE_BEGIN("Profile a single NOP instruction at Normal Speed");
+ __asm__("nop");
+ EMU_PROFILE_END("NOP TIME:");
+ }
+
+
+ // ==== Color Game Boy in Double Speed Mode ====
+ // Profile code: a single NOP instruction
+ //
+ // The EMU_PROFILE_BEGIN/END macros don't support the
+ // Color Game Boy (CGB) in double speed mode (cpu_fast()).
+ // The example below shows what to use instead (and how to
+ // check for a CGB and turn on Double Speed mode).
+ //
+ // Check and only run this test if on CGB hardware
+ if (DEVICE_SUPPORTS_COLOR) {
+
+ // Set CGB into double speed mode
+ // (Requires passing -Wm-yc or -Wm-yC with Lcc during build time)
+ cpu_fast();
+ // Set some default DMG styled colors in the CGB Palette
+ set_default_palette();
+
+ // In CGB Double Speed mode, you don't have to
+ // divide by 2 to get the cycle count.
+ //
+ // You should see the message "NOP TIME: 1".
+
+ __critical { // Temporarily turn off interrupts for more accurate measurements
+ EMU_PROFILE_BEGIN("Profile a single NOP instruction at CGB Double Speed");
+ __asm__("nop");
+ // The "-4+" subtracts 4 clocks to compensate for the ones
+ // used by the debug message itself (Normal speed uses -8)
+ EMU_MESSAGE("NOP TIME:%-4+LASTCLKS%");
+ }
+
+ // Return the CGB to normal speed
+ cpu_slow();
+ }
+
+
+ __critical { // Temporarily turn off interrupts for more accurate measurements
+
+ // Profile code in a loop
+ EMU_PROFILE_BEGIN("Profile code in a loop");
+ for(c=0; c<5; c++) {
+ // Do something
+ printf("%d\n", c);
+ }
+ // Elapsed cycle count output is in hex.
+ // Remember to divide by 2 for the result (Normal Speed)
+ EMU_PROFILE_END("LOOP TIME:");
+ }
+
+
+ // ==== Some other things you can print ====
+
+ // TOTALCLKS shows the clocks counter ("internal divider") in the BGB IO map
+ EMU_MESSAGE("Total Clocks: %TOTALCLKS%");
+
+ // CLKS2VBLANK
+ EMU_MESSAGE("Clocks until VBLANK: %CLKS2VBLANK%");
+
+ // Which Banks are currently active (for MBC based cartridges)
+ EMU_MESSAGE("Current ROM bank: %ROMBANK%");
+ EMU_MESSAGE("Current SRAM bank: %SRAMBANK%");
+ // These are only banked in the CGB
+ EMU_MESSAGE("Current VRAM bank: %VRAMBANK%");
+ EMU_MESSAGE("Current WRAM bank: %WRAMBANK%");
+
+ // Registers (All in this case, or individual ones)
+ EMU_MESSAGE("All Registers: %ALLREGS%");
+
+ // Simple addition with a register
+ EMU_MESSAGE("Register A + 1: %(A+1)%");
+
+ // Read the LY Register a couple times
+ // (Current Y coordinate being rendered to the LCD)
+ EMU_MESSAGE("LY Register (0xFF44): %($ff44)%");
+ EMU_MESSAGE("LY Register (0xFF44): %($ff44)%");
+ // Now print a conditional debug message using it
+ EMU_MESSAGE("Is LY Register > Line 67: %($ff44)>67%Yes;No;");
+
+ // Print some profile info using a built-in function.
+ EMU_MESSAGE("The following lines contain: PROFILE,(SP+$0),(SP+$1),A,TOTALCLKS,ROMBANK,WRAMBANK");
+ EMU_profiler_message();
+ // It's equivalent to:
+ EMU_MESSAGE("PROFILE,%(SP+$0)%,%(SP+$1)%,%A%,%TOTALCLKS%,%ROMBANK%,%WRAMBANK%");
+
+ uint8_t var0 = 16;
+ int16_t var1 = -10;
+ //
+ EMU_printf("var0: %hd; var1: %d; var0*var1=%d", (uint8_t)var0, var1, var0 * var1);
+
+ // The EMU_TEXT() macro will accept a non-quoted string
+ EMU_TEXT("The End");
+
+ return 0;
+}
diff --git a/gbdk/gbdk-lib/examples/ap/filltest/Makefile b/gbdk/gbdk-lib/examples/ap/filltest/Makefile
new file mode 100644
index 00000000..823a32cb
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/filltest/Makefile
@@ -0,0 +1,17 @@
+CC = ../../../bin/lcc -msm83:ap -Wl-j -Wm-yS
+
+BINS = filltest.pocket
+
+all: $(BINS)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+# Compile and link single file in one pass
+%.pocket: %.c
+ $(CC) -o $@ $<
+
+clean:
+ rm -f *.o *.lst *.map *.pocket *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi
+
diff --git a/gbdk/gbdk-lib/examples/ap/filltest/filltest.c b/gbdk/gbdk-lib/examples/ap/filltest/filltest.c
new file mode 100644
index 00000000..628a2c1f
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/filltest/filltest.c
@@ -0,0 +1,60 @@
+/* Sample Program to demonstrate the drawing functions in GBDK */
+/* Jon Fuge jonny@q-continuum.demon.co.uk */
+
+#include <gb/gb.h>
+#include <stdint.h>
+#include <gb/drawing.h>
+
+void linetest(uint8_t x, uint8_t y, uint8_t w) {
+ color(DKGREY,WHITE,SOLID);
+ for (int i = -w; i <= w; i++) line(x,y,x+i,y-w);
+ for (int i = -w; i <= w; i++) line(x,y,x+w,y+i);
+ for (int i = -w; i <= w; i++) line(x,y,x+i,y+w);
+ for (int i = -w; i <= w; i++) line(x,y,x-w,y+i);
+}
+
+void main(void)
+{
+ uint8_t a,b,c,d,e;
+ c=0;
+ /* Draw many characters on the screen with different fg and bg colours */
+ for (a=0; a<=15; a++) {
+ for (b=0; b<=15; b++) {
+ gotogxy(b,a);
+ d=a/4;
+ e=b/4;
+ if (d==e) {
+ d=3-e;
+ }
+ color(d,e,SOLID);
+ gprintf("%c",c++);
+ }
+ }
+
+ /* Draw two circles, a line, and two boxes in different drawing modes */
+ color(LTGREY,WHITE,SOLID);
+ circle(140,20,15,M_FILL);
+ color(BLACK,WHITE,SOLID);
+ circle(140,20,10,M_NOFILL);
+ color(DKGREY,WHITE,XOR);
+ circle(120,40,30,M_FILL);
+ line(0,0,159,143);
+ color(BLACK,LTGREY,SOLID);
+ box(0,130,40,143,M_NOFILL);
+ box(50,130,90,143,M_FILL);
+
+
+ linetest(130, 100, 20);
+
+ /* Scroll the screen using the hardest method imaginable :) */
+ for (c=0; c<=143; c++) {
+ for (b=0; b<=142; b++) {
+ for (a=0; a<=159; a++) {
+ color(getpix(a,b+1),WHITE,SOLID);
+ plot_point(a,b);
+ }
+ color(WHITE,WHITE,SOLID);
+ }
+ line(0,143,159,143);
+ }
+}
diff --git a/gbdk/gbdk-lib/examples/ap/galaxy/Makefile b/gbdk/gbdk-lib/examples/ap/galaxy/Makefile
new file mode 100644
index 00000000..b6d79f10
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/galaxy/Makefile
@@ -0,0 +1,17 @@
+CC = ../../../bin/lcc -msm83:ap -Wl-j -Wm-yS
+
+BINS = galaxy.pocket
+
+all: $(BINS)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+# Compile and link single file in one pass
+%.pocket: %.c
+ $(CC) -o $@ $<
+
+clean:
+ rm -f *.o *.lst *.map *.pocket *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi
+
diff --git a/gbdk/gbdk-lib/examples/ap/galaxy/galaxy.c b/gbdk/gbdk-lib/examples/ap/galaxy/galaxy.c
new file mode 100644
index 00000000..80f45b79
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/galaxy/galaxy.c
@@ -0,0 +1,632 @@
+/*
+ * C version of the 'space' assembly demo.
+ *
+ * Little demo illustrating how to use the graphical possibilities
+ * of the GB (background, window and animated sprite)
+ * I have used fixed-point values for both the position and
+ * speed of objects to get smooth movements
+ *
+ * OBJ data : 0x8000 -> 0x8FFF (unsigned)
+ * Window data : 0x8800 -> 0x97FF (unsigned)
+ * Background data : 0x8800 -> 0x97FF (signed)
+ *
+ * Tiled 0xFC -> 0xFF are standard tiles (all black -> all white)
+ *
+ * Keys:
+ * Arrow keys : Change the speed (and direction) of the sprite
+ * Arrow keys + A : Change the speed (and direction) of the window
+ * Arrow keys + B : Change the speed (and direction) of the background
+ * START : Open/close the door
+ * SELECT : Basic fading effect
+ *
+ * Note that the window is kept in the lower right part of the screen
+ * since it can't be made transparent
+ */
+
+#include <gb/gb.h>
+#include <stdint.h>
+
+const unsigned char std_data[] = {
+
+ /* Basic tiles (0xFC to 0xFF) */
+ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+};
+
+const unsigned char earth_data[] = {
+
+ /* Tile 0x00 */
+ 0x07,0x07,0x18,0x1F,0x32,0x2D,0x71,0x4E,0x70,0x4F,0xF8,0x87,0xF8,0x87,0xF8,0x87,
+ 0xFC,0x83,0xFE,0x81,0x7F,0x40,0x7F,0x40,0x3F,0x20,0x1F,0x18,0x07,0x07,0x00,0x00,
+ 0xC0,0xC0,0xF0,0x30,0x78,0x88,0x3C,0xC4,0x5C,0xA4,0x9E,0x62,0x3E,0xC2,0x3E,0xC2,
+ 0x5E,0xA2,0x7E,0x82,0x0C,0xF4,0x0C,0xF4,0x98,0x68,0xB0,0x70,0xC0,0xC0,0x00,0x00,
+ 0x07,0x07,0x1F,0x18,0x2F,0x30,0x4F,0x70,0x6F,0x50,0x9F,0xE0,0x9F,0xE0,0xBF,0xC0,
+ 0xFF,0x80,0xB7,0xC8,0x63,0x5C,0x43,0x7C,0x3F,0x20,0x1F,0x18,0x07,0x07,0x00,0x00,
+ 0xC0,0xC0,0xB0,0x70,0x18,0xE8,0x0C,0xF4,0x0C,0xF4,0x82,0x7E,0x82,0x7E,0x86,0x7A,
+ 0xC6,0x3A,0xE6,0x1A,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FF,0xFF,
+ 0xFF,0xFF,0xFF,0xFF,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF
+};
+
+/*
+ * Image size: 0x40 x 0x40
+ * Number of tiles (total - unique): 0x40 - 0x2D
+ */
+
+const unsigned char bkg_tiles[] = {
+ 0x00,0x01,0x02,0x03,0xFC,0xFC,0x04,0xFC,
+ 0xFC,0x05,0x06,0xFC,0x07,0x08,0x09,0x0A,
+ 0xFC,0xFC,0xFC,0x02,0x0B,0x0C,0x0D,0xFC,
+ 0x0E,0x0F,0x10,0xFC,0x11,0x12,0x13,0x14,
+ 0x15,0x16,0x17,0xFC,0x18,0x19,0x1A,0xFC,
+ 0x1B,0x1C,0x1D,0xFC,0xFC,0x1E,0x1F,0x20,
+ 0x21,0x22,0xFC,0x23,0x24,0x25,0xFC,0x26,
+ 0x27,0x13,0x28,0x29,0x2A,0x2B,0x2C,0x11
+};
+
+/*
+ * Image size: 0x10 x 0x70
+ * Number of tiles (total - unique): 0x1C - 0x1C
+ */
+
+const unsigned char earth_tiles[] = {
+ 0x00,0x02,
+ 0x04,0x06,
+ 0x08,0x0A,
+ 0x0C,0x0E,
+ 0x10,0x12,
+ 0x14,0x16,
+ 0x18,0x1A
+};
+
+/*
+ * Image size: 0x80 x 0x50
+ * Number of tiles (total - unique): 0xA0 - 0x15
+ */
+
+const unsigned char frame_tiles[] = {
+ 0x80,0x81,0xFD,0x82,0x83,0x81,0xFD,0x82,0x83,0x81,0xFD,0x82,0x83,0x81,0xFD,0x84,
+ 0x85,0x86,0x87,0x88,0x89,0x8A,0x87,0x88,0x89,0x8A,0x87,0x88,0x89,0x8A,0x8B,0x8C,
+ 0xFD,0x8D,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x8E,0x8F,
+ 0x82,0x8C,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x85,0x90,
+ 0x8E,0x8F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFD,0x8D,
+ 0x85,0x90,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x82,0x8C,
+ 0xFD,0x8D,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x8E,0x8F,
+ 0x82,0x8C,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x85,0x90,
+ 0x8E,0x91,0xFD,0x82,0x83,0x81,0xFD,0x82,0x83,0x81,0xFD,0x82,0x83,0x81,0x92,0x8D,
+ 0x93,0x8A,0x87,0x88,0x89,0x8A,0x87,0x88,0x89,0x8A,0x87,0x88,0x89,0x8A,0x87,0x94
+};
+
+/*
+ * Image size: 0x60 x 0x30
+ * Number of tiles (total - unique): 0x48 - 0x03
+ */
+
+const unsigned char door1_tiles[] = {
+ 0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,
+ 0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,
+ 0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,
+ 0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,
+ 0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,
+ 0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,
+
+ 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,
+ 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,
+ 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,
+ 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,
+ 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,
+ 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC
+};
+
+/*
+ * Image size: 0x60 x 0x30
+ * Number of tiles (total - unique): 0x48 - 0x04
+ */
+
+const unsigned char door2_tiles[] = {
+ 0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98,
+ 0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,
+ 0x9A,0x9A,0x9A,0x9A,0x9A,0x9A,0x9A,0x9A,0x9A,0x9A,0x9A,0x9A,
+ 0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98,
+ 0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,
+ 0x9B,0x9B,0x9B,0x9B,0x9B,0x9B,0x9B,0x9B,0x9B,0x9B,0x9B,0x9B,
+
+ 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,
+ 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,
+ 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,
+ 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,
+ 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,
+};
+
+/*
+ * Image size: 0x60 x 0x30
+ * Number of tiles (total - unique): 0x48 - 0x04
+ */
+
+const unsigned char door3_tiles[] = {
+ 0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,
+ 0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,
+ 0x9E,0x9E,0x9E,0x9E,0x9E,0x9E,0x9E,0x9E,0x9E,0x9E,0x9E,0x9E,
+ 0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,
+ 0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,
+ 0x9F,0x9F,0x9F,0x9F,0x9F,0x9F,0x9F,0x9F,0x9F,0x9F,0x9F,0x9F,
+
+ 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,
+ 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,
+ 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,
+ 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,
+ 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC
+};
+
+/*
+ * Image size: 0x60 x 0x30
+ * Number of tiles (total - unique): 0x48 - 0x01
+ */
+
+const unsigned char door4_tiles[] = {
+ 0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,
+ 0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,
+ 0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,
+ 0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,
+ 0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,
+ 0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,
+
+ 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,
+ 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,
+ 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,
+ 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,
+ 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC
+};
+
+/* Should really be const, but sdcc doesnt yet support it. */
+const unsigned char * const film[] = {
+ &door1_tiles[0x0C*0],
+ &door2_tiles[0x0C*0],
+ &door3_tiles[0x0C*0],
+ &door4_tiles[0x0C*0],
+ &door1_tiles[0x0C*1],
+ &door2_tiles[0x0C*1],
+ &door3_tiles[0x0C*1],
+ &door4_tiles[0x0C*1],
+ &door1_tiles[0x0C*2],
+ &door2_tiles[0x0C*2],
+ &door3_tiles[0x0C*2],
+ &door4_tiles[0x0C*2],
+ &door1_tiles[0x0C*3],
+ &door2_tiles[0x0C*3],
+ &door3_tiles[0x0C*3],
+ &door4_tiles[0x0C*3],
+ &door1_tiles[0x0C*4],
+ &door2_tiles[0x0C*4],
+ &door3_tiles[0x0C*4],
+ &door4_tiles[0x0C*4],
+ &door1_tiles[0x0C*5],
+ &door2_tiles[0x0C*5],
+ &door3_tiles[0x0C*5],
+ &door4_tiles[0x0C*5],
+ &door1_tiles[0x0C*6]
+};
+
+#define NBDFRAMES 0x18 /* Nb frames for the door */
+#define NBSFRAMES 0x07 /* Nb frames for the sprite */
+#define WINSZX 0x80 /* Size of the picture in the window */
+#define WINSZY 0x50
+#define MINWINX (MAXWNDPOSX-WINSZX+1) /* Bounds of the window origin */
+#define MINWINY (MAXWNDPOSY-WINSZY+1)
+#define MAXWINX MAXWNDPOSX
+#define MAXWINY MAXWNDPOSY
+#define FADESTEP 0x10 /* Nb steps for the fading effect */
+#define STARTFADE (0x06*FADESTEP) /* Initial value for the fading effect */
+
+#define CLOSED 0x00
+#define OPENING 0x01
+#define OPENED 0x02
+#define CLOSING 0x03
+
+static uint8_t time = 0; /* Global "time" value (counter) */
+uint8_t doorstate = 0; /* State of the door (OPENED, CLOSED...) */
+uint8_t doorpos = 0; /* Current position in the door animation */
+static uint8_t color = 0; /* Current color for fading effect */
+uint8_t sframe = 0; /* Current frame of the sprite */
+fixed bposx, bposy; /* Background position (fixed point) */
+fixed bspx, bspy; /* Background speed (fixed point) */
+fixed wposx, wposy; /* Window position (fixed point) */
+fixed wspx, wspy; /* Window speed (fixed point) */
+fixed sposx, sposy; /* Sprite position (fixed point) */
+fixed sspx, sspy; /* Sprite speed (fixed point) */
+
+void fade();
+void scroll();
+void door();
+void animate_sprite();
+void tile_sprite();
+void place_sprite();
+
+/* Fade the screen (off and on) */
+void fade()
+{
+ if(color == 0)
+ return;
+ switch(color)
+ {
+ case STARTFADE:
+ case STARTFADE-4*FADESTEP:
+ BGP_REG = 0xF9U;
+ break;
+ case STARTFADE-FADESTEP:
+ case STARTFADE-3*FADESTEP:
+ BGP_REG = 0xFEU;
+ break;
+ case STARTFADE-2*FADESTEP:
+ BGP_REG = 0xFFU;
+ break;
+ case STARTFADE-5*FADESTEP:
+ BGP_REG = 0xE4U;
+ break;
+ }
+ color--;
+}
+
+/* Scroll the background, the window and the sprite */
+void scroll()
+{
+ /* Update background */
+ bposx.w += bspx.w;
+ bposy.w += bspy.w;
+ SCX_REG = bposx.b.h;
+ SCY_REG = bposy.b.h;
+
+ /* Update window */
+ wposx.w += wspx.w ;
+ wposy.w += wspy.w ;
+ /* X position */
+ if(wposx.b.h >= MAXWINX) {
+ wposx.b.h = MAXWINX;
+ /* Invert speed */
+ wspx.w = -(int16_t)wspx.w;
+ } else if(wposx.b.h <= MINWINX) {
+ wposx.b.h = MINWINX;
+ /* Invert speed */
+ wspx.w = -(int16_t)wspx.w;
+ }
+ WX_REG = wposx.b.h;
+ /* Y position */
+ if(wposy.b.h >= MAXWINY) {
+ wposy.b.h = MAXWINY;
+ /* Invert speed */
+ wspy.w = -(int16_t)wspy.w;
+ } else if(wposy.b.h <= MINWINY) {
+ wposy.b.h = MINWINY;
+ /* Invert speed */
+ wspy.w = -(int16_t)wspy.w;
+ }
+ WY_REG = wposy.b.h;
+
+ /* Update sprite */
+ sposx.w += sspx.w;
+ sposy.w += sspy.w;
+ place_sprite();
+}
+
+/* Open and close the door */
+void door()
+{
+ if(doorstate == OPENING) {
+ doorpos++;
+ /* Draw the door in the window */
+ set_win_tiles(2, 2, 12, 6, (unsigned char*)film[doorpos]);
+ if(doorpos == NBDFRAMES)
+ doorstate = OPENED;
+ } else if(doorstate == CLOSING) {
+ doorpos--;
+ /* Draw the door in the window */
+ set_win_tiles(2, 2, 12, 6, (unsigned char*)film[doorpos]);
+ if(doorpos == 0)
+ doorstate = CLOSED;
+ }
+}
+
+/* Animate sprite */
+void animate_sprite()
+{
+ if((time&0x07) == 0) {
+ sframe++;
+ if(sframe == NBSFRAMES)
+ sframe = 0;
+ tile_sprite();
+ }
+}
+
+/* Set sprite tiles */
+void tile_sprite()
+{
+ uint8_t s;
+
+ s = sframe<<1;
+ set_sprite_tile(0, earth_tiles[s]);
+ set_sprite_tile(1, earth_tiles[s+1]);
+}
+
+/* Place sprite */
+void place_sprite()
+{
+ move_sprite(0, sposx.b.h, sposy.b.h);
+ move_sprite(1, sposx.b.h+8, sposy.b.h);
+}
+
+void main()
+{
+ uint8_t i, j;
+
+ disable_interrupts();
+ DISPLAY_OFF;
+ LCDC_REG = LCDCF_OFF | LCDCF_WIN9C00 | LCDCF_WINON | LCDCF_BG8800 | LCDCF_BG9800 | LCDCF_OBJ16 | LCDCF_OBJON | LCDCF_BGON;
+ /*
+ * LCD = Off
+ * WindowBank = 0x9C00
+ * Window = On
+ * BG Chr = 0x8800
+ * BG Bank = 0x9800
+ * OBJ = 8x16
+ * OBJ = On
+ * BG = On
+ */
+
+ doorstate = CLOSED;
+
+ /* Set palettes */
+ BGP_REG = OBP0_REG = OBP1_REG = 0xE4U;
+
+ /* Initialize the background */
+ set_bkg_data(0xFC, 0x04, std_data);
+ set_bkg_data(0x00, 0x2D, bkg_data);
+ /*
+ * Draw the background
+ *
+ * Width = 0x100 = 0x20 * 8
+ * Height = 0x100 = 0x20 * 8
+ */
+ for(i = 0; i < 32; i+=8)
+ for(j = 0; j < 32; j+=8)
+ set_bkg_tiles(i, j, 8, 8, bkg_tiles);
+ bposx.w = 0;
+ SCX_REG = 0;
+ bposy.w = 0;
+ SCY_REG = 0;
+ bspx.w = 0xFF00;
+ bspy.w = 0x0080;
+
+ /* Initialize the window */
+ set_win_data(0x80, 0x21, frame_data);
+ /*
+ * Draw the frame in the window
+ *
+ * Width = 0x80 = 0x10 * 8
+ * Height = 0x50 = 0x0A * 8
+ */
+ set_win_tiles(0, 0, 16, 10, frame_tiles);
+ /*
+ * Draw the door in the window
+ *
+ * Width = 0x60 = 0x20 * 12
+ * Height = 0x30 = 0x20 * 6
+ */
+ set_win_tiles(2, 2, 12, 6, door1_tiles);
+ wposx.b.h = MAXWNDPOSX;
+ wposx.b.l = 0;
+ WX_REG = MAXWNDPOSX;
+ wposy.b.h = MAXWNDPOSY;
+ wposy.b.l = 0;
+ WY_REG = MAXWNDPOSY;
+ wspx.w = 0xFF80;
+ wspy.w = 0xFFC0;
+
+ /* Initialize the sprite */
+ set_sprite_data(0x00, 0x1C, earth_data);
+ set_sprite_prop(0, 0x00);
+ set_sprite_prop(1, 0x00);
+ sframe = 0;
+ sposx.w = 0x1000;
+ sposy.w = 0x1000;
+ sspx.w = 0x0040;
+ sspy.w = 0x0040;
+ tile_sprite();
+ place_sprite();
+
+ DISPLAY_ON;
+ enable_interrupts();
+
+ while(1) {
+ /* Skip four VBLs (slow down animation) */
+ for(i = 0; i < 4; i++)
+ wait_vbl_done();
+ time++;
+ fade();
+ door();
+ scroll();
+ animate_sprite();
+ i = joypad();
+ if(i & J_B) {
+ if(i & J_UP)
+ bspy.w -= 0x0010;
+ if(i & J_DOWN)
+ bspy.w += 0x0010;
+ if(i & J_LEFT)
+ bspx.w -= 0x0010;
+ if(i & J_RIGHT)
+ bspx.w += 0x0010;
+ } else if(i & J_A) {
+ if(i & J_UP)
+ wspy.w -= 0x0010;
+ if(i & J_DOWN)
+ wspy.w += 0x0010;
+ if(i & J_LEFT)
+ wspx.w -= 0x0010;
+ if(i & J_RIGHT)
+ wspx.w += 0x0010;
+ } else {
+ if(i & J_SELECT)
+ color = STARTFADE;
+ if(i & J_START)
+ if(doorstate == CLOSED) {
+ doorstate = OPENING;
+ doorpos = 0;
+ } else if(doorstate == OPENED) {
+ doorstate = CLOSING;
+ doorpos = NBDFRAMES;
+ }
+ if(i & J_UP)
+ sspy.w -= 0x0010;
+ if(i & J_DOWN)
+ sspy.w += 0x0010;
+ if(i & J_LEFT)
+ sspx.w -= 0x0010;
+ if(i & J_RIGHT)
+ sspx.w += 0x0010;
+ }
+ }
+}
diff --git a/gbdk/gbdk-lib/examples/ap/gb-dtmf/Makefile b/gbdk/gbdk-lib/examples/ap/gb-dtmf/Makefile
new file mode 100644
index 00000000..3b562daf
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/gb-dtmf/Makefile
@@ -0,0 +1,24 @@
+CC = ../../../bin/lcc -msm83:ap -Wl-j -Wm-yS
+
+BINS = gb-dtmf.pocket
+
+all: $(BINS)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+%.s: %.c
+ $(CC) -S -o $@ $<
+
+%.o: %.c
+ $(CC) -c -o $@ $<
+
+%.o: %.s
+ $(CC) -c -o $@ $<
+
+%.pocket: %.o
+ $(CC) -o $@ $<
+
+clean:
+ rm -f *.o *.lst *.map *.pocket *.ihx *.sym *.cdb *.adb *.asm
diff --git a/gbdk/gbdk-lib/examples/ap/gb-dtmf/brk_btn.c b/gbdk/gbdk-lib/examples/ap/gb-dtmf/brk_btn.c
new file mode 100644
index 00000000..186e4ba6
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/gb-dtmf/brk_btn.c
@@ -0,0 +1,41 @@
+/*
+
+ BREAK_BTN.C
+
+ Tile Source File.
+
+ Info:
+ Form : All tiles as one unit.
+ Format : Gameboy 4 color.
+ Counter : None.
+ Tile size : 8 x 8
+ Tiles : 0 to 8
+
+ This file was generated by GBTD v0.5
+
+*/
+
+/* Start of tile array. */
+const unsigned char break_btn[] =
+{
+ 0x00,0x00,0x00,0x00,0x3F,0x00,0x3F,0x00,
+ 0x3F,0x00,0x3F,0x00,0x3F,0x00,0x3F,0x00,
+ 0x00,0x00,0x00,0x00,0xFF,0x00,0xFF,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0x00,0x01,0x00,0x03,0xFC,0x03,0xFC,0x03,
+ 0xFC,0x03,0xFC,0x03,0xFC,0x03,0xFC,0x03,
+ 0x3F,0x00,0x3F,0x00,0x3F,0x00,0x3F,0x00,
+ 0x3F,0x00,0x3F,0x00,0x3F,0x00,0x3F,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0xFC,0x03,0xFC,0x03,0xFC,0x03,0xFC,0x03,
+ 0xFC,0x03,0xFC,0x03,0xFC,0x03,0xFC,0x03,
+ 0x3F,0x00,0x3F,0x00,0x3F,0x00,0x3F,0x00,
+ 0x3F,0x00,0x3F,0x00,0x00,0x3F,0x00,0x7F,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0xFF,0x00,0xFF,0x00,0x00,0xFF,0x00,0xFF,
+ 0xFC,0x03,0xFC,0x03,0xFC,0x03,0xFC,0x03,
+ 0xFC,0x03,0xFC,0x03,0x00,0xFF,0x00,0xFF
+};
+
+/* End of BREAK_BTN.C */
diff --git a/gbdk/gbdk-lib/examples/ap/gb-dtmf/brk_btn.gbr b/gbdk/gbdk-lib/examples/ap/gb-dtmf/brk_btn.gbr
new file mode 100644
index 00000000..985131c2
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/gb-dtmf/brk_btn.gbr
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/ap/gb-dtmf/cursor.c b/gbdk/gbdk-lib/examples/ap/gb-dtmf/cursor.c
new file mode 100644
index 00000000..e6151222
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/gb-dtmf/cursor.c
@@ -0,0 +1,39 @@
+/*
+
+ CURSOR.C
+
+ Tile Source File.
+
+ Info:
+ Form : All tiles as one unit.
+ Format : Gameboy 4 color.
+ Counter : None.
+ Tile size : 16 x 16
+ Tiles : 0 to 1
+
+ This file was generated by GBTD v0.5
+
+*/
+
+/* Start of tile array. */
+const unsigned char cursor_data[] =
+{
+ 0x06,0x06,0x09,0x09,0x09,0x09,0x09,0x0F,
+ 0x09,0x0F,0x69,0x6F,0x19,0x3F,0x59,0x7F,
+ 0x49,0x7F,0x49,0x7F,0x40,0x7F,0x40,0x7F,
+ 0x20,0x3F,0x10,0x1F,0x08,0x0F,0x0F,0x0F,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xA8,0xA8,0x54,0xFC,
+ 0x54,0xFC,0x54,0xFC,0x04,0xFC,0x04,0xFC,
+ 0x08,0xF8,0x10,0xF0,0x20,0xE0,0xE0,0xE0,
+ 0x00,0x00,0x06,0x06,0x09,0x09,0x09,0x0F,
+ 0x09,0x0F,0x69,0x6F,0x19,0x3F,0x59,0x7F,
+ 0x49,0x7F,0x49,0x7F,0x40,0x7F,0x40,0x7F,
+ 0x20,0x3F,0x10,0x1F,0x08,0x0F,0x0F,0x0F,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xA8,0xA8,0x54,0xFC,
+ 0x54,0xFC,0x54,0xFC,0x04,0xFC,0x04,0xFC,
+ 0x08,0xF8,0x10,0xF0,0x20,0xE0,0xE0,0xE0
+};
+
+/* End of CURSOR.C */
diff --git a/gbdk/gbdk-lib/examples/ap/gb-dtmf/cursor.gbr b/gbdk/gbdk-lib/examples/ap/gb-dtmf/cursor.gbr
new file mode 100644
index 00000000..9baa76a8
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/gb-dtmf/cursor.gbr
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/ap/gb-dtmf/dtmf_lcd.c b/gbdk/gbdk-lib/examples/ap/gb-dtmf/dtmf_lcd.c
new file mode 100644
index 00000000..c16aa07f
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/gb-dtmf/dtmf_lcd.c
@@ -0,0 +1,123 @@
+/*
+
+ DTMF_LCD.C
+
+ Tile Source File.
+
+ Info:
+ Form : All tiles as one unit.
+ Format : Gameboy 4 color.
+ Counter : None.
+ Tile size : 8 x 16
+ Tiles : 0 to 24
+
+ This file was generated by GBTD v0.5
+
+*/
+
+/* Start of tile array. */
+const unsigned char dtmf_lcd[] =
+{
+ 0x3E,0x3E,0x7F,0x7F,0x63,0x63,0x63,0x63,
+ 0x63,0x63,0x63,0x63,0x63,0x63,0x00,0x00,
+ 0x00,0x00,0x63,0x63,0x63,0x63,0x63,0x63,
+ 0x63,0x63,0x63,0x63,0x7F,0x7F,0x3E,0x3E,
+ 0x3E,0x02,0x7F,0x03,0x63,0x03,0x63,0x03,
+ 0x63,0x03,0x63,0x03,0x63,0x03,0x3C,0x00,
+ 0x3C,0x00,0x63,0x03,0x63,0x03,0x63,0x03,
+ 0x63,0x03,0x63,0x03,0x7F,0x03,0x3E,0x02,
+ 0x3E,0x3E,0x7F,0x7F,0x63,0x03,0x63,0x03,
+ 0x63,0x03,0x63,0x03,0x63,0x03,0x3E,0x3E,
+ 0x3E,0x3E,0x63,0x60,0x63,0x60,0x63,0x60,
+ 0x63,0x60,0x63,0x60,0x7F,0x7F,0x3E,0x3E,
+ 0x3E,0x3E,0x7F,0x7F,0x63,0x03,0x63,0x03,
+ 0x63,0x03,0x63,0x03,0x63,0x03,0x3E,0x3E,
+ 0x3E,0x3E,0x63,0x03,0x63,0x03,0x63,0x03,
+ 0x63,0x03,0x63,0x03,0x7F,0x7F,0x3E,0x3E,
+ 0x3E,0x22,0x7F,0x63,0x63,0x63,0x63,0x63,
+ 0x63,0x63,0x63,0x63,0x63,0x63,0x3E,0x3E,
+ 0x3E,0x3E,0x63,0x03,0x63,0x03,0x63,0x03,
+ 0x63,0x03,0x63,0x03,0x7F,0x03,0x3E,0x02,
+ 0x3E,0x3E,0x7F,0x7F,0x63,0x60,0x63,0x60,
+ 0x63,0x60,0x63,0x60,0x63,0x60,0x3E,0x3E,
+ 0x3E,0x3E,0x63,0x03,0x63,0x03,0x63,0x03,
+ 0x63,0x03,0x63,0x03,0x7F,0x7F,0x3E,0x3E,
+ 0x3E,0x3E,0x7F,0x7F,0x63,0x60,0x63,0x60,
+ 0x63,0x60,0x63,0x60,0x63,0x60,0x3E,0x3E,
+ 0x3E,0x3E,0x63,0x63,0x63,0x63,0x63,0x63,
+ 0x63,0x63,0x63,0x63,0x7F,0x7F,0x3E,0x3E,
+ 0x3E,0x3E,0x7F,0x7F,0x63,0x03,0x63,0x03,
+ 0x63,0x03,0x63,0x03,0x63,0x03,0x3E,0x00,
+ 0x3E,0x00,0x63,0x03,0x63,0x03,0x63,0x03,
+ 0x63,0x03,0x63,0x03,0x7F,0x03,0x3E,0x02,
+ 0x3E,0x3E,0x7F,0x7F,0x63,0x63,0x63,0x63,
+ 0x63,0x63,0x63,0x63,0x63,0x63,0x3E,0x3E,
+ 0x3E,0x3E,0x63,0x63,0x63,0x63,0x63,0x63,
+ 0x63,0x63,0x63,0x63,0x7F,0x7F,0x3E,0x3E,
+ 0x3E,0x3E,0x7F,0x7F,0x63,0x63,0x63,0x63,
+ 0x63,0x63,0x63,0x63,0x63,0x63,0x3E,0x3E,
+ 0x3E,0x3E,0x63,0x03,0x63,0x03,0x63,0x03,
+ 0x63,0x03,0x63,0x03,0x7F,0x7F,0x3E,0x3E,
+ 0x3E,0x3E,0x7F,0x7F,0x63,0x63,0x63,0x63,
+ 0x63,0x63,0x63,0x63,0x63,0x63,0x3E,0x3E,
+ 0x3E,0x3E,0x63,0x63,0x63,0x63,0x63,0x63,
+ 0x63,0x63,0x63,0x63,0x7F,0x63,0x3E,0x00,
+ 0x3E,0x20,0x7F,0x60,0x63,0x60,0x63,0x60,
+ 0x63,0x60,0x63,0x60,0x63,0x60,0x3E,0x3E,
+ 0x3E,0x3E,0x63,0x63,0x63,0x63,0x63,0x63,
+ 0x63,0x63,0x63,0x63,0x7F,0x7F,0x3E,0x3E,
+ 0x3E,0x3E,0x7F,0x7F,0x63,0x60,0x63,0x60,
+ 0x63,0x60,0x63,0x60,0x63,0x60,0x3E,0x20,
+ 0x3E,0x20,0x63,0x60,0x63,0x60,0x63,0x60,
+ 0x63,0x60,0x63,0x60,0x7F,0x7F,0x3E,0x3E,
+ 0x3E,0x02,0x7F,0x03,0x63,0x03,0x63,0x03,
+ 0x63,0x03,0x63,0x03,0x63,0x03,0x3E,0x3E,
+ 0x3E,0x3E,0x63,0x63,0x63,0x63,0x63,0x63,
+ 0x63,0x63,0x63,0x63,0x7F,0x7F,0x3E,0x3E,
+ 0x00,0x00,0x36,0x36,0x36,0x36,0x36,0x36,
+ 0x36,0x36,0x7F,0x7F,0x7F,0x7F,0x36,0x36,
+ 0x36,0x36,0x7F,0x7F,0x7F,0x7F,0x36,0x36,
+ 0x36,0x36,0x36,0x36,0x36,0x36,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x2A,0x2A,0x6B,0x6B,
+ 0x6B,0x6B,0x6B,0x6B,0x3E,0x3E,0x1C,0x1C,
+ 0x3E,0x3E,0x6B,0x6B,0x6B,0x6B,0x6B,0x6B,
+ 0x2A,0x2A,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x3E,0x00,0x7F,0x00,0x63,0x00,0x63,0x00,
+ 0x63,0x00,0x63,0x00,0x63,0x00,0x3E,0x00,
+ 0x3E,0x00,0x63,0x00,0x63,0x00,0x63,0x00,
+ 0x63,0x00,0x63,0x00,0x7F,0x00,0x3E,0x00,
+ 0x3E,0x22,0x7F,0x63,0x63,0x63,0x63,0x63,
+ 0x63,0x63,0x63,0x63,0x63,0x63,0x3E,0x3E,
+ 0x3E,0x3E,0x63,0x03,0x63,0x03,0x63,0x03,
+ 0x63,0x03,0x63,0x03,0x7F,0x7F,0x3E,0x3E,
+ 0x3E,0x22,0x7F,0x63,0x77,0x77,0x77,0x77,
+ 0x77,0x77,0x77,0x77,0x6B,0x6B,0x2A,0x2A,
+ 0x2A,0x2A,0x6B,0x6B,0x63,0x63,0x63,0x63,
+ 0x63,0x63,0x63,0x63,0x7F,0x63,0x3E,0x22,
+ 0x3E,0x22,0x7F,0x63,0x63,0x63,0x63,0x63,
+ 0x63,0x63,0x63,0x63,0x63,0x63,0x3E,0x22,
+ 0x3E,0x22,0x63,0x63,0x63,0x63,0x63,0x63,
+ 0x63,0x63,0x63,0x63,0x7F,0x7F,0x3E,0x3E,
+ 0x3E,0x3E,0x7F,0x7F,0x63,0x60,0x63,0x60,
+ 0x63,0x60,0x63,0x60,0x63,0x60,0x3F,0x27,
+ 0x3F,0x27,0x63,0x63,0x63,0x63,0x63,0x63,
+ 0x63,0x63,0x63,0x63,0x7F,0x7F,0x3E,0x3E,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x3E,
+ 0x3E,0x3E,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x67,0x67,0x67,0x67,0x18,0x18,0x18,0x18,
+ 0x18,0x18,0x18,0x18,0x18,0x18,0x00,0x00,
+ 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
+ 0x18,0x18,0x18,0x18,0x18,0x18,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x0C,0x0C,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,
+ 0x0C,0x0C,0x04,0x04,0x08,0x08,0x00,0x00,
+ 0x3E,0x3E,0x7E,0x7E,0x63,0x60,0x63,0x60,
+ 0x63,0x60,0x63,0x60,0x63,0x60,0x3E,0x3E,
+ 0x3E,0x3E,0x63,0x60,0x63,0x60,0x63,0x60,
+ 0x63,0x60,0x63,0x60,0x7F,0x60,0x3E,0x20
+};
+
+/* End of DTMF_LCD.C */
diff --git a/gbdk/gbdk-lib/examples/ap/gb-dtmf/dtmf_lcd.gbr b/gbdk/gbdk-lib/examples/ap/gb-dtmf/dtmf_lcd.gbr
new file mode 100644
index 00000000..737a8040
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/gb-dtmf/dtmf_lcd.gbr
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/ap/gb-dtmf/frm_lcd.c b/gbdk/gbdk-lib/examples/ap/gb-dtmf/frm_lcd.c
new file mode 100644
index 00000000..4d82262e
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/gb-dtmf/frm_lcd.c
@@ -0,0 +1,41 @@
+/*
+
+ FRAME_LCD.C
+
+ Tile Source File.
+
+ Info:
+ Form : All tiles as one unit.
+ Format : Gameboy 4 color.
+ Counter : None.
+ Tile size : 8 x 8
+ Tiles : 0 to 8
+
+ This file was generated by GBTD v0.5
+
+*/
+
+/* Start of tile array. */
+const unsigned char frame_lcd[] =
+{
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,
+ 0x00,0x1F,0x00,0x18,0x00,0x18,0x00,0x18,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,
+ 0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,
+ 0x00,0xF8,0x00,0x18,0x00,0x18,0x00,0x18,
+ 0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,
+ 0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,
+ 0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,
+ 0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x1F,
+ 0x00,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,
+ 0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x18,0x00,0x18,0x00,0x18,0x00,0xF8,
+ 0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00
+};
+
+/* End of FRAME_LCD.C */
diff --git a/gbdk/gbdk-lib/examples/ap/gb-dtmf/frm_lcd.gbr b/gbdk/gbdk-lib/examples/ap/gb-dtmf/frm_lcd.gbr
new file mode 100644
index 00000000..f89a22e7
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/gb-dtmf/frm_lcd.gbr
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/ap/gb-dtmf/gb-dtmf.c b/gbdk/gbdk-lib/examples/ap/gb-dtmf/gb-dtmf.c
new file mode 100644
index 00000000..0bb92cb9
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/gb-dtmf/gb-dtmf.c
@@ -0,0 +1,715 @@
+/* ---------------------------------------- */
+/* GB-DTMF Ver1.0 */
+/* by */
+/* Osamu Ohashi */
+/* ---------------------------------------- */
+
+#include <gb/gb.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+
+/* BG data */
+#include "frm_lcd.c" /* Back ground pattern */
+#include "brk_btn.c" /* button image when broken */
+#include "prs_btn.c" /* button image when pressed */
+
+#include "dtmf_lcd.c" /* LCD characters */
+
+/* Sprite data */
+#include "key_num.c" /* Sprite pattern for each key pad */
+#include "cursor.c" /* cursor pattern */
+
+/*
+ usage of BG data
+ file name number of BG type of matrix aount
+ -------------------------------------------------
+ frame_lcd.c 9 8 x 8 9
+ break_btn.c 9 8 x 8 9
+ press_btn.c 9 8 x 8 9
+ dtmf_lcd.c 25 8 x 16 50
+ ------------------------------------------------
+ total 77
+
+
+ usage of OBJ data
+ file name number of obj type of matrix amount
+ --------------------------------------------------
+ key_num.c 23 8 x 8 23
+ cursor.c 2 16 x 16 8
+ --------------------------------------------------
+ total 31
+*/
+
+
+/* display */
+#define TITLE " GB-DTMF BY 05AMU "
+
+#define OFFSET 27U
+#define KEY_STEP 24U /* Key matrix size as 24 x 24 */
+#define START_CURSOR_X 24U /* CURSOR position */
+#define START_CURSOR_Y 72U
+
+#define LCD_X 1U /* start position of X */
+#define LCD_Y 2U /* start position of Y */
+#define LCD_WIDTH 18U /* Horizontal size of LCD */
+#define LCD_HIGHT 2U /* Vertical Size of LCD */
+
+
+#define ON 1
+#define OFF 0
+
+/* DTMF */
+#define DTMF_ON 100UL /* Tone on time */
+#define DTMF_OFF 100UL /* Tone off time */
+
+#define MAX_DTMF 30 /* Maximum length of DTMF strings */
+
+/*
+ Frequency setting
+*/
+/*
+ We have to calculate the frequency as following formula
+
+ DTMF has two set frequency, we have to decide Row & Column
+ with each digit('0','1','2'...)
+*/
+
+#define C1 0x94U /* 1209Hz, 1213Hz */
+#define C2 0x9EU /* 1336Hz, 1337Hz */
+#define C3 0xA7U /* 1477Hz, 1472Hz */
+#define C4 0xB0U /* 1633Hz, 1638Hz */
+
+#define R1 0x44U /* 697Hz, 697Hz */
+#define R2 0x56U /* 770Hz, 770Hz */
+#define R3 0x66U /* 852Hz, 851Hz */
+#define R4 0x75U /* 941Hz, 942Hz */
+
+const unsigned char row[4] = {R1,R2,R3,R4}; /* DTMF frequency strage of Row */
+const unsigned char col[4] = {C1,C2,C3,C4}; /* DTMF frequency strage of Col */
+
+/* It is possible to set up initial screen by each BG data. */
+const unsigned char dtmf_tile[] = {
+ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
+
+ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2,
+ 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5,
+ 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5,
+ 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8,
+
+ 4, 9,10,11, 9,10,11, 9,10,11, 9,10,11, 4, 9,10,11, 9,10,11,
+ 4,12,13,14,12,13,14,12,13,14,12,13,14, 4,12,13,14,12,13,14,
+ 4,15,16,17,15,16,17,15,16,17,15,16,17, 4,15,16,17,15,16,17,
+
+ 4, 9,10,11, 9,10,11, 9,10,11, 9,10,11, 4, 9,10,11, 9,10,11,
+ 4,12,13,14,12,13,14,12,13,14,12,13,14, 4,12,13,14,12,13,14,
+ 4,15,16,17,15,16,17,15,16,17,15,16,17, 4,15,16,17,15,16,17,
+
+ 4, 9,10,11, 9,10,11, 9,10,11, 9,10,11, 4, 9,10,11, 9,10,11,
+ 4,12,13,14,12,13,14,12,13,14,12,13,14, 4,12,13,14,12,13,14,
+ 4,15,16,17,15,16,17,15,16,17,15,16,17, 4,15,16,17,15,16,17,
+
+ 4, 9,10,11, 9,10,11, 9,10,11, 9,10,11, 4, 9,10,10,10,10,11,
+ 4,12,13,14,12,13,14,12,13,14,12,13,14, 4,12,13,13,13,13,14,
+ 4,15,16,17,15,16,17,15,16,17,15,16,17, 4,15,16,16,16,16,17,
+
+ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4
+};
+
+/*
+ Button image
+ Normal buttons are created by 3tiles x 3tiles(24pixels x 24pixels)
+ Dialing button is created by 6tiles x 3tiles(48pixels x 24pixels)
+*/
+const unsigned char break_tile[] = {
+ 9,10,11,
+ 12,13,14,
+ 15,16,17
+};
+
+const unsigned char dialing_break[] = {
+ 9,10,10,10,10,11,
+ 12,13,13,13,13,14,
+ 15,16,16,16,16,17
+};
+
+const unsigned char press_tile[] = {
+ 18,19,20,
+ 21,22,23,
+ 24,25,26
+};
+
+
+const unsigned char dialing_press[] = {
+ 18,19,19,19,19,20,
+ 21,22,22,22,22,23,
+ 24,25,25,25,25,26
+};
+
+/*
+ LCD image at initial & AC
+*/
+const unsigned char init_disp[] = {
+ 59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,
+ 60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60
+};
+
+const char pad[4][6] = { /* DTMF Pad assign */
+ {'1','2','3','A','%','P'},
+ {'4','5','6','B','-','F'},
+ {'7','8','9','C',',','?'},
+ {'*','0','#','D','s','s'}
+};
+
+unsigned char disp_tile[MAX_DTMF * 2];
+
+/*
+ Initialize for sound registers
+ ch1, ch2 are used for this routine.
+*/
+void init_dial()
+{
+
+ NR52_REG = 0x83U;
+ NR51_REG = 0x00U;
+ NR50_REG = 0x77U;
+
+ NR24_REG = 0x87U;
+ NR22_REG = 0xffU;
+ NR21_REG = 0xbfU;
+
+ NR14_REG = 0x87U;
+ NR12_REG = 0xffU;
+ NR11_REG = 0xbfU;
+ NR10_REG = 0x04U;
+}
+
+/* sound engine for DTMF */
+void dialtone(uint16_t dtmf_on, uint16_t dtmf_off, char str[20])
+{
+ uint8_t i = 0;
+
+ while(str[i]){
+ switch(str[i]){
+ case '1':
+ NR13_REG = R1;
+ NR23_REG = C1;
+ break;
+ case '2':
+ NR13_REG = R1;
+ NR23_REG = C2;
+ break;
+ case '3':
+ NR13_REG = R1;
+ NR23_REG = C3;
+ break;
+ case 'A':
+ case 'a':
+ NR13_REG = R1;
+ NR23_REG = C4;
+ break;
+ case '4':
+ NR13_REG = R2;
+ NR23_REG = C1;
+ break;
+ case '5':
+ NR13_REG = R2;
+ NR23_REG = C2;
+ break;
+ case '6':
+ NR13_REG = R2;
+ NR23_REG = C3;
+ break;
+ case 'B':
+ case 'b':
+ NR13_REG = R2;
+ NR23_REG = C4;
+ break;
+ case '7':
+ NR13_REG = R3;
+ NR23_REG = C1;
+ break;
+ case '8':
+ NR13_REG = R3;
+ NR23_REG = C2;
+ break;
+ case '9':
+ NR13_REG = R3;
+ NR23_REG = C3;
+ break;
+ case 'C':
+ case 'c':
+ NR13_REG = R3;
+ NR23_REG = C4;
+ break;
+ case '*':
+ NR13_REG = R4;
+ NR23_REG = C1;
+ break;
+ case '0':
+ NR13_REG = R4;
+ NR23_REG = C2;
+ break;
+ case '#':
+ NR13_REG = R4;
+ NR23_REG = C3;
+ break;
+ case 'D':
+ case 'd':
+ NR13_REG = R4;
+ NR23_REG = C4;
+ break;
+ case ',':
+ delay(dtmf_on); /* keep on */
+ delay(dtmf_off); /* keep off */
+
+ default:
+ NR51_REG = 0x00U; /* sound off */
+ goto skip;
+
+ }
+ NR24_REG = 0x87U; /* ch2 tips */
+ NR51_REG = 0x33U; /* sound on */
+ delay(dtmf_on); /* keep on */
+
+ NR51_REG = 0x00U; /* sound off */
+ delay(dtmf_off); /* keep off */
+
+ skip:
+ i++;
+ }
+}
+
+
+/* Display looks like 7-SEGMENT LED */
+void disp_lcd(uint8_t len, char str[MAX_DTMF])
+{
+ uint8_t i,j;
+
+ j = len;
+
+ i=0;
+ while(str[i]){
+ if(str[i] >= '0'||'9' <= str[i]){
+ disp_tile[i] = OFFSET + (str[i] - '0') * 2;
+ disp_tile[i+j] = OFFSET + (str[i] - '0') * 2 + 1;
+ }
+ switch(str[i]){
+ case 'A':
+ disp_tile[i] = OFFSET + 10 * 2;
+ disp_tile[i+j] = OFFSET + 10 * 2 + 1;
+ break;
+ case 'B':
+ disp_tile[i] = OFFSET + 11 * 2;
+ disp_tile[i+j] = OFFSET + 11 * 2 + 1;
+ break;
+ case 'C':
+ disp_tile[i] = OFFSET + 12 * 2;
+ disp_tile[i+j] = OFFSET + 12 * 2 + 1;
+ break;
+ case 'D':
+ disp_tile[i] = OFFSET + 13 * 2;
+ disp_tile[i+j] = OFFSET + 13 * 2 + 1;
+ break;
+ case '#':
+ disp_tile[i] = OFFSET + 14 * 2;
+ disp_tile[i+j] = OFFSET + 14 * 2 + 1;
+ break;
+ case '*':
+ disp_tile[i] = OFFSET + 15 * 2;
+ disp_tile[i+j] = OFFSET + 15 * 2 + 1;
+ break;
+ case ' ':
+ disp_tile[i] = OFFSET + 16 * 2;
+ disp_tile[i+j] = OFFSET + 16 * 2 + 1;
+ break;
+ case 'Y':
+ disp_tile[i] = OFFSET + 17 * 2;
+ disp_tile[i+j] = OFFSET + 17 * 2 + 1;
+ break;
+ case 'M':
+ disp_tile[i] = OFFSET + 18 * 2;
+ disp_tile[i+j] = OFFSET + 18 * 2 + 1;
+ break;
+ case 'U':
+ disp_tile[i] = OFFSET + 19 * 2;
+ disp_tile[i+j] = OFFSET + 19 * 2 + 1;
+ break;
+ case 'G':
+ disp_tile[i] = OFFSET + 20 * 2;
+ disp_tile[i+j] = OFFSET + 20 * 2 + 1;
+ break;
+ case '-':
+ disp_tile[i] = OFFSET + 21 * 2;
+ disp_tile[i+j] = OFFSET + 21 * 2 + 1;
+ break;
+ case 'T':
+ disp_tile[i] = OFFSET + 22 * 2;
+ disp_tile[i+j] = OFFSET + 22 * 2 + 1;
+ break;
+ case ',':
+ disp_tile[i] = OFFSET + 23 * 2;
+ disp_tile[i+j] = OFFSET + 23 * 2 + 1;
+ break;
+ case 'F':
+ disp_tile[i] = OFFSET + 24 * 2;
+ disp_tile[i+j] = OFFSET + 24 * 2 + 1;
+ break;
+ case 'S':
+ disp_tile[i] = OFFSET + ('5' - '0') * 2;
+ disp_tile[i+j] = OFFSET + ('5' - '0') * 2 + 1;
+ break;
+ }
+ i++;
+ }
+}
+
+/* clear display */
+void clr_disp()
+{
+ set_bkg_data(OFFSET, 50, dtmf_lcd);
+ set_bkg_tiles(LCD_X, LCD_Y, LCD_WIDTH, LCD_HIGHT, init_disp);
+}
+
+/*
+ CAUTION: Don't display the NULL code
+*/
+void disp(const char *str)
+{
+ uint8_t no, left_pos;
+ uint8_t i, start_ch, end_ch;
+ char work[MAX_DTMF];
+
+ clr_disp();
+
+ no = 0;
+ while(str[no]){
+ no++;
+ }
+
+ if(no >= LCD_WIDTH){
+ start_ch = no - LCD_WIDTH;
+ end_ch = LCD_WIDTH;
+ }
+ else{
+ start_ch = 0;
+ end_ch = no;
+ }
+ for(i = 0;i < end_ch;i++){
+ work[i] = str[i+start_ch];
+ }
+ work[end_ch] = 0x00;
+
+ disp_lcd(end_ch, work);
+
+ left_pos = 19 - end_ch;
+ set_bkg_tiles(left_pos, 2, end_ch, LCD_HIGHT, disp_tile);
+}
+
+void press_button(uint8_t x, uint8_t y)
+{
+ if(x <= 3 && y <= 3){
+ set_bkg_tiles(x * 3 + 1, y * 3 + 5, 3, 3, press_tile);
+ }
+ if((x == 4 || x == 5) && (y <= 2)){
+ set_bkg_tiles(x * 3 + 2, y * 3 + 5, 3, 3, press_tile);
+ }
+ if((x == 4 || x == 5) && (y == 3)){
+ set_bkg_tiles(14, 14, 6, 3, dialing_press);
+ }
+}
+
+void break_button(uint8_t x, uint8_t y)
+{
+ if(x <= 3 && y <= 3){
+ set_bkg_tiles(x * 3 + 1, y * 3 + 5, 3, 3, break_tile);
+ }
+ if((x == 4 || x == 5) && (y <= 2)){
+ set_bkg_tiles(x * 3 + 2, y * 3 + 5, 3, 3, break_tile);
+ }
+ if((x == 4 || x == 5) && (y == 3)){
+ set_bkg_tiles(14, 14, 6, 3, dialing_break);
+ }
+}
+
+
+void init_key()
+{
+ uint8_t key_x, key_y, i;
+
+ /* To make numeric KeyPad */
+ set_sprite_data(0, 24, key_num);
+
+ /* key pad 1 - 3 */
+ key_y = KEY_STEP + 40;
+ for(i = 1;i <= 3;i++){
+ key_x = i * KEY_STEP;
+ set_sprite_tile(i, i);
+ move_sprite(i, key_x, key_y);
+ }
+
+ /* key pad 4 - 6 */
+ key_y = KEY_STEP * 2 + 40;
+ for(i = 4;i <= 6;i++){
+ key_x = (i - 3) * KEY_STEP;
+ set_sprite_tile(i, i);
+ move_sprite(i, key_x, key_y);
+ }
+
+ /* key pad 7 - 9 */
+ key_y = KEY_STEP * 3 + 40;
+ for(i = 7;i <= 9;i++){
+ key_x = (i - 6) * KEY_STEP;
+ set_sprite_tile(i, i);
+ move_sprite(i, key_x, key_y);
+ }
+
+ /* key pad 'A' - 'D' */
+ key_x = KEY_STEP * 4;
+ for(i = 0;i <= 3;i++){
+ key_y = (i+1) * KEY_STEP + 40;
+ set_sprite_tile(i+10, i+10);
+ move_sprite(i+10, key_x, key_y);
+ }
+
+ /* key pad '*', '0', '#' */
+ set_sprite_tile(15, 15);
+ move_sprite(15, KEY_STEP * 1, KEY_STEP * 4 + 40U);
+ set_sprite_tile(0, 0);
+ move_sprite(0, KEY_STEP * 2, KEY_STEP * 4 + 40U);
+ set_sprite_tile(14, 14);
+ move_sprite(14, KEY_STEP * 3, KEY_STEP * 4 + 40U);
+
+ /* func left */
+ key_x = KEY_STEP * 5 + 8U;
+ for(i = 0;i <= 2;i++){
+ key_y = (i+1) * KEY_STEP + 40;
+ set_sprite_tile(i+16, i+16);
+ move_sprite(i+16, key_x, key_y);
+ }
+
+ /* func right */
+ key_x = KEY_STEP * 6 + 8U;
+ for(i = 0;i <= 2;i++){
+ key_y = (i+1) * KEY_STEP + 40;
+ set_sprite_tile(i+19, i+19);
+ move_sprite(i+19, key_x, key_y);
+ }
+
+ /* dialing button */
+ key_x = KEY_STEP * 5 + 20U;
+ key_y = KEY_STEP * 4 + 40U;
+ set_sprite_tile(22, 22);
+ move_sprite(22, key_x, key_y);
+}
+
+void init_background()
+{
+ /* Initialize the background */
+ set_bkg_data( 0, 9, frame_lcd);
+ set_bkg_data( 9, 9, break_btn);
+ set_bkg_data(18, 9, press_btn);
+
+ set_bkg_tiles(0, 0, 20, 18, dtmf_tile);
+}
+
+void init_cursor()
+{
+ uint8_t i;
+
+ /* Setup the cursor data*/
+ set_sprite_data(23, 8, cursor_data);
+
+ for(i = 23;i <= 30;i++){
+ set_sprite_tile(i, i);
+ }
+}
+
+void move_cursor(uint8_t x, uint8_t y)
+{
+ move_sprite(23, x, y);
+ move_sprite(24, x, y+8);
+ move_sprite(25, x+8, y);
+ move_sprite(26, x+8, y+8);
+}
+
+void main()
+{
+ uint8_t key1, key2, i, j, pos_x, pos_y, ch_pos;
+ uint8_t non_flick = OFF;
+ uint16_t on_time, off_time;
+
+ char str[MAX_DTMF];
+ char str_ms[10];
+
+ /* PENDING: sdcc is broken and needs this to be initalised. */
+ key2 = 0;
+
+ /* default dialling time setting */
+ on_time = DTMF_ON;
+ off_time = DTMF_OFF;
+
+ disable_interrupts();
+
+ SPRITES_8x8; /* sprites are 8x8 */
+
+ init_dial();
+
+ init_background();
+
+ init_key();
+
+ init_cursor();
+
+ disp(TITLE);
+
+ SHOW_BKG;
+ SHOW_SPRITES;
+ DISPLAY_ON;
+
+ enable_interrupts();
+
+ i = j = 0;
+
+ ch_pos = 0;
+
+ while(1) {
+ wait_vbl_done();
+ key1 = joypad();
+
+ if(key1 != key2){
+ pos_x = i * KEY_STEP + START_CURSOR_X;
+ pos_y = j * KEY_STEP + START_CURSOR_Y;
+ move_cursor(pos_x, pos_y);
+ }
+
+ if(key2 & J_A){
+ if(key1 & J_A){
+ /* value set for each sound reg only numeric key pad*/
+ if(i <= 3 && j <= 3){
+ /* frequncy register set up for DTMF */
+ NR13_REG = row[i];
+ NR23_REG = col[j];
+ NR24_REG = 0x87U;
+
+ /* sound output on */
+ NR51_REG = 0x33U;
+ }
+
+ /* '?' button */
+ /* appear the title during press A button */
+ if(i == 5 && j == 0 && !non_flick){
+ disp(TITLE);
+ non_flick = ON;
+ }
+
+ /* incremental button */
+ /* decremental button */
+ /* appear the delay during press A button */
+ if(i == 5 && (j == 1 || j == 2) && !non_flick){
+ sprintf(str_ms, "%u MS", on_time);
+ disp(str_ms);
+ non_flick = ON;
+ }
+ }
+ else{
+ /* sound output off */
+ NR51_REG = 0x00U;
+
+ break_button(i, j);
+
+ /* '?' button */
+ /* incremental button */
+ /* decremental button */
+ /* return to normal display at release the A button */
+ if(i == 5 && (j == 0 || j == 1 || j == 2)){
+ non_flick = OFF;
+ if(ch_pos == 0)
+ clr_disp();
+ else
+ disp(str);
+ }
+ }
+ }
+ else{
+ if(key1 & J_A){
+ /* button display handle */
+ press_button(i, j);
+
+ /* numeric key pad handling */
+ if(i <= 3 && j <= 3){
+ /* string length check */
+ if(ch_pos < MAX_DTMF-1){
+ str[ch_pos] = pad[j][i];
+ ch_pos++;
+ str[ch_pos] = 0x00;
+ disp(str);
+ }
+ }
+
+ /* ',' button */
+ if(i == 4 && j == 2){
+ /* string length check */
+ if(ch_pos < MAX_DTMF-1){
+ str[ch_pos] = pad[j][i];
+ ch_pos++;
+ str[ch_pos] = 0x00;
+ disp(str);
+ }
+ }
+
+ /* all clear button */
+ if(i == 4 && j == 0){
+ ch_pos = 0x00;
+ strcpy(str,"");
+ clr_disp();
+ }
+
+ /* delete button */
+ if(i == 4 && j == 1){
+ if(ch_pos > 0){
+ ch_pos--;
+ str[ch_pos] = 0x00;
+ if(ch_pos == 0)
+ clr_disp();
+ else
+ disp(str);
+ }
+ }
+
+ /* incremental button */
+ if(i == 5 && j == 1){
+ if(on_time >= DTMF_ON / 2){
+ on_time = on_time - 10;
+ off_time = off_time - 10;
+ }
+ }
+
+ /* decremental button */
+ if(i == 5 && j == 2){
+ if(on_time <= DTMF_ON * 2){
+ on_time = on_time + 10;
+ off_time = off_time + 10;
+ }
+ }
+
+ /* dialing button */
+ if((i==4 || i==5) && j==3){
+ dialtone(on_time, off_time, str);
+ }
+ }
+ }
+ if(!(key1 & J_A)){
+ if((key1 & J_UP) && !(key2 & J_UP) && j > 0)
+ j--;
+ else if((key1 & J_DOWN) && !(key2 & J_DOWN) && j < 3)
+ j++;
+
+ if((key1 & J_LEFT) && !(key2 & J_LEFT) && i > 0)
+ i--;
+ else if((key1 & J_RIGHT) && !(key2 & J_RIGHT) && i < 5)
+ i++;
+ }
+ key2 = key1;
+ }
+}
diff --git a/gbdk/gbdk-lib/examples/ap/gb-dtmf/key_num.c b/gbdk/gbdk-lib/examples/ap/gb-dtmf/key_num.c
new file mode 100644
index 00000000..efc56276
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/gb-dtmf/key_num.c
@@ -0,0 +1,69 @@
+/*
+
+ KEY_NUM.C
+
+ Tile Source File.
+
+ Info:
+ Form : All tiles as one unit.
+ Format : Gameboy 4 color.
+ Counter : None.
+ Tile size : 8 x 8
+ Tiles : 0 to 22
+
+ This file was generated by GBTD v0.5
+
+*/
+
+/* Start of tile array. */
+const unsigned char key_num[] =
+{
+ 0xFF,0x3C,0xFF,0x7E,0xFF,0x66,0xFF,0x66,
+ 0xFF,0x66,0xFF,0x66,0xFF,0x7E,0xFF,0x3C,
+ 0xFF,0x18,0xFF,0x38,0xFF,0x38,0xFF,0x18,
+ 0xFF,0x18,0xFF,0x18,0xFF,0x18,0xFF,0x18,
+ 0xFF,0x3C,0xFF,0x66,0xFF,0x6E,0xFF,0x1C,
+ 0xFF,0x38,0xFF,0x70,0xFF,0x7E,0xFF,0x7E,
+ 0xFF,0x7C,0xFF,0x7E,0xFF,0x06,0xFF,0x3E,
+ 0xFF,0x3E,0xFF,0x06,0xFF,0x7E,0xFF,0x7C,
+ 0xFF,0x0C,0xFF,0x1C,0xFF,0x3C,0xFF,0x6C,
+ 0xFF,0x6E,0xFF,0x7E,0xFF,0x0C,0xFF,0x0C,
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x7C,0x3C,0x3C,0x1C,0x1C,0x0C,0x0C,
+ 0x00,0x00,0x18,0x18,0x3C,0x3C,0x3C,0x3C,
+ 0x1C,0x1C,0x0C,0x0C,0x38,0x38,0x00,0x00,
+ 0x3C,0x3C,0x42,0x42,0x02,0x02,0x1C,0x1C,
+ 0x18,0x18,0x00,0x00,0x18,0x18,0x18,0x18,
+ 0x00,0x00,0x18,0x18,0x3C,0x3C,0x7E,0x7E,
+ 0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,
+ 0x7E,0x7E,0x3C,0x3C,0x18,0x18,0x00,0x00,
+ 0x12,0x12,0x34,0x34,0xF1,0xF1,0xF2,0xF2,
+ 0xF2,0xF2,0xF1,0xF1,0x34,0x34,0x12,0x12
+};
+
+/* End of KEY_NUM.C */
diff --git a/gbdk/gbdk-lib/examples/ap/gb-dtmf/key_num.gbr b/gbdk/gbdk-lib/examples/ap/gb-dtmf/key_num.gbr
new file mode 100644
index 00000000..3e075a62
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/gb-dtmf/key_num.gbr
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/ap/gb-dtmf/prs_btn.c b/gbdk/gbdk-lib/examples/ap/gb-dtmf/prs_btn.c
new file mode 100644
index 00000000..ea87af4f
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/gb-dtmf/prs_btn.c
@@ -0,0 +1,41 @@
+/*
+
+ PRESS_BTN.C
+
+ Tile Source File.
+
+ Info:
+ Form : All tiles as one unit.
+ Format : Gameboy 4 color.
+ Counter : None.
+ Tile size : 8 x 8
+ Tiles : 0 to 8
+
+ This file was generated by GBTD v0.5
+
+*/
+
+/* Start of tile array. */
+const unsigned char press_btn[] =
+{
+ 0x00,0xFF,0x00,0xFF,0x3F,0xC0,0x3F,0xC0,
+ 0x3F,0xC0,0x3F,0xC0,0x3F,0xC0,0x3F,0xC0,
+ 0x00,0xFF,0x00,0xFF,0xFF,0x00,0xFF,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0x00,0xFE,0x00,0xFC,0xFC,0x00,0xFC,0x00,
+ 0xFC,0x00,0xFC,0x00,0xFC,0x00,0xFC,0x00,
+ 0x3F,0xC0,0x3F,0xC0,0x3F,0xC0,0x3F,0xC0,
+ 0x3F,0xC0,0x3F,0xC0,0x3F,0xC0,0x3F,0xC0,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0xFC,0x00,0xFC,0x00,0xFC,0x00,0xFC,0x00,
+ 0xFC,0x00,0xFC,0x00,0xFC,0x00,0xFC,0x00,
+ 0x3F,0xC0,0x3F,0xC0,0x3F,0xC0,0x3F,0xC0,
+ 0x3F,0xC0,0x3F,0xC0,0x00,0xC0,0x00,0x80,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0xFF,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,
+ 0xFC,0x00,0xFC,0x00,0xFC,0x00,0xFC,0x00,
+ 0xFC,0x00,0xFC,0x00,0x00,0x00,0x00,0x00
+};
+
+/* End of PRESS_BTN.C */
diff --git a/gbdk/gbdk-lib/examples/ap/gb-dtmf/prs_btn.gbr b/gbdk/gbdk-lib/examples/ap/gb-dtmf/prs_btn.gbr
new file mode 100644
index 00000000..28423a7d
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/gb-dtmf/prs_btn.gbr
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/ap/gbdecompress/Makefile b/gbdk/gbdk-lib/examples/ap/gbdecompress/Makefile
new file mode 100644
index 00000000..ab99e273
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/gbdecompress/Makefile
@@ -0,0 +1,33 @@
+#
+# Simple Makefile that compiles all .c and .s files in the same folder
+#
+
+# If you move this project you can change the directory
+# to match your GBDK root directory (ex: GBDK_HOME = "C:/GBDK/"
+GBDK_HOME = ../../../
+
+LCC = $(GBDK_HOME)bin/lcc -msm83:ap -Wl-j -Wm-yS
+
+# You can uncomment the line below to turn on debug output
+# LCC = $(LCC) -debug
+
+# You can set the name of the .pocket ROM file here
+PROJECTNAME = gbdecompress
+
+BINS = $(PROJECTNAME).pocket
+CSOURCES := $(wildcard *.c)
+ASMSOURCES := $(wildcard *.s)
+
+all: $(BINS)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+# Compile and link all source files in a single call to LCC
+$(BINS): $(CSOURCES) $(ASMSOURCES)
+ $(LCC) -o $@ $(CSOURCES) $(ASMSOURCES)
+
+clean:
+ rm -f *.o *.lst *.map *.pocket *.ihx *.sym *.cdb *.adb *.asm *.noi
+
diff --git a/gbdk/gbdk-lib/examples/ap/gbdecompress/Readme.md b/gbdk/gbdk-lib/examples/ap/gbdecompress/Readme.md
new file mode 100644
index 00000000..7f21a65e
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/gbdecompress/Readme.md
@@ -0,0 +1,8 @@
+
+GBDecompress
+============
+
+Demonstrates using gbdecompress to load a compressed tile set into vram.
+
+The tileset was compressed during export from GBTD by checking the
+GB-compress checkbox in the export settings panel.
diff --git a/gbdk/gbdk-lib/examples/ap/gbdecompress/main.c b/gbdk/gbdk-lib/examples/ap/gbdecompress/main.c
new file mode 100644
index 00000000..e81d81f9
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/gbdecompress/main.c
@@ -0,0 +1,41 @@
+#include <gb/gb.h>
+#include <stdint.h>
+#include <gb/gbdecompress.h>
+#include <stdbool.h>
+
+// Include graphics data
+#include "monalisa_tiles_comp.h"
+#include "monalisa_map.h"
+
+// The map tiles were exported from GBTD with compression enabled
+// using this updated version of GBTD: https://github.com/untoxa/GBTD_GBMB
+// Size was 4096 bytes -> 3493 bytes
+
+void main(void)
+{
+ // Decompress the map tiles into the background tile vram.
+ //
+ // Notice that the number of tiles isn't specified. The amount
+ // of data to decompress is embedded in the compressed data.
+ //
+ // Note: For non-compressed data the equivalent would be: set_bkg_data(0, 253u, monalisa_tiles)
+ //
+ gb_decompress_bkg_data(0, monalisa_tiles_comp); // first tile, pointer to comrpessed data
+
+ // Now set the map and turn the background on
+ set_bkg_tiles(0,0, monalisa_mapWidth, monalisa_mapHeight, monalisa_mapPLN0);
+ SHOW_BKG;
+
+ // Loop forever
+ while(1) {
+
+ // Main loop processing goes here
+
+ // Done processing, yield CPU and wait for start of next frame
+ wait_vbl_done();
+ }
+}
+
+
+
+
diff --git a/gbdk/gbdk-lib/examples/ap/gbdecompress/monalisa.gbm b/gbdk/gbdk-lib/examples/ap/gbdecompress/monalisa.gbm
new file mode 100644
index 00000000..a21dfeeb
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/gbdecompress/monalisa.gbm
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/ap/gbdecompress/monalisa_map.c b/gbdk/gbdk-lib/examples/ap/gbdecompress/monalisa_map.c
new file mode 100644
index 00000000..c110ae15
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/gbdecompress/monalisa_map.c
@@ -0,0 +1,66 @@
+/*
+
+ MONALISA_MAP.C
+
+ Map Source File.
+
+ Info:
+ Section :
+ Bank : 0
+ Map size : 20 x 18
+ Tile set : monalisa_tiles.gbr
+ Plane count : 1 plane (8 bits)
+ Plane order : Planes are continues
+ Tile offset : 0
+ Split data : No
+
+ This file was generated by GBMB v1.8
+
+*/
+
+#define monalisa_mapWidth 20
+#define monalisa_mapHeight 18
+#define monalisa_mapBank 0
+
+#define monalisa_map monalisa_mapPLN0
+const unsigned char monalisa_mapPLN0[] =
+{
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02,
+ 0x03,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x06,0x07,
+ 0x08,0x09,0x0A,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x0B,0x0C,0x0D,0x0E,
+ 0x0F,0x10,0x11,0x12,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x13,0x14,0x00,0x00,0x00,0x00,0x15,0x16,0x00,0x17,
+ 0x18,0x19,0x1A,0x1B,0x1C,0x13,0x00,0x00,0x00,0x00,
+ 0x1D,0x1E,0x1F,0x20,0x21,0x00,0x22,0x23,0x24,0x25,
+ 0x26,0x27,0x1A,0x28,0x29,0x2A,0x2B,0x00,0x00,0x00,
+ 0x2C,0x2D,0x2E,0x2F,0x30,0x31,0x32,0x33,0x34,0x35,
+ 0x36,0x37,0x1A,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,
+ 0x3F,0x40,0x41,0x41,0x42,0x43,0x44,0x45,0x46,0x47,
+ 0x48,0x49,0x1A,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F,0x50,
+ 0x51,0x52,0x41,0x53,0x54,0x55,0x56,0x57,0x58,0x59,
+ 0x5A,0x5B,0x1A,0x1A,0x5C,0x5D,0x5E,0x5F,0x60,0x61,
+ 0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x1A,0x69,0x6A,
+ 0x6B,0x6C,0x1A,0x1A,0x6D,0x6E,0x6F,0x70,0x71,0x72,
+ 0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x1A,0x7A,0x7B,
+ 0x7C,0x7D,0x7E,0x1A,0x7F,0x80,0x81,0x82,0x83,0x84,
+ 0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,
+ 0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,
+ 0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,0xA0,0xA1,0x00,
+ 0x00,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,
+ 0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0x00,0x00,
+ 0x00,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,
+ 0xBC,0xBD,0xBE,0xBF,0xC0,0x1A,0xC1,0xC2,0xC3,0x00,
+ 0xC4,0xC5,0xC6,0xC7,0x1A,0x1A,0x1A,0xC8,0xC9,0xCA,
+ 0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,
+ 0xD5,0xD6,0x1A,0x1A,0xD7,0xD8,0x1A,0xD9,0xDA,0xDB,
+ 0xDC,0xDD,0xDE,0xDF,0x1A,0xE0,0xE1,0xE2,0xE3,0xE4,
+ 0xE5,0x1A,0x1A,0xE6,0xE7,0xE8,0x1A,0xE9,0xEA,0xEB,
+ 0xEC,0xED,0xEE,0xEF,0xF0,0x1A,0x1A,0x1A,0xF1,0xF2,
+ 0x1A,0x1A,0x1A,0xF3,0xF4,0x1A,0x1A,0x1A,0xF5,0xF6,
+ 0xF7,0xF8,0xF9,0xFA,0xFB,0x1A,0x1A,0x1A,0x1A,0x1A,
+ 0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0xFC
+};
+
+/* End of MONALISA_MAP.C */
diff --git a/gbdk/gbdk-lib/examples/ap/gbdecompress/monalisa_map.h b/gbdk/gbdk-lib/examples/ap/gbdecompress/monalisa_map.h
new file mode 100644
index 00000000..f094a2d3
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/gbdecompress/monalisa_map.h
@@ -0,0 +1,32 @@
+/*
+
+ MONALISA_MAP.H
+
+ Map Include File.
+
+ Info:
+ Section :
+ Bank : 0
+ Map size : 20 x 18
+ Tile set : monalisa_tiles.gbr
+ Plane count : 1 plane (8 bits)
+ Plane order : Planes are continues
+ Tile offset : 0
+ Split data : No
+
+ This file was generated by GBMB v1.8
+
+*/
+#ifndef __monalisa_map_h_INCLUDE
+#define __monalisa_map_h_INCLUDE
+
+#define monalisa_mapWidth 20
+#define monalisa_mapHeight 18
+#define monalisa_mapBank 0
+
+#define monalisa_map monalisa_mapPLN0
+extern const unsigned char monalisa_mapPLN0[];
+
+#endif
+
+/* End of MONALISA_MAP.H */
diff --git a/gbdk/gbdk-lib/examples/ap/gbdecompress/monalisa_tiles.gbr b/gbdk/gbdk-lib/examples/ap/gbdecompress/monalisa_tiles.gbr
new file mode 100644
index 00000000..821f2928
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/gbdecompress/monalisa_tiles.gbr
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/ap/gbdecompress/monalisa_tiles_comp.c b/gbdk/gbdk-lib/examples/ap/gbdecompress/monalisa_tiles_comp.c
new file mode 100644
index 00000000..37aae936
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/gbdecompress/monalisa_tiles_comp.c
@@ -0,0 +1,467 @@
+/*
+
+ MONALISA_TILES_COMP.C
+
+ Tile Source File.
+
+ Info:
+ Form : All tiles as one unit.
+ Format : Gameboy 4 color.
+ Compression : GB-Compress.
+ Counter : None.
+ Tile size : 8 x 8
+ Tiles : 0 to 252
+
+ Palette colors : Included.
+ SGB Palette : None.
+ CGB Palette : None.
+
+ Convert to metatiles : No.
+
+ This file was generated by GBTD v2.2
+
+*/
+
+/* Start of tile array. */
+const unsigned char monalisa_tiles_comp[] =
+{
+ 0x1D,0x00,0xC1,0x02,0x01,0x8B,0xE0,0xFF,
+ 0xC3,0x10,0x2F,0x11,0xFF,0x8B,0xD0,0xFF,
+ 0xC2,0x0D,0xF2,0x54,0x8C,0xF0,0xFF,0xC2,
+ 0x00,0x00,0xE0,0x89,0xB1,0xFF,0xE9,0x01,
+ 0x02,0x01,0x02,0x07,0x08,0x07,0x02,0x0F,
+ 0x20,0x1F,0x6A,0x3F,0x82,0x7D,0xA1,0xFE,
+ 0xAB,0x54,0x01,0xFE,0xAF,0x50,0xAF,0xFF,
+ 0x0D,0xFF,0x2F,0xFF,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4,0x0D,0xFF,0xBF,0xFF,0x15,0x8A,0x28,
+ 0xF7,0x85,0xF8,0xFD,0xC6,0xFF,0xFF,0xED,
+ 0xFF,0xFF,0xFF,0x50,0x86,0x88,0xFF,0x83,
+ 0x64,0xF5,0xC6,0x81,0xFF,0xFE,0xFF,0x01,
+ 0xFF,0xA2,0x84,0x4C,0xF8,0xC2,0x50,0xFF,
+ 0xEA,0x83,0xFC,0xFF,0xC2,0xFF,0xD0,0xFF,
+ 0x00
+};
+
+/* End of MONALISA_TILES_COMP.C */
diff --git a/gbdk/gbdk-lib/examples/ap/gbdecompress/monalisa_tiles_comp.h b/gbdk/gbdk-lib/examples/ap/gbdecompress/monalisa_tiles_comp.h
new file mode 100644
index 00000000..747d28ca
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/gbdecompress/monalisa_tiles_comp.h
@@ -0,0 +1,107 @@
+/*
+
+ MONALISA_TILES_COMP.H
+
+ Include File.
+
+ Info:
+ Form : All tiles as one unit.
+ Format : Gameboy 4 color.
+ Compression : GB-Compress.
+ Counter : None.
+ Tile size : 8 x 8
+ Tiles : 0 to 252
+
+ Palette colors : Included.
+ SGB Palette : None.
+ CGB Palette : None.
+
+ Convert to metatiles : No.
+
+ This file was generated by GBTD v2.2
+
+*/
+
+#ifndef __monalisa_tiles_comp_h_INCLUDE
+#define __monalisa_tiles_comp_h_INCLUDE
+
+/* Bank of tiles. */
+#define monalisa_tiles_compBank 0
+
+/* Super Gameboy palette 0 */
+#define monalisa_tiles_compSGBPal0c0 0
+#define monalisa_tiles_compSGBPal0c1 0
+#define monalisa_tiles_compSGBPal0c2 18432
+#define monalisa_tiles_compSGBPal0c3 749
+
+/* Super Gameboy palette 1 */
+#define monalisa_tiles_compSGBPal1c0 6076
+#define monalisa_tiles_compSGBPal1c1 8935
+#define monalisa_tiles_compSGBPal1c2 6596
+#define monalisa_tiles_compSGBPal1c3 5344
+
+/* Super Gameboy palette 2 */
+#define monalisa_tiles_compSGBPal2c0 6076
+#define monalisa_tiles_compSGBPal2c1 8935
+#define monalisa_tiles_compSGBPal2c2 6596
+#define monalisa_tiles_compSGBPal2c3 5344
+
+/* Super Gameboy palette 3 */
+#define monalisa_tiles_compSGBPal3c0 6076
+#define monalisa_tiles_compSGBPal3c1 8935
+#define monalisa_tiles_compSGBPal3c2 6596
+#define monalisa_tiles_compSGBPal3c3 5344
+
+/* Gameboy Color palette 0 */
+#define monalisa_tiles_compCGBPal0c0 4228
+#define monalisa_tiles_compCGBPal0c1 11627
+#define monalisa_tiles_compCGBPal0c2 20083
+#define monalisa_tiles_compCGBPal0c3 30653
+
+/* Gameboy Color palette 1 */
+#define monalisa_tiles_compCGBPal1c0 6076
+#define monalisa_tiles_compCGBPal1c1 8935
+#define monalisa_tiles_compCGBPal1c2 6596
+#define monalisa_tiles_compCGBPal1c3 5344
+
+/* Gameboy Color palette 2 */
+#define monalisa_tiles_compCGBPal2c0 6076
+#define monalisa_tiles_compCGBPal2c1 8935
+#define monalisa_tiles_compCGBPal2c2 6596
+#define monalisa_tiles_compCGBPal2c3 5344
+
+/* Gameboy Color palette 3 */
+#define monalisa_tiles_compCGBPal3c0 6076
+#define monalisa_tiles_compCGBPal3c1 8935
+#define monalisa_tiles_compCGBPal3c2 6596
+#define monalisa_tiles_compCGBPal3c3 5344
+
+/* Gameboy Color palette 4 */
+#define monalisa_tiles_compCGBPal4c0 6076
+#define monalisa_tiles_compCGBPal4c1 8935
+#define monalisa_tiles_compCGBPal4c2 6596
+#define monalisa_tiles_compCGBPal4c3 5344
+
+/* Gameboy Color palette 5 */
+#define monalisa_tiles_compCGBPal5c0 6076
+#define monalisa_tiles_compCGBPal5c1 8935
+#define monalisa_tiles_compCGBPal5c2 6596
+#define monalisa_tiles_compCGBPal5c3 5344
+
+/* Gameboy Color palette 6 */
+#define monalisa_tiles_compCGBPal6c0 6076
+#define monalisa_tiles_compCGBPal6c1 8935
+#define monalisa_tiles_compCGBPal6c2 6596
+#define monalisa_tiles_compCGBPal6c3 5344
+
+/* Gameboy Color palette 7 */
+#define monalisa_tiles_compCGBPal7c0 6076
+#define monalisa_tiles_compCGBPal7c1 8935
+#define monalisa_tiles_compCGBPal7c2 6596
+#define monalisa_tiles_compCGBPal7c3 5344
+/* Start of tile array. */
+extern const unsigned char monalisa_tiles_comp[];
+
+#endif
+
+/* End of MONALISA_TILES_COMP.H */
diff --git a/gbdk/gbdk-lib/examples/ap/irq/Makefile b/gbdk/gbdk-lib/examples/ap/irq/Makefile
new file mode 100644
index 00000000..1524389d
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/irq/Makefile
@@ -0,0 +1,17 @@
+CC = ../../../bin/lcc -msm83:ap -Wl-j -Wm-yS
+
+BINS = irq.pocket
+
+all: $(BINS)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+# Compile and link single file in one pass
+%.pocket: %.c
+ $(CC) -o $@ $<
+
+clean:
+ rm -f *.o *.lst *.map *.pocket *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi
+
diff --git a/gbdk/gbdk-lib/examples/ap/irq/irq.c b/gbdk/gbdk-lib/examples/ap/irq/irq.c
new file mode 100644
index 00000000..1dede704
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/irq/irq.c
@@ -0,0 +1,62 @@
+#include <gb/gb.h>
+#include <gbdk/console.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+
+// counters are 16-bit so we need a mutual exclusion access
+unsigned int vbl_cnt, tim_cnt;
+
+void vbl()
+{
+ // Upon IRQ, interrupts are automatically disabled
+ vbl_cnt++;
+}
+
+void tim()
+{
+ // Upon IRQ, interrupts are automatically disabled
+ tim_cnt++;
+}
+
+void print_counter()
+{
+ unsigned int cnt;
+
+ // Ensure mutual exclusion
+ CRITICAL {
+ cnt = tim_cnt;
+ }
+
+ printf(" TIM %u", cnt);
+ gotoxy(9, posy());
+
+ // Ensure mutual exclusion
+ CRITICAL {
+ cnt = vbl_cnt;
+ }
+
+ printf("- VBL %u\n", cnt);
+}
+
+void main()
+{
+ // Ensure mutual exclusion
+ CRITICAL {
+ vbl_cnt = tim_cnt = 0;
+ add_VBL(vbl);
+ add_TIM(tim);
+ }
+
+ // Set TMA to divide clock by 0x100
+ TMA_REG = 0x00U;
+ // Set clock to 4096 Hertz
+ TAC_REG = 0x04U;
+ // Handle VBL and TIM interrupts
+ set_interrupts(VBL_IFLAG | TIM_IFLAG);
+
+ while(1) {
+ print_counter();
+ delay(1000UL);
+ }
+}
diff --git a/gbdk/gbdk-lib/examples/ap/large_map/Makefile b/gbdk/gbdk-lib/examples/ap/large_map/Makefile
new file mode 100644
index 00000000..c8303a1d
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/large_map/Makefile
@@ -0,0 +1,11 @@
+CC = ../../../bin/lcc -msm83:ap -Wl-j -Wm-yS
+
+all:
+ $(CC) -o large_map.pocket large_map.c bigmap_map.c bigmap_tiles.c
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+clean:
+ rm -f *.o *.lst *.map *.pocket *.ihx *.sym *.cdb *.adb *.asm
diff --git a/gbdk/gbdk-lib/examples/ap/large_map/Readme.md b/gbdk/gbdk-lib/examples/ap/large_map/Readme.md
new file mode 100644
index 00000000..5a88c78e
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/large_map/Readme.md
@@ -0,0 +1,14 @@
+
+Large Map
+=========
+
+Shows how to scroll with maps larger than 32 x 32 tiles using set_bkg_submap().
+
+It fills rows and columns at the edges of the visible viewport (of the hardware
+Background Map) with the desired sub-region of the large map as it scrolls.
+
+
+Overworld Map and Tiles are by ArMM1998:
+https://opengameart.org/content/gameboy-tileset
+License(s): CC0
+
diff --git a/gbdk/gbdk-lib/examples/ap/large_map/bigmap_map.c b/gbdk/gbdk-lib/examples/ap/large_map/bigmap_map.c
new file mode 100644
index 00000000..b433c25e
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/large_map/bigmap_map.c
@@ -0,0 +1,1661 @@
+/*
+
+ BIGMAP_MAP.C
+
+ Map Source File.
+
+ Info:
+ Section :
+ Bank : 0
+ Map size : 247 x 66
+ Tile set : bigmap_tiles.gbr
+ Plane count : 1 plane (8 bits)
+ Plane order : Planes are continues
+ Tile offset : 0
+ Split data : No
+
+ This file was generated by GBMB v1.8
+
+*/
+
+#define bigmap_mapWidth 247
+#define bigmap_mapHeight 66
+#define bigmap_mapBank 0
+
+#define bigmap_map bigmap_mapPLN0
+const unsigned char bigmap_mapPLN0[] =
+{
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x03,
+ 0x00,0x01,0x00,0x01,0x04,0x05,0x04,0x05,0x04,0x05,
+ 0x04,0x05,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x06,0x06,0x06,0x06,0x07,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x09,0x06,0x04,0x05,0x06,0x06,0x06,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x02,0x03,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0A,0x0B,0x0A,
+ 0x0B,0x0C,0x0D,0x0C,0x0D,0x0C,0x0D,0x0C,0x0D,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x06,0x06,0x06,0x06,0x0E,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x0F,0x06,
+ 0x0C,0x0D,0x06,0x06,0x06,0x0A,0x0B,0x0A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0x00,0x01,0x00,0x01,0x0A,0x0B,0x06,0x06,
+ 0x06,0x06,0x14,0x15,0x16,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x09,0x06,0x06,0x04,0x05,
+ 0x06,0x06,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x30,0x3F,0x40,0x41,0x42,0x9B,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x17,0x18,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x0C,
+ 0x0D,0x0C,0x0D,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,
+ 0x06,0x0A,0x0B,0x0A,0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0x00,0x01,0x12,0x13,0x00,0x01,0x00,0x01,
+ 0x02,0x03,0x00,0x01,0x00,0x01,0x12,0x13,0x00,0x01,
+ 0x02,0x03,0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x19,0x1A,0x06,0x06,0x06,0x06,0x19,0x19,
+ 0x00,0x01,0x02,0x03,0x00,0x01,0x12,0x13,0x00,0x01,
+ 0x02,0x03,0x06,0x06,0x02,0x03,0x00,0x01,0x1B,0x1C,
+ 0x1D,0x1E,0x1D,0x1E,0x1D,0x1E,0x1F,0x1F,0x1F,0x1F,
+ 0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x20,0x0B,0x0A,0x0B,
+ 0x06,0x04,0x05,0x06,0x06,0x06,0x06,0x06,0x14,0x15,
+ 0x21,0x22,0x16,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x23,0x21,0x22,0x24,0x25,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x02,0x03,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x02,0x03,0x06,0x06,0x00,0x01,0x02,0x03,
+ 0x00,0x01,0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x12,0x13,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x39,0x14,0x15,
+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B,0x0A,0x0B,0x06,
+ 0x06,0x06,0x06,0x0A,0x0B,0x06,0x06,0x0A,0x0B,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x06,0x3C,0xA5,0xA5,0xA5,0xA5,0xA6,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x00,0x01,0x10,0x11,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x12,0x13,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x1A,0x06,0x06,0x06,0x02,0x03,
+ 0x02,0x03,0x02,0x03,0x00,0x01,0x06,0x2B,0x06,0x06,
+ 0x06,0x06,0x2B,0x06,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x02,0x03,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x02,0x03,0x2C,0x06,0x06,0x06,0x12,0x13,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x2D,0x04,0x05,0x04,0x04,0x04,0x04,0x05,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x14,0x15,0x21,0x22,
+ 0x21,0x22,0x21,0x22,0x21,0x22,0x21,0x22,0x24,0x25,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,
+ 0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x02,0x03,0x02,0x03,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,0x06,0x06,
+ 0x00,0x01,0x12,0x13,0x00,0x01,0x12,0x13,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x03,
+ 0x06,0xD8,0xDB,0xDB,0xDB,0xDB,0xDC,0x06,0x02,0x03,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x0A,
+ 0x0B,0x17,0x18,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x27,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x0A,0x0B,0x06,0x06,0x2E,0x2F,0x2E,0x2F,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x30,
+ 0x06,0x06,0x06,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x31,0x32,0x0C,0x0D,
+ 0x0C,0x0C,0x0C,0x0C,0x0D,0x06,0x06,0x06,0x06,0x06,
+ 0x05,0x04,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x04,
+ 0x05,0x06,0x06,0x04,0x05,0x06,0x06,0x06,0x06,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0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0x04,0x05,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x0C,0x0D,0x04,0x05,
+ 0x0C,0x0D,0x04,0x05,0x06,0x06,0x02,0x03,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x02,0x03,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x02,0x03,0x02,0x03,0x06,0x31,
+ 0x06,0x06,0x02,0x03,0x02,0x03,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x12,0x13,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x02,0x03,0x44,0x45,0x06,0xD8,0x80,0x80,0x80,0x80,
+ 0xB6,0x06,0x06,0x06,0x02,0x03,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x0A,0x0B,0x06,0x06,0x17,0x18,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x06,0x06,0x06,0x06,0x3A,0x26,0x3B,0x06,0x06,
+ 0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x06,0x2F,0x36,
+ 0x36,0x36,0x36,0x2E,0x2F,0x06,0x06,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x29,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x3C,0x3D,0x3E,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x31,
+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0x36,
+ 0x36,0x36,0x1B,0x1C,0x1D,0x1E,0x1D,0x1E,0x1D,0x1E,
+ 0x43,0x06,0x06,0x06,0x06,0x06,0x44,0x45,0x06,0x06,
+ 0x46,0x47,0x2C,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x2D,0x02,
+ 0x03,0x04,0x05,0x04,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x0D,0x0C,0x06,0x06,0x06,0x06,0x06,0x0C,0x0D,
+ 0x06,0x06,0x06,0x06,0x48,0x49,0x4A,0x4B,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x04,0x05,0x04,0x05,
+ 0x06,0x06,0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x02,0x03,0x06,0x06,0x06,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,
+ 0x02,0x03,0x00,0x01,0x00,0x01,0x02,0x03,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x06,
+ 0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,
+ 0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x06,0x44,0x45,0x06,0x06,0x46,
+ 0x80,0x80,0x80,0x80,0xB6,0x06,0x06,0x06,0x44,0x45,
+ 0x02,0x03,0x00,0x01,0x02,0x03,0x00,0x0A,0x0B,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x4C,
+ 0x4D,0x4E,0x4F,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,
+ 0x06,0x06,0x2F,0x36,0x36,0x36,0x36,0x36,0x36,0x29,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x50,0x51,0x06,0x06,0x52,0x53,0x30,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x32,0x06,0x06,0x0C,0x0D,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x3F,0x40,0x54,0x55,0x54,0x55,0x54,0x55,
+ 0x55,0x56,0x57,0x58,0x59,0x55,0x55,0x54,0x55,0x54,
+ 0x55,0x41,0x42,0x0C,0x0D,0x0C,0x0D,0x04,0x05,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x06,0x06,0x06,0x06,0x06,0x12,0x13,0x02,0x03,
+ 0x02,0x03,0x02,0x03,0x12,0x13,0x06,0x06,0x06,0x0A,
+ 0x0B,0x0A,0x0B,0x06,0x31,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x06,0x50,0x51,0x06,0x06,0xDD,0xE1,0xE1,0xE1,
+ 0xE1,0xE2,0x06,0x06,0x31,0x50,0x51,0x06,0x06,0x0A,
+ 0x0B,0x06,0x06,0x0A,0x00,0x01,0x12,0x13,0x06,0x06,
+ 0x06,0x06,0x06,0x5A,0x19,0x19,0x19,0x19,0x1A,0x06,
+ 0x06,0x06,0x3F,0x40,0x54,0x55,0x5B,0x08,0x08,0x5C,
+ 0x02,0x03,0x02,0x03,0x02,0x03,0x06,0x06,0x06,0x35,
+ 0x36,0x36,0x36,0x36,0x36,0x36,0x2C,0x06,0x3F,0x40,
+ 0x54,0x55,0x41,0x42,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x2C,0x06,0x06,0x06,
+ 0x06,0x06,0x5D,0x5E,0x5F,0x60,0x61,0x62,0x06,0x06,
+ 0x06,0x06,0x2D,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x05,0x04,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x4C,
+ 0x4D,0x63,0x64,0x63,0x64,0x63,0x64,0x64,0x65,0x66,
+ 0x67,0x68,0x64,0x64,0x63,0x64,0x63,0x64,0x4E,0x09,
+ 0x06,0x06,0x04,0x05,0x0C,0x0D,0x06,0x06,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x03,0x06,0x31,
+ 0x06,0x06,0x06,0x0A,0x0B,0x06,0xA1,0xA2,0x06,0x06,
+ 0x06,0x0A,0x0B,0x06,0x06,0x06,0x02,0x03,0x02,0x03,
+ 0x06,0x06,0x06,0x06,0x12,0x13,0x12,0x13,0x12,0x13,
+ 0x12,0x13,0x12,0x13,0x06,0x06,0x31,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x02,0x03,0x02,0x03,
+ 0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,0x00,0x01,
+ 0x00,0x01,0x02,0x03,0x02,0x03,0x02,0x03,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x02,0x03,0x00,0x01,0x12,0x13,
+ 0x06,0x06,0x06,0x46,0x81,0x82,0x83,0x80,0xB6,0x06,
+ 0x06,0x06,0x06,0x06,0x44,0x45,0x00,0x01,0x06,0x06,
+ 0x02,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,
+ 0x69,0x26,0x26,0x26,0x26,0x27,0x06,0x06,0x06,0x4C,
+ 0x4D,0x63,0x64,0x6A,0x08,0x08,0x09,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x2F,0x36,0x36,0x36,
+ 0x36,0x36,0x36,0x30,0x06,0x4C,0x4D,0x63,0x64,0x4E,
+ 0x4F,0x06,0x06,0x06,0x6B,0x6C,0x6D,0x6C,0x6D,0x6C,
+ 0x6D,0x6C,0x6D,0x30,0x06,0x06,0x31,0x06,0x06,0x6E,
+ 0x6F,0x70,0x71,0x72,0x73,0x06,0x06,0x06,0x06,0x32,
+ 0x05,0x04,0x06,0x06,0x06,0x05,0x04,0x0D,0x0C,0x05,
+ 0x06,0x06,0x06,0x3F,0x40,0x55,0x5B,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x75,0x76,0x77,0x78,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x79,0x41,0x42,0x0C,
+ 0x0D,0x06,0x04,0x05,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x02,0x03,0x06,0xAF,0xB0,0x06,0x06,0x06,0x02,0x03,
+ 0x06,0x31,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x31,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,
+ 0x52,0x90,0x91,0x92,0x8F,0xC0,0x06,0x06,0x06,0x06,
+ 0x06,0x50,0x51,0x0A,0x0B,0x06,0x06,0x06,0x00,0x01,
+ 0x00,0x01,0x06,0x31,0x06,0x06,0x06,0x7A,0x06,0x06,
+ 0x5D,0x5E,0x5F,0x60,0x7B,0x7C,0x74,0x08,0x08,0x08,
+ 0x7D,0x7E,0x08,0x5C,0x5D,0x5E,0x5F,0x60,0x61,0x62,
+ 0x06,0x06,0x06,0x2F,0x7F,0x36,0x36,0x36,0x1B,0x1C,
+ 0x43,0x06,0x0E,0x08,0x08,0x08,0x08,0x0F,0x06,0x06,
+ 0x06,0x2D,0x80,0x81,0x82,0x83,0x80,0x81,0x80,0x81,
+ 0x2C,0x06,0x06,0x06,0x31,0x06,0x84,0x85,0x86,0x87,
+ 0x08,0x88,0x06,0x06,0x06,0x06,0x2D,0x0D,0x0C,0x04,
+ 0x05,0x06,0x0D,0x0C,0x05,0x04,0x0D,0x06,0x06,0x06,
+ 0x4C,0x4D,0x64,0x6A,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x75,0x76,0x77,0x78,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x89,0x4E,0x4F,0x06,0x06,0x06,0x0C,
+ 0x0D,0x06,0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x03,0x02,0x03,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x12,0x13,
+ 0x12,0x13,0x12,0x13,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x12,0x13,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,
+ 0x06,0x06,0x12,0x13,0x12,0x13,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x31,0x06,0x06,
+ 0x06,0x06,0x02,0x03,0x02,0x03,0x06,0x31,0x06,0x06,
+ 0x06,0x06,0x02,0x03,0x02,0x03,0x02,0x03,0x06,0x06,
+ 0x02,0x03,0x00,0x01,0x12,0x13,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x02,0x03,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x06,
+ 0x06,0x31,0x06,0x06,0x8A,0x06,0x06,0x6E,0x6F,0x70,
+ 0x8B,0x72,0x8C,0x07,0x08,0x08,0x08,0x8D,0x8E,0x08,
+ 0x09,0x6E,0x6F,0x70,0x71,0x72,0x73,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x36,0x36,0x29,0x06,0x06,0x06,0x14,
+ 0x15,0x08,0x08,0x24,0x25,0x06,0x06,0x06,0x32,0x8F,
+ 0x90,0x91,0x92,0x8F,0x90,0x8F,0x90,0x30,0x06,0x06,
+ 0x06,0x06,0x06,0x93,0x94,0x95,0x96,0x97,0x98,0x06,
+ 0x31,0x06,0x06,0x32,0x05,0x04,0x0C,0x0D,0x04,0x05,
+ 0x04,0x0D,0x0C,0x06,0x06,0x06,0x06,0x74,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x75,
+ 0x76,0x77,0x78,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x79,0x41,0x42,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x06,0x31,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0A,
+ 0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0A,
+ 0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x00,0x01,0x00,0x01,0x06,0x06,0x06,0x06,
+ 0x06,0x33,0x34,0x06,0x99,0x08,0x86,0x87,0x9A,0x88,
+ 0x0E,0x08,0x08,0x08,0x08,0x08,0x08,0x0F,0x84,0x85,
+ 0x86,0x87,0x08,0x88,0x06,0x06,0x31,0x06,0x06,0x06,
+ 0x7F,0x36,0x39,0x06,0x06,0x06,0x06,0x9B,0x9C,0x08,
+ 0x39,0x06,0x06,0x06,0x06,0x9B,0x9D,0x06,0x06,0x06,
+ 0x06,0x9E,0x9F,0xA0,0x2C,0x06,0x06,0x06,0x06,0x06,
+ 0xA1,0xA2,0x36,0x36,0x2E,0x06,0x06,0x06,0x06,0x06,
+ 0x2D,0x0D,0x0C,0x06,0x06,0x0C,0x0D,0x0C,0x05,0x04,
+ 0x06,0x06,0x06,0x06,0x0E,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x75,0xA3,0xA4,0x78,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x89,
+ 0x4E,0x4F,0x06,0x06,0x04,0x05,0x06,0x06,0x02,0x03,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x06,0x31,0x06,0x06,0x12,0x13,0x12,0x13,0x06,0x06,
+ 0x31,0x06,0x02,0x03,0x02,0x03,0x02,0x03,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x12,0x13,0x12,0x13,0x12,0x13,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x12,0x13,0x00,0x01,0x00,0x01,
+ 0x12,0x13,0x12,0x13,0x31,0x06,0x06,0x06,0x12,0x13,
+ 0x12,0x13,0x12,0x13,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x02,0x03,0x00,0x01,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x12,0x13,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0A,
+ 0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,0x3A,0x3B,
+ 0x06,0x93,0x94,0x95,0x96,0x97,0x98,0x14,0x15,0x21,
+ 0x22,0x21,0x22,0x24,0x25,0x93,0x94,0x95,0x96,0x97,
+ 0x98,0x31,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x3C,
+ 0x3D,0x6C,0x6D,0xA5,0xA6,0xA7,0xA8,0x3C,0x3D,0xA9,
+ 0xAA,0xA5,0xA6,0xAB,0x06,0x06,0x06,0x06,0xAC,0xAD,
+ 0xAE,0x30,0x06,0x06,0x06,0x06,0x06,0xAF,0xB0,0x36,
+ 0x36,0xB1,0x06,0x31,0x06,0x06,0x06,0x32,0x04,0x05,
+ 0x06,0x06,0x06,0x04,0x05,0x0D,0x0C,0x04,0x06,0x06,
+ 0x06,0x74,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x75,0xB2,0xB3,0x78,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x5C,0x06,
+ 0x06,0x0C,0x0D,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x31,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x12,0x13,0x12,
+ 0x13,0x12,0x13,0x12,0x13,0x0A,0x0B,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x00,0x01,0x02,0x03,
+ 0x06,0x06,0xB4,0xB5,0x5F,0x60,0x61,0x62,0xA1,0xA2,
+ 0x36,0x36,0x2E,0x06,0x12,0x13,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0xA1,0xA2,0x36,0x36,0x2E,0x06,0x06,0x31,
+ 0x06,0x5A,0x19,0x19,0x19,0x19,0x46,0x47,0x80,0x81,
+ 0x80,0xB6,0xB7,0xB8,0x46,0x47,0xB9,0xBA,0x80,0xB6,
+ 0x9D,0x06,0x06,0x06,0x06,0x9E,0x06,0x06,0x2C,0x06,
+ 0x06,0x06,0x12,0x13,0x06,0x35,0x36,0x36,0x2E,0x06,
+ 0x06,0x06,0x06,0x06,0x2D,0x0C,0x0D,0x06,0x06,0x06,
+ 0x0C,0x0D,0x05,0x04,0x0C,0x06,0x06,0x06,0x07,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x23,0xBB,
+ 0xBC,0xA3,0xA4,0xBD,0x22,0x22,0x22,0x16,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x09,0x06,0x04,0x05,0x04,
+ 0x05,0x06,0x06,0x06,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x06,0x06,0x12,0x13,0x00,0x01,
+ 0x00,0x01,0x12,0x13,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x12,0x13,0x12,0x13,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,
+ 0x12,0x13,0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,
+ 0x06,0x06,0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13,
+ 0x12,0x13,0x06,0x06,0x31,0x06,0x12,0x13,0x31,0x06,
+ 0x06,0x06,0x02,0x03,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,
+ 0x0A,0x0B,0x02,0x03,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x12,0x13,0x12,0x0A,0x0B,0x06,0x06,0x06,0x06,0xBE,
+ 0x6F,0x70,0x71,0x72,0x73,0xAF,0xB0,0x36,0x36,0xB1,
+ 0x06,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0xAF,
+ 0xB0,0x36,0x36,0xB1,0x06,0x06,0x06,0x06,0x69,0x26,
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,0x0A,
+ 0x00,0x01,0x06,0x06,0x06,0x06,0x99,0x08,0x86,0x87,
+ 0x08,0x88,0x06,0x35,0x36,0x36,0x2E,0x06,0x02,0x03,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x35,0x36,0x36,
+ 0x2E,0x06,0x44,0x45,0x06,0x2B,0x3F,0x40,0x54,0x55,
+ 0x54,0x55,0x54,0x55,0x54,0x55,0xC9,0xCA,0x41,0x42,
+ 0x06,0x06,0x44,0x45,0x9D,0x06,0x06,0x06,0x06,0x9E,
+ 0x06,0x06,0x2C,0x06,0x06,0x06,0x02,0x03,0x06,0x35,
+ 0x36,0x36,0x2E,0x06,0x06,0x06,0x06,0x06,0x2D,0x06,
+ 0x06,0x06,0x06,0x06,0x0C,0x0D,0x05,0x04,0x04,0x06,
+ 0x06,0x06,0x74,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x09,0x06,0x31,0x06,0x31,0x06,0x31,0x06,
+ 0x06,0x07,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x09,
+ 0x06,0x06,0x04,0x05,0x06,0x06,0x06,0x06,0x00,0x01,
+ 0x00,0x01,0x02,0x03,0x02,0x03,0x02,0x03,0x06,0x06,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,
+ 0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x03,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x02,0x03,0x02,0x03,0x12,0x13,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,0x06,0x06,
+ 0x00,0x01,0x12,0x13,0x06,0x06,0x06,0x06,0x0A,0x0B,
+ 0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x12,0x13,0x00,0x01,0x00,0x0A,0x0B,0x06,
+ 0x06,0x06,0x06,0x93,0x94,0x95,0x96,0x97,0x98,0x06,
+ 0x2F,0x36,0x36,0xB1,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x2F,0x36,0x36,0xB1,0x06,0x50,
+ 0x51,0x06,0x06,0x4C,0x4D,0x63,0x64,0x63,0x64,0x63,
+ 0x64,0x63,0x64,0xCB,0xCC,0x4E,0x4F,0x06,0x06,0x50,
+ 0x51,0xAB,0x06,0x31,0x06,0x06,0xAC,0x06,0x06,0x30,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x2F,0x36,0x36,0xB1,
+ 0x06,0x06,0x06,0x06,0x06,0x32,0x06,0x06,0x06,0x06,
+ 0x04,0x05,0x04,0x0D,0x0C,0x04,0x06,0x06,0x06,0x07,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x5C,
+ 0x31,0x31,0x06,0x31,0x31,0x06,0x31,0x06,0x74,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x5C,0x06,0x06,0x0C,
+ 0x0D,0x04,0x05,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0A,0x0A,0x0A,
+ 0x0B,0x06,0x06,0x06,0x06,0x02,0x03,0x02,0x03,0x02,
+ 0x03,0x02,0x03,0x06,0x06,0x06,0x06,0x06,0x06,0x0A,
+ 0x0B,0x0A,0x0B,0x0B,0x00,0x01,0x06,0x06,0x06,0x06,
+ 0x06,0x35,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,
+ 0x2E,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x35,0x36,0x36,0x2E,0x06,0x06,0x06,0x06,0x06,
+ 0x74,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x5C,0x06,0x06,0x06,0xCD,0xCE,0x06,
+ 0x06,0x06,0x06,0x9E,0x06,0x06,0x2C,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x2D,0x06,0x06,0x06,0x06,0x0C,0x0D,0x0C,
+ 0x05,0x04,0x0C,0x06,0x06,0x06,0x74,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x5C,0x06,0x06,0x31,
+ 0x06,0x31,0x31,0x06,0x06,0x07,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x09,0x06,0x06,0x06,0x06,0x0C,0x0D,
+ 0x06,0x06,0x00,0x01,0x02,0x03,0x06,0x06,0x06,0x06,
+ 0x31,0x06,0x06,0x06,0x02,0x03,0x02,0x03,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x02,0x03,0x02,0x03,0x02,0x03,
+ 0x02,0x03,0x02,0x03,0x02,0x03,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x12,0x13,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x12,0x13,0x12,0x13,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x12,0x13,0x00,0x01,0x00,0x01,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x12,0x13,0x00,0x01,0x00,0x01,
+ 0x00,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,0x2F,0x36,
+ 0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x2E,0x2F,0x2E,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x2F,0x36,
+ 0x36,0x2E,0x2F,0x2E,0x06,0x06,0x06,0x74,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x09,0x06,0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,
+ 0xAC,0x06,0x06,0x30,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x32,
+ 0x06,0x06,0x06,0x06,0x06,0x04,0x05,0x0D,0x06,0x06,
+ 0x06,0x06,0x06,0x0E,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x09,0x06,0x06,0x31,0x31,0x06,0x06,
+ 0x06,0x06,0x74,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x4F,0x06,0x06,0x06,0x04,0x05,0x06,0x06,0x06,0x0A,
+ 0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x0A,0x0B,0x0B,0x0A,0x0A,0x0B,0x0B,0xCF,0xD0,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x7F,0x36,
+ 0x7F,0x36,0x36,0x36,0x36,0x36,0x2E,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x35,0x36,0x36,0x36,0x36,
+ 0x2E,0x06,0x06,0x06,0x07,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x5C,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x31,0x06,0x9E,0x06,0x06,
+ 0x2C,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x31,0x06,0x06,0x06,0x2D,0x06,0x06,0x06,
+ 0x06,0x06,0x0C,0x0D,0x06,0x06,0x06,0x31,0x06,0x06,
+ 0x74,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x79,0x41,0x42,0x06,0x06,0x31,0x06,0x3F,0x40,0x5B,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x5C,0x06,0x06,
+ 0x06,0x0C,0x0D,0x06,0x06,0x06,0x02,0x03,0x06,0x06,
+ 0x06,0x06,0x12,0x13,0x12,0x13,0x12,0x13,0x06,0x06,
+ 0x06,0x06,0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x03,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,0x12,0x13,
+ 0x12,0x13,0x12,0x13,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x12,0x13,0x12,0x13,0x31,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x12,0x13,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x5A,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x36,
+ 0x36,0x36,0x36,0xB1,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x2F,0x2E,0x2F,0x36,0x36,0x36,0x36,0xB1,0x06,0x06,
+ 0x06,0x74,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x09,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0xAC,0x06,0x06,0x30,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x32,0x06,0x06,0x06,0x06,0x06,0x05,
+ 0x04,0x05,0x04,0x06,0x06,0x31,0x06,0x07,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,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x06,0x44,0x45,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x2D,0x06,0x06,0x06,0x06,0x04,0x0D,0x0C,0x0D,0x0C,
+ 0x06,0x06,0x06,0x06,0x74,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x79,0x54,0x55,0x54,
+ 0x55,0x5B,0x08,0x08,0x08,0x08,0x08,0x08,0x23,0x24,
+ 0x24,0x25,0x06,0x06,0x0C,0x0D,0x0C,0x0D,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x12,0x13,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x12,0x13,0x12,0x13,0x06,0x06,0x02,0x03,
+ 0x02,0x03,0x02,0x03,0x02,0x03,0x00,0x01,0x02,0x03,
+ 0x06,0x06,0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13,
+ 0x12,0x13,0x06,0x06,0x31,0x06,0x02,0x03,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x10,0x11,0x00,0x01,0x00,0x01,0x02,0x03,0x00,0x01,
+ 0x00,0x01,0x12,0x13,0x00,0x01,0x02,0x03,0x02,0x03,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,0x12,0x13,
+ 0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x8A,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x36,0x36,0x2E,0x2F,0x2E,
+ 0x2F,0x2E,0x2F,0x36,0x36,0x36,0x36,0x36,0x36,0xB1,
+ 0x06,0x06,0x06,0x06,0x06,0x0E,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x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0xA1,0xA2,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x35,0x36,0x36,0x36,0x7F,0x7F,0x36,
+ 0x7F,0x36,0x7F,0x36,0xB1,0x06,0x06,0x06,0x3F,0x40,
+ 0x54,0x55,0x5B,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x5C,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x04,0x05,0x04,0x05,0x39,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x9B,0x06,0x06,0x06,0x06,0x06,
+ 0x0D,0x0C,0x06,0x06,0x06,0x06,0x06,0x06,0x0E,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x5C,0x06,0x06,0x06,0x06,0x0C,0x0D,0x0C,
+ 0x0D,0x06,0x06,0x06,0x12,0x13,0x12,0x13,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x12,0x13,0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x06,
+ 0x02,0x03,0x06,0x06,0x12,0x13,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,0x06,0x06,
+ 0x06,0x06,0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,
+ 0x02,0x03,0x00,0x01,0x12,0x13,0x00,0x01,0x00,0x01,
+ 0x12,0x13,0x00,0x01,0x02,0x03,0x02,0x03,0x02,0x03,
+ 0x06,0x06,0x31,0x06,0x02,0x03,0x02,0x03,0x02,0x03,
+ 0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x8A,0x06,0xAF,0xB0,0xAF,0xB0,0xAF,
+ 0xB0,0xAF,0xB0,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x2F,0x36,0x36,0xB1,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x4C,0x4D,0x63,0x64,0x6A,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x09,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x0C,0x0D,0x0C,0x0D,0x3C,0x3D,0x6C,0x6D,0x6C,
+ 0x6D,0xA5,0xA5,0xA5,0xA5,0xA5,0xA5,0xA5,0xA5,0xA5,
+ 0xA5,0xA6,0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x14,0x15,0x22,0x16,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x23,0x24,0x25,
+ 0x06,0x06,0x06,0x04,0x05,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,
+ 0x31,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0B,0x0A,0x0B,0x0A,0x0B,
+ 0x0A,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x33,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,
+ 0x19,0x19,0x19,0x19,0x34,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x3F,0x40,0x54,0x55,0x54,0x55,
+ 0x54,0x55,0x5B,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x79,
+ 0x41,0x42,0x06,0x06,0x04,0x05,0x04,0x05,0x3F,0x40,
+ 0x41,0x42,0xD8,0xD9,0xDA,0xD9,0xDA,0xD9,0xDB,0xDB,
+ 0xDB,0xDB,0xDB,0xDB,0xDB,0xDB,0xDB,0xDB,0xDC,0x31,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x31,0x06,0x06,0x06,0x07,0x08,0x08,0x08,0x7D,
+ 0x7E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x5C,0x06,0x06,0x06,0x06,0x06,
+ 0x0C,0x0D,0x06,0x06,0x06,0x06,0x12,0x13,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,0x12,0x13,
+ 0x12,0x13,0x06,0x06,0x06,0x06,0x06,0x06,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x12,0x13,0x06,0x06,0x31,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x10,0x11,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x03,0x06,0x5A,
+ 0x19,0x19,0x19,0x19,0x19,0x19,0x34,0x19,0x19,0x19,
+ 0x19,0x5A,0x06,0x06,0x06,0x06,0x02,0x03,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x02,0x03,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x03,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x3A,0x26,0x26,
+ 0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,
+ 0x26,0x3B,0x06,0x06,0x48,0x49,0x4A,0x4B,0x06,0x06,
+ 0x06,0x4C,0x4D,0x63,0x64,0x63,0x64,0x63,0x64,0x6A,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x89,0x4E,0x4F,0x06,
+ 0x06,0x0C,0x0D,0x0C,0x0D,0x4C,0x4D,0x4E,0x4F,0xDD,
+ 0xDE,0xDF,0xE0,0xDF,0xE0,0xE1,0xE1,0xE1,0xE1,0xE1,
+ 0xE1,0xE1,0xE1,0xE1,0xE1,0xE2,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x31,0x06,0x06,0x31,0x06,0x06,0x31,
+ 0x06,0x06,0x0E,0x08,0x08,0x08,0x8D,0x8E,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x23,0xBB,0xE3,0xBB,0xE3,
+ 0x24,0x25,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x17,0x18,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x06,0x06,0x06,0x69,0x26,0x26,0x26,
+ 0x26,0x3A,0x26,0x3B,0x26,0x26,0x26,0x26,0x69,0x06,
+ 0x31,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x54,0x55,0x54,0x55,0x54,0x55,
+ 0x54,0x55,0x54,0x55,0x54,0x55,0x54,0x55,0x54,0x55,
+ 0x54,0x56,0x57,0x58,0x59,0x55,0x54,0x55,0x5B,0x08,
+ 0x08,0x08,0x08,0x08,0x7D,0x7E,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x7D,0x7E,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x79,0x54,0x55,0x54,0x55,
+ 0x54,0x55,0x5B,0x08,0x08,0x5C,0x46,0x47,0x80,0x81,
+ 0x80,0x81,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
+ 0x80,0x80,0xB6,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x74,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x5C,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x04,0x05,0x06,0x06,0x06,0x06,0x06,0x06,0x12,0x13,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,0x12,0x13,
+ 0x12,0x13,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,
+ 0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13,0x06,0x06,
+ 0x06,0x06,0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,
+ 0x06,0x5A,0x19,0x7A,0x06,0x06,0x06,0x06,0x3F,0x40,
+ 0x41,0x42,0x12,0x13,0x06,0x7A,0x34,0x19,0x19,0x5A,
+ 0x06,0x06,0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x06,0x06,0x02,0x03,0x00,0x01,0x02,0x03,
+ 0x00,0x63,0x64,0x63,0x64,0x63,0x64,0x63,0x64,0x63,
+ 0x64,0x63,0x64,0x63,0x64,0x63,0x64,0x63,0x65,0x66,
+ 0x67,0x68,0xE4,0x63,0x64,0x6A,0x08,0x08,0x08,0x08,
+ 0x08,0x8D,0x8E,0x08,0x08,0x7D,0x7E,0x08,0x08,0x8D,
+ 0x8E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x89,0x63,0x64,0x63,0x64,0x63,0x64,0x6A,
+ 0x08,0x08,0x09,0x52,0x53,0x8F,0x90,0x8F,0x90,0xBF,
+ 0xBF,0xBF,0xBF,0xBF,0xBF,0xBF,0xBF,0xBF,0xBF,0xC0,
+ 0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x31,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x07,0x08,0x08,0x08,
+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x54,0x55,0x41,0x42,0x12,0x13,0x12,0x13,0x12,0x13,
+ 0x12,0x13,0x12,0x13,0x12,0x13,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x0E,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x5C,0x06,0x06,0x06,
+ 0x06,0x06,0x0C,0x0D,0x04,0x05,0x0C,0x0D,0x04,0x05,
+ 0x06,0x06,0x02,0x03,0x02,0x03,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,
+ 0x02,0x03,0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x12,0x13,0x06,0x06,0x06,0x06,0x06,0x5A,
+ 0x19,0x19,0x19,0x19,0x19,0x7A,0x06,0x06,0x3F,0x40,
+ 0x54,0x55,0x5B,0x08,0x08,0x5C,0x02,0x03,0x06,0x06,
+ 0x06,0x06,0x06,0x7A,0x06,0x06,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,0x06,0x06,
+ 0x00,0x01,0x12,0x13,0x00,0x08,0x08,0x7D,0x7E,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x75,0xA3,0xA4,0x78,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x8D,0x8E,0x08,0x08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E6,
+ 0xE7,0xE8,0xE9,0xEA,0x08,0x08,0x08,0x08,0x08,0x75,
+ 0xB2,0xB3,0x78,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x5C,0x02,0x03,
+ 0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x4C,0x4D,0x63,0x64,0x6A,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x09,0x06,0x48,0x49,0x4A,0x4B,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x02,0x03,0x02,0x03,0x02,0x03,0x06,0x4C,0x4D,0x63,
+ 0x64,0x64,0x64,0x64,0x63,0x64,0x4E,0x4F,0x02,0x03,
+ 0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,
+ 0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x06,0x31,
+ 0x06,0x31,0x06,0x7A,0x06,0x06,0x5D,0x5E,0x5F,0x60,
+ 0x7B,0x7C,0x74,0x08,0x08,0x08,0x7D,0x7E,0x08,0x5C,
+ 0x06,0x06,0x06,0x0A,0x0B,0x06,0x06,0x7A,0x06,0x06,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x12,0x13,0x00,0x01,0x00,0x01,0x00,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0xBE,0x6F,0x70,0x71,0x72,
+ 0x73,0x21,0x22,0x21,0x22,0x21,0xBC,0xA3,0xA4,0xBD,
+ 0x22,0x16,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x7D,0x7E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x09,0x54,0x55,0x54,0x55,0x54,
+ 0x55,0x54,0x55,0x54,0x55,0x54,0x55,0x54,0x55,0x54,
+ 0x54,0x55,0x54,0x55,0x54,0x55,0x54,0x55,0x54,0x55,
+ 0x5B,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x79,0x41,0x56,
+ 0x57,0x58,0x59,0x55,0x54,0x55,0x54,0x55,0x54,0x55,
+ 0x54,0x54,0x55,0x54,0x55,0x54,0x55,0x54,0x55,0x54,
+ 0x55,0x54,0x55,0x55,0x5B,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x5C,0x55,0x55,0x54,0x55,0x41,
+ 0x42,0x06,0x06,0x06,0x06,0x31,0x06,0x31,0x06,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x31,0x06,0x06,
+ 0x8A,0x06,0x06,0x6E,0x6F,0x70,0x8B,0x72,0x8C,0x07,
+ 0x08,0x08,0x08,0x8D,0x8E,0x08,0x09,0x06,0x06,0x06,
+ 0x02,0x03,0x06,0x06,0x8A,0x06,0x06,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x1B,0x1C,0x1D,0x1E,
+ 0x1F,0x20,0x99,0x08,0x86,0x87,0x9A,0x88,0x1A,0x06,
+ 0x06,0x06,0x06,0xC5,0xC6,0xC7,0xC8,0x06,0x0E,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x8D,0x8E,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x64,0x63,0x64,0x64,0x63,0x64,0x63,0x64,
+ 0x63,0x64,0x63,0x64,0x63,0x64,0x63,0x63,0x64,0x63,
+ 0x64,0x63,0x64,0x63,0x64,0x63,0x64,0x6A,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x89,0x4E,0x65,0x66,0x67,0x68,
+ 0xE4,0x63,0x64,0x63,0x64,0x63,0x64,0x63,0x63,0x64,
+ 0x63,0x64,0x63,0x64,0x63,0x64,0x63,0x64,0x63,0x64,
+ 0x64,0x6A,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x64,0x64,0x64,0x63,0x64,0x4E,0x4F,0x06,0x44,
+ 0x45,0x31,0x06,0x31,0x06,0x06,0x02,0x03,0x02,0x03,
+ 0x02,0x03,0x02,0x03,0x02,0x03,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x03,
+ 0x02,0x03,0x06,0x06,0x06,0x06,0x06,0x33,0x06,0x06,
+ 0x99,0x08,0x86,0x87,0x9A,0x88,0x0E,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x5C,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x8A,0x06,0x06,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x29,0x06,0x06,0x06,0x06,0x2A,0x93,
+ 0x94,0x95,0x96,0x97,0x98,0x27,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x14,0x15,0xBB,0xE3,0xBB,
+ 0xE3,0xBB,0xE3,0xBB,0xE3,0xEB,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x75,0x76,0x77,0x78,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x5C,0x06,0x50,0x51,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,0x5A,0x19,
+ 0x19,0x06,0x06,0x06,0x33,0x06,0x06,0x93,0x94,0x95,
+ 0x96,0x97,0x98,0x0E,0x08,0x08,0x7D,0x7E,0x08,0x08,
+ 0x09,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x7A,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x43,0x06,0x12,0x13,0x06,0x2D,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x2B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13,
+ 0x12,0x13,0x0E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x7D,0x7E,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x75,0xA3,0xA4,0x78,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x09,0x31,0x06,0x06,0x06,0x06,0x31,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x02,0x03,0x06,0x06,0x06,0x69,0x26,0x7A,0x06,0x06,
+ 0x06,0x7A,0x06,0x06,0xA1,0xA2,0x36,0x36,0x2E,0x06,
+ 0x14,0x15,0x16,0x8D,0x8E,0x08,0x08,0x25,0xA1,0xA2,
+ 0x36,0x36,0x2E,0x06,0x06,0x8A,0x06,0x06,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x12,0x13,0x00,0x01,0x00,0x01,
+ 0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x06,0x06,0x0A,
+ 0x0B,0x06,0x32,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0xEC,0x06,0x06,0x06,0x06,0xD3,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x14,
+ 0x15,0x16,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x8D,0x8E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x7D,0x7E,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x75,0xB2,0xB3,
+ 0x78,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x5C,0x06,
+ 0x06,0x06,0x44,0x45,0x1B,0x1C,0x37,0x38,0x1D,0x1E,
+ 0x1D,0x1E,0x1D,0x1F,0x20,0x06,0x06,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x5A,
+ 0x19,0x19,0x7A,0x06,0x26,0x06,0x06,0x06,0x26,0x06,
+ 0x06,0xAF,0xB0,0x36,0x36,0xB1,0x06,0x06,0x06,0x0E,
+ 0x08,0x08,0x08,0x09,0x06,0xAF,0xB0,0x36,0x36,0xB1,
+ 0x06,0x06,0x8A,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x12,0x13,0x00,0x01,0x06,0x2D,
+ 0x19,0x19,0x19,0x19,0x34,0x06,0x06,0x06,0x06,0x06,
+ 0x9E,0x06,0x06,0x06,0x06,0xED,0x02,0x03,0x00,0x01,
+ 0x00,0x01,0x02,0x03,0x02,0x03,0x06,0x06,0x74,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x7D,0x7E,0x08,0x08,0x08,0x08,0x08,0x08,0x7D,
+ 0x7E,0x08,0x08,0x8D,0x8E,0x08,0x08,0x08,0x08,0x08,
+ 0x23,0xBB,0xE3,0xBB,0xE3,0xBB,0xE3,0xBB,0xE3,0x15,
+ 0xBB,0xE3,0xBB,0xE3,0xE3,0x22,0x21,0xBB,0xE3,0xE3,
+ 0xBB,0x22,0x21,0xE3,0xBB,0x22,0x21,0xBB,0xE3,0xBB,
+ 0xE3,0xBB,0xE3,0x15,0xBB,0xE3,0xBB,0xE3,0x22,0x21,
+ 0x22,0x21,0x22,0x21,0xBC,0xA3,0xA4,0xBD,0x22,0xE3,
+ 0x15,0xBB,0xE3,0xBB,0xE3,0x15,0x21,0x22,0x21,0x22,
+ 0x21,0x22,0x21,0x22,0x21,0x22,0x21,0x22,0x21,0x22,
+ 0x16,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x09,0x06,0x06,0x06,0x50,
+ 0x51,0x30,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x32,0x06,0x06,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x06,0x06,0x7A,0x26,0x26,0x26,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x35,
+ 0x36,0x36,0x2E,0x06,0x06,0x06,0x14,0xE3,0xE3,0x24,
+ 0x25,0x06,0x06,0x35,0x36,0x36,0x2E,0x06,0x06,0x8A,
+ 0x06,0x31,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0xA1,0xA2,0x00,0x01,0x00,0x01,
+ 0x00,0x0A,0x0B,0x0A,0x0B,0x06,0x32,0x26,0x26,0x26,
+ 0x26,0x3B,0x06,0x06,0x06,0x06,0x06,0xAC,0x06,0x06,
+ 0x06,0x06,0xEE,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x07,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x8D,0x8E,
+ 0x08,0x08,0x7D,0x7E,0x08,0x08,0x8D,0x8E,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x7D,0x7E,0x08,0x5C,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0xC5,0xC6,0xC7,0xC8,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x12,0x13,0x12,0x13,0x12,0x13,0x12,
+ 0x13,0x06,0x06,0x12,0x13,0x06,0x06,0x74,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x79,0x41,0x42,0x06,0x06,0x06,0x2C,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x2D,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x06,0x06,0x7A,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x2F,0x2E,0x06,0x36,0x36,0x36,
+ 0x2E,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x35,0x36,0x36,0x2E,0x06,0x06,0x7A,0x06,0x06,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0xAF,0xB0,0x0A,0x0B,0x0A,0x0B,0x0A,0x02,0x03,
+ 0x00,0x01,0x06,0x2D,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x9E,0x06,0x06,0x06,0x06,0xED,
+ 0x06,0x06,0x02,0x03,0x02,0x03,0x04,0x05,0x06,0x06,
+ 0x06,0x06,0x74,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x8D,
+ 0x8E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x8D,0x8E,0x08,0x09,0x06,0x06,0x06,0x12,0x13,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x31,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x31,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x06,
+ 0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,
+ 0x0A,0x0B,0x06,0x06,0x07,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x89,
+ 0x4E,0x4F,0x06,0x06,0x06,0x30,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x32,0x06,0x06,0x02,0x03,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x06,0x06,
+ 0x8A,0x06,0x06,0x06,0x06,0x44,0x45,0x06,0x06,0x35,
+ 0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x2E,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x35,0x36,0x36,0x36,0x36,0x36,
+ 0x36,0x2E,0x06,0x8A,0x06,0x06,0x00,0x01,0x00,0x01,
+ 0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x06,0x06,0x0A,0x0B,0x06,
+ 0x32,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0xAC,0x06,0x06,0x06,0x06,0xEE,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x0C,0x0D,0x06,0x06,0x06,0x06,0x07,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x23,0x21,0x22,0x22,
+ 0x24,0x25,0x06,0x06,0x06,0x0A,0x0B,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x31,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x31,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x02,0x03,0x00,
+ 0x01,0x00,0x01,0x00,0x01,0x12,0x13,0x00,0x01,0x06,
+ 0x06,0x74,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x4F,0x06,
+ 0x06,0x06,0x2C,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x9B,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x8A,0x06,0x31,
+ 0x06,0x06,0x50,0x51,0x06,0x06,0x2F,0x2E,0x2E,0x06,
+ 0x06,0x2F,0x36,0x36,0x36,0x36,0x2E,0x06,0x06,0x06,
+ 0x06,0x06,0x2F,0x36,0x36,0x36,0x36,0x36,0xB1,0x06,
+ 0x8A,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x06,0x06,0x02,0x03,0x06,0x2D,0x12,0x13,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x9D,0x06,
+ 0x06,0x06,0x06,0xCD,0x06,0x06,0x04,0x05,0x04,0x05,
+ 0x04,0x05,0x06,0x06,0x06,0x06,0x0E,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x5C,0x12,0x13,0x12,0x13,0x12,0x13,
+ 0x12,0x13,0x00,0x01,0x06,0x06,0x12,0x13,0x06,0x06,
+ 0x06,0x31,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x31,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x04,0x06,
+ 0x06,0x06,0x06,0x04,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x31,0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,
+ 0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x07,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x4F,0x06,0x06,0x06,0x30,
+ 0x06,0x06,0x6B,0x6C,0x6D,0x6C,0x6D,0x6C,0x6D,0xA6,
+ 0x06,0x06,0x06,0x06,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x06,0x06,0x33,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x36,0x36,0x36,0x2E,0x06,0x06,0x06,0x06,0x2F,0x36,
+ 0x2F,0x36,0x36,0x36,0x2E,0x06,0x06,0x7A,0x06,0x06,
+ 0x00,0x01,0x00,0x01,0x12,0x13,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x06,
+ 0x06,0x06,0x06,0x06,0x32,0x0A,0x0B,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0xAB,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x0C,0x0D,0x0C,0x0D,0x0C,0x0D,0x06,
+ 0x06,0x06,0x06,0x14,0x15,0x16,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x09,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x06,0x06,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x31,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x05,
+ 0x04,0x05,0x04,0x05,0x04,0x04,0x06,0x06,0x05,0x04,
+ 0x0C,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x31,0x06,
+ 0x06,0x06,0x06,0x00,0x01,0x00,0x01,0x00,0x01,0x00,
+ 0x01,0x00,0x01,0x06,0x06,0x0E,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x4F,0x06,0x06,0x06,0x2C,0x06,0x06,0x2D,
+ 0x80,0x81,0x82,0x83,0x80,0x81,0xDC,0x06,0x06,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,
+ 0x06,0x7A,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x31,
+ 0x06,0x06,0x06,0x06,0x12,0x13,0x35,0x36,0x36,0x2E,
+ 0x06,0x12,0x13,0x06,0x06,0x06,0x2F,0x36,0x36,0x36,
+ 0x36,0xB1,0x06,0x06,0x8A,0x06,0x31,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x02,0x03,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x06,0x06,0x06,0x06,
+ 0x06,0x9B,0x00,0x01,0x12,0x13,0x06,0x06,0x06,0xCD,
+ 0xEF,0xF0,0xCE,0x06,0x06,0x06,0x04,0x05,0x04,0x05,
+ 0x12,0x13,0x04,0x05,0x04,0x05,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x0E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x0F,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,
+ 0x00,0x01,0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x31,0x06,0x06,0x06,0x06,0x0D,0x0C,0x0D,0x0C,
+ 0x0D,0x0C,0x06,0x06,0x06,0x0D,0x0C,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x02,0x03,0x02,0x03,
+ 0x06,0x06,0x14,0x15,0x16,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x4F,
+ 0x06,0x06,0x06,0x30,0x06,0x06,0x32,0x8F,0x90,0x91,
+ 0x92,0x8F,0x8F,0x90,0x06,0x06,0x12,0x13,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x06,0x06,0x8A,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x0A,0x0B,0x2F,0x36,0x36,0xB1,0x06,0x0A,0x0B,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x7A,0x06,0x06,0x00,0x01,0x00,0x01,0x02,0x03,
+ 0x06,0x06,0x00,0x01,0x02,0x03,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x6C,0x6D,0x6C,0x6D,0xA5,0xA6,0x0A,
+ 0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x0C,0x0D,0x0C,0x0D,0x0A,0x0B,0x0C,
+ 0x0D,0x0C,0x0D,0x06,0x06,0x06,0x06,0x06,0x06,0x14,
+ 0x15,0x21,0x22,0x16,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x23,0x21,0x22,0x24,0x25,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x05,0x04,0x05,0x04,0x04,0x05,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x04,0x05,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x02,0x03,0x02,
+ 0x03,0x02,0x03,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x0E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x4F,0x06,0x06,0x06,
+ 0x2C,0x06,0x06,0x32,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x06,0x06,0x7A,0x06,0xA1,0xA2,0xA1,
+ 0xA2,0xA1,0xA2,0xA1,0xA2,0x06,0x06,0x06,0x02,0x03,
+ 0x35,0x36,0x36,0x2E,0x06,0x02,0x03,0x06,0xA1,0xA2,
+ 0xA1,0xA2,0xA1,0xA2,0xA1,0xA2,0x06,0x06,0x8A,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x0A,
+ 0x0B,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x80,0x81,0x80,0x81,0x80,0xB6,0x00,0x01,0x00,0x01,
+ 0x12,0x13,0x12,0x13,0x12,0x13,0x04,0x05,0x04,0x05,
+ 0x04,0x05,0x12,0x13,0x02,0x03,0x04,0x05,0x04,0x05,
+ 0x04,0x05,0x06,0x06,0x44,0x45,0x12,0x13,0x06,0x06,
+ 0x0E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x0F,0x12,0x13,
+ 0x12,0x13,0x00,0x01,0x02,0x03,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x03,
+ 0x00,0x01,0x00,0x01,0x12,0x13,0x12,0x13,0x12,0x13,
+ 0x12,0x13,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0D,
+ 0x0C,0x0D,0x04,0x0C,0x0D,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x12,0x13,0x0C,0x0D,0x04,0x04,0x05,0x04,0x05,
+ 0x12,0x13,0x12,0x13,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x31,0x06,0x06,0x06,0x06,0x06,0x06,0x14,0x15,
+ 0x21,0x22,0x16,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x4F,0x06,0x06,0x06,0x30,0x06,0x06,
+ 0x32,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x06,0x06,0x8A,0x06,0xAF,0xB0,0xAF,0xB0,0xAF,0xB0,
+ 0xAF,0xB0,0x06,0x06,0x06,0x06,0x19,0x06,0x06,0x06,
+ 0x06,0x06,0x19,0x06,0x06,0xAF,0xB0,0xAF,0xB0,0xAF,
+ 0xB0,0xAF,0xB0,0x06,0x06,0x7A,0x06,0x06,0x00,0x01,
+ 0x00,0x01,0x12,0x13,0x06,0x06,0x00,0x01,0x12,0x13,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x8F,0x90,0x8F,
+ 0x90,0xBF,0xC0,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0C,0x0D,0x0C,0x0D,0x0C,0x0D,0x0A,
+ 0x0B,0x06,0x06,0x0C,0x0D,0x0C,0x0D,0x0C,0x0D,0x06,
+ 0x06,0x50,0x51,0x0A,0x0B,0x06,0x06,0x14,0x15,0x21,
+ 0x22,0x21,0x22,0x21,0x22,0x21,0x22,0x21,0x22,0x21,
+ 0x22,0x21,0x22,0x24,0x25,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x05,0x04,0x05,0x0C,
+ 0x04,0x06,0x06,0x06,0x06,0x05,0x04,0x05,0x0A,0x0B,
+ 0x12,0x13,0x0C,0x0C,0x0D,0x0C,0x0D,0x0A,0x0B,0x0A,
+ 0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x07,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x79,0x41,0x41,0x41,0x2C,0x06,0x06,0x2D,0x41,0x41,
+ 0x42,0x06,0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x33,
+ 0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,
+ 0x19,0x19,0x19,0x28,0x06,0x06,0x06,0x06,0x06,0x28,
+ 0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,
+ 0x19,0x19,0x8A,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x06,0x06,0x12,0x13,0x06,0x06,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x1B,0x1C,
+ 0x1D,0x1E,0x1D,0x1E,0x1D,0x1E,0x1F,0x20,0x04,0x05,
+ 0x04,0x05,0x04,0x05,0x04,0x05,0x12,0x13,0x12,0x13,
+ 0x02,0x03,0x12,0x13,0x06,0x06,0x12,0x13,0x12,0x13,
+ 0x12,0x13,0x12,0x13,0x06,0x06,0x12,0x13,0x06,0x06,
+ 0x12,0x13,0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,
+ 0x10,0x11,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x12,0x13,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,0x12,0x13,
+ 0x06,0x06,0x04,0x05,0x04,0x05,0x04,0x0C,0x06,0x06,
+ 0x06,0x06,0x0D,0x0C,0x0D,0x00,0x01,0x0A,0x0B,0x04,
+ 0x04,0x05,0x04,0x05,0x00,0x01,0x00,0x01,0x12,0x13,
+ 0x12,0x13,0x12,0x13,0x06,0x06,0x12,0x13,0x12,0x13,
+ 0x06,0x06,0x31,0x06,0x06,0x06,0x0E,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x30,0x06,0x06,0x32,0x4E,0x4E,0x4F,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x06,0x06,0x26,0x26,0x26,0x26,
+ 0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,
+ 0x26,0x06,0x06,0x06,0x06,0x06,0x26,0x26,0x26,0x26,
+ 0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,
+ 0x06,0x06,0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x03,
+ 0x02,0x03,0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x06,0x06,0x0A,0x0B,0x06,0x06,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x29,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x2A,0x0C,0x0D,0x0C,0x0D,0x0C,
+ 0x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06,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x12,0x13,
+ 0x02,0x03,0x44,0x45,0x10,0x11,0x00,0x01,0x00,0x01,
+ 0x02,0x03,0x2C,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x2D,0x04,0x05,0x04,0x05,0x12,0x13,0x12,0x13,
+ 0x00,0x01,0x00,0x01,0x12,0x13,0x00,0x01,0x12,0x13,
+ 0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,
+ 0x00,0x01,0x12,0x13,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x0A,0x0B,0x02,0x03,0x10,0x11,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x06,0x0C,0x04,0x05,0x12,0x13,
+ 0x04,0x0C,0x0D,0x06,0x06,0x0C,0x0D,0x0A,0x0B,0x10,
+ 0x11,0x0A,0x0B,0x04,0x04,0x05,0x04,0x05,0x10,0x11,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,
+ 0x00,0x01,0x00,0x01,0x12,0x13,0x06,0x06,0x06,0x06,
+ 0x07,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x30,0x06,0x06,0x32,0x08,
+ 0x08,0x09,0x06,0x06,0x06,0x06,0x0A,0x0B,0x02,0x03,
+ 0x02,0x03,0x02,0x03,0x00,0x01,0x00,0x01,0x12,0x13,
+ 0x12,0x13,0x06,0x06,0x06,0x06,0x06,0x06,0x12,0x13,
+ 0x12,0x13,0x12,0x13,0x12,0x13,0x06,0x06,0x06,0x06,
+ 0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13,
+ 0x12,0x13,0x12,0x13,0x12,0x13,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A,0x0B,0x0A,0x0B,0x12,
+ 0x13,0x12,0x13,0x12,0x13,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,
+ 0x06,0x06,0x12,0x13,0x06,0x06,0x06,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x02,0x03,0x06,0x06,0x06,0x06,0x31,0x06,
+ 0x02,0x03,0x02,0x03,0x12,0x13,0x39,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x9B,0x04,0x05,0x04,0x05,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x12,0x13,0x00,0x01,0x10,0x11,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x03,
+ 0x02,0x03,0x02,0x03,0x00,0x01,0x00,0x01,0x0A,0x0B,
+ 0x0A,0x0B,0x06,0x06,0x02,0x03,0x02,0x03,0x02,0x03,
+ 0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,
+ 0x02,0x03,0x02,0x03,0x00,0x01,0x00,0x01,0x06,0x04,
+ 0x04,0x05,0x00,0x01,0x04,0x0C,0x0D,0x0C,0x0C,0x0D,
+ 0x0C,0x0D,0x0D,0x06,0x06,0x17,0x18,0x04,0x04,0x05,
+ 0x04,0x05,0x04,0x05,0x02,0x03,0x02,0x03,0x02,0x03,
+ 0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x00,0x01,
+ 0x12,0x13,0x06,0x06,0x07,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x09,0x06,0x30,
+ 0x06,0x06,0x9B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x31,0x06,0x50,0x51,0x06,0x02,0x03,
+ 0x02,0x03,0x02,0x03,0x02,0x03,0x0A,0x0B,0x0A,0x0B,
+ 0x0A,0x0B,0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,
+ 0x06,0x06,0x06,0x06,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x02,0x03,0x00,0x01,0x06,0x06,0x06,0x06,0x06,0x0A,
+ 0x0B,0x06,0x06,0x06,0x00,0x01,0x00,0x01,0x00,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,
+ 0x06,0x0A,0x0B,0x3C,0x3D,0x3E,0x06,0x06,0x06,0x06,
+ 0x6B,0xA5,0xA6,0x0C,0x0D,0x0C,0x0D,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x17,0x18,0x0A,0x0B,0x02,
+ 0x03,0x02,0x03,0x02,0x03,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x00,0x01,0x00,0x01,0x12,
+ 0x13,0x12,0x13,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x06,0x0C,0x0C,0x0D,0x0A,
+ 0x0B,0x0C,0x04,0x05,0x04,0x05,0x04,0x05,0x04,0x05,
+ 0x04,0x05,0x04,0x05,0x04,0x0C,0x0D,0x0C,0x0D,0x0C,
+ 0x0D,0x06,0x06,0x06,0x06,0x06,0x06,0x02,0x03,0x00,
+ 0x01,0x00,0x01,0x00,0x01,0x0A,0x0B,0x0A,0x0B,0x06,
+ 0x06,0x0E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x09,0x06,0x2C,0x06,0x06,0x06,
+ 0x1D,0x1E,0x1D,0x1F,0x20,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x02,0x03,0x02,0x03,0x02,0x03,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0A,
+ 0x0B,0x06,0x06,0x06,0x06,0x06,0x02,0x03,0x06,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x06,0x06,0x12,0x13,
+ 0x06,0x06,0x12,0x13,0x06,0x06,0x06,0x06,0x02,0x03,
+ 0x46,0x47,0x39,0x06,0x06,0x06,0x06,0x9B,0x80,0xB6,
+ 0x04,0x05,0x04,0x05,0x10,0x11,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x10,0x11,0x12,0x13,0x02,0x03,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x12,0x13,0x06,0x06,0x02,0x03,
+ 0x02,0x03,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x02,0x03,
+ 0x02,0x03,0x06,0x04,0x04,0x05,0x10,0x11,0x04,0x0C,
+ 0x0D,0x0C,0x0D,0x0C,0x0D,0x0C,0x0D,0x06,0x06,0x06,
+ 0x0D,0x04,0x04,0x05,0x04,0x05,0x04,0x05,0x04,0x05,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,
+ 0x0A,0x0B,0x00,0x01,0x00,0x01,0x06,0x06,0x74,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x09,0x06,0x30,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x32,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x12,0x13,0x00,0x01,0x12,0x13,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x00,0x01,
+ 0x00,0x01,0x00,0x06,0x06,0x0A,0x0B,0x06,0x06,0x0A,
+ 0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x52,0x53,0x3C,
+ 0x3D,0x6C,0x6D,0xA5,0xA6,0xBF,0xC0,0x0C,0x0D,0x0C,
+ 0x0D,0x17,0x18,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x17,0x18,0x0A,
+ 0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x02,
+ 0x03,0x02,0x03,0x02,0x03,0x02,0x03,0x06,0x06,0x06,
+ 0x06,0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13,0x12,
+ 0x13,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x0C,0x0C,0x0D,0x17,0x18,0x0C,0x04,0x05,0x05,0x04,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0C,0x0C,
+ 0x0D,0x0C,0x0D,0x0C,0x0D,0x0C,0x0D,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x02,0x03,0x02,0x03,0x02,0x03,0x0A,
+ 0x0B,0x0A,0x0B,0x06,0x06,0x07,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x09,0x06,
+ 0x39,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x32,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x31,0x06,0x06,0x06,0x06,0x06,0x31,0x06,0x06,
+ 0x06,0x06,0x06,0x12,0x13,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x31,0x06,0x02,0x03,0x06,0x06,0x02,0x03,0x06,0x06,
+ 0x12,0x13,0x06,0x06,0x06,0x06,0x46,0x47,0x80,0x81,
+ 0x80,0xB6,0x44,0x45,0x04,0x05,0x04,0x05,0x04,0x05,
+ 0x02,0x03,0x02,0x03,0x02,0x03,0x0A,0x0B,0x0A,0x0B,
+ 0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x02,0x03,0x06,0x06,
+ 0x06,0x06,0x12,0x13,0x12,0x13,0x12,0x13,0x00,0x01,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,
+ 0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x04,0x05,
+ 0x04,0x05,0x04,0x0C,0x0D,0x0D,0x0C,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x00,0x01,0x00,0x01,
+ 0x06,0x06,0x74,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x09,0x06,0x39,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x9B,0x06,0x06,0x12,0x13,
+ 0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13,
+ 0x06,0x06,0x06,0x06,0x12,0x13,0x12,0x13,0x12,0x13,
+ 0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x12,0x13,0x06,0x06,0x12,0x13,
+ 0x12,0x13,0x00,0x01,0x00,0x01,0x00,0x06,0x31,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x06,
+ 0x06,0x06,0x06,0x52,0x53,0x8F,0x90,0xBF,0xC0,0x50,
+ 0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,0x0B,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x31,0x06,0x06,0x02,0x03,0x06,0x06,0x31,0x06,
+ 0x12,0x13,0x12,0x13,0x12,0x13,0x04,0x05,0x04,0x05,
+ 0x04,0x05,0x04,0x05,0x04,0x05,0x06,0x06,0x04,0x05,
+ 0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x02,0x03,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x12,0x13,0x0A,0x0B,0x12,0x13,
+ 0x12,0x13,0x12,0x13,0x12,0x13,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x17,0x18,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,
+ 0x0A,0x0B,0x06,0x06,0x12,0x13,0x12,0x13,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x31,
+ 0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x12,0x13,0x12,0x13,0x06,0x06,0x12,0x13,
+ 0x00,0x01,0x02,0x03,0x06,0x06,0x0E,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x09,
+ 0x06,0x46,0x47,0x81,0x80,0x81,0x81,0x80,0x81,0xDC,
+ 0x12,0x13,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x12,0x13,0x12,0x13,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x12,0x13,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0C,0x0D,0x0C,0x0D,0x0C,0x0D,0x0C,
+ 0x0D,0x0C,0x0D,0x06,0x06,0x0C,0x0D,0x06,0x06,0x02,
+ 0x03,0x02,0x03,0x02,0x03,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x02,0x03,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x12,0x13,0x06,0x06,0x06,0x06,0x12,
+ 0x13,0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,0x12,
+ 0x13,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x31,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0A,
+ 0x0B,0x0A,0x0B,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x06,
+ 0x06,0x06,0x06,0x74,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x5C,0x06,0x52,0x53,
+ 0x8F,0x8F,0x8F,0x8F,0x8F,0x8F,0x90,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x06,0x06,
+ 0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x06,0x06,0x04,0x05,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x12,0x13,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x02,0x03,0x02,0x03,0x02,0x03,0x00,0x01,
+ 0x06,0x06,0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,
+ 0x0A,0x0B,0x06,0x06,0x06,0x06,0x0A,0x0B,0x06,0x06,
+ 0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x02,0x03,
+ 0x02,0x03,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x05,0x04,0x05,0x05,0x04,0x05,
+ 0x04,0x05,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x05,0x04,0x05,0x00,0x01,0x00,0x01,
+ 0x06,0x06,0x00,0x01,0x00,0x01,0x12,0x13,0x12,0x13,
+ 0x07,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x09,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x12,0x13,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x03,
+ 0x02,0x03,0x02,0x03,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x02,0x03,0x02,0x03,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0C,
+ 0x0D,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x00,0x01,0x12,
+ 0x13,0x06,0x06,0x02,0x03,0x06,0x06,0x02,0x03,0x02,
+ 0x03,0x02,0x03,0x00,0x01,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x05,0x04,0x05,
+ 0x04,0x05,0x0C,0x0C,0x0D,0x0C,0x0D,0x0C,0x0C,0x05,
+ 0x04,0x05,0x06,0x06,0x06,0x06,0x06,0x05,0x04,0x05,
+ 0x05,0x04,0x05,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x74,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x5C,0x06,0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A
+};
+
+/* End of BIGMAP_MAP.C */
diff --git a/gbdk/gbdk-lib/examples/ap/large_map/bigmap_map.h b/gbdk/gbdk-lib/examples/ap/large_map/bigmap_map.h
new file mode 100644
index 00000000..4ab64633
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/large_map/bigmap_map.h
@@ -0,0 +1,32 @@
+/*
+
+ BIGMAP_MAP.H
+
+ Map Include File.
+
+ Info:
+ Section :
+ Bank : 0
+ Map size : 247 x 66
+ Tile set : bigmap_tiles.gbr
+ Plane count : 1 plane (8 bits)
+ Plane order : Planes are continues
+ Tile offset : 0
+ Split data : No
+
+ This file was generated by GBMB v1.8
+
+*/
+#ifndef __bigmap_map_h_INCLUDE
+#define __bigmap_map_h_INCLUDE
+
+#define bigmap_mapWidth 247
+#define bigmap_mapHeight 66
+#define bigmap_mapBank 0
+
+#define bigmap_map bigmap_mapPLN0
+extern const unsigned char bigmap_mapPLN0[];
+
+#endif
+
+/* End of BIGMAP_MAP.H */
diff --git a/gbdk/gbdk-lib/examples/ap/large_map/bigmap_tiles.c b/gbdk/gbdk-lib/examples/ap/large_map/bigmap_tiles.c
new file mode 100644
index 00000000..6cef85df
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/large_map/bigmap_tiles.c
@@ -0,0 +1,512 @@
+/*
+
+ BIGMAP_TILES.C
+
+ Tile Source File.
+
+ Info:
+ Form : All tiles as one unit.
+ Format : Gameboy 4 color.
+ Compression : None.
+ Counter : None.
+ Tile size : 8 x 8
+ Tiles : 0 to 240
+
+ Palette colors : Included.
+ SGB Palette : None.
+ CGB Palette : None.
+
+ Convert to metatiles : No.
+
+ This file was generated by GBTD v2.2
+
+*/
+
+/* Start of tile array. */
+const unsigned char bigmap_tiles[] =
+{
+ 0x5C,0x63,0x33,0x3C,0x2D,0x10,0x5A,0x20,
+ 0xDD,0x20,0xBF,0x40,0xBF,0x40,0x1B,0x64,
+ 0x02,0xFE,0xCC,0x3C,0x74,0x08,0xFA,0x04,
+ 0xFB,0x04,0xFB,0x06,0xD3,0x2E,0xC6,0x3E,
+ 0x5C,0x63,0x3B,0x37,0x3C,0x0F,0x6F,0x18,
+ 0xCD,0x3A,0xC9,0x3E,0x3C,0x03,0x0F,0x00,
+ 0x02,0xFE,0xCC,0xFC,0x7C,0xF0,0x76,0xF8,
+ 0x73,0xFC,0x73,0xFC,0x3C,0xC0,0xF0,0x00,
+ 0x00,0x22,0x14,0x41,0x22,0x49,0x1C,0x22,
+ 0x00,0x00,0x00,0x44,0x28,0x82,0x44,0x92,
+ 0x00,0x00,0x00,0x22,0x14,0x41,0x22,0x49,
+ 0x1C,0x22,0x00,0x00,0x00,0x44,0x28,0x82,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x17,0x10,0x17,0x30,0x67,0x10,0x77,0x08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D7,0x30,0x23,0x7C,
+ 0x31,0x4E,0x74,0x0B,0x66,0x19,0x02,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xC1,0x3E,
+ 0x8C,0x73,0x2E,0xD1,0x27,0x00,0x0F,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0x7F,0x80,
+ 0x9F,0x60,0x8F,0x30,0x2F,0x10,0x77,0x10,
+ 0x3C,0x03,0x0F,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x3C,0xC0,0xF0,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x38,0x00,0x44,0x00,
+ 0xBA,0x00,0xC6,0x82,0xDB,0xA7,0xDB,0xA6,
+ 0x00,0x00,0x00,0x00,0x38,0x00,0x44,0x00,
+ 0xBA,0x00,0xC6,0x82,0xDA,0xA6,0xFA,0xAE,
+ 0xFF,0x06,0xFD,0x1B,0xE6,0x31,0xF2,0x20,
+ 0xF8,0x20,0xE0,0x30,0xF0,0x40,0xE0,0x90,
+ 0xFF,0xFB,0x35,0xCE,0xBB,0x40,0x9A,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xFF,0xBE,0x4D,0xF3,0xAE,0x50,0xA6,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xFF,0xE0,0x5F,0xBF,0xCC,0x33,0x9C,0x00,
+ 0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xFF,0xEE,0xD5,0x3B,0xEC,0x03,0x69,0x00,
+ 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xFF,0x00,0xFF,0xF8,0xCF,0x36,0xC9,0x03,
+ 0x83,0x01,0x07,0x01,0x03,0x06,0x07,0x01,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0x41,0x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F0,0x00,0xF0,0x00,0xF0,0x00,
+ 0x00,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,
+ 0x00,0x00,0x07,0x00,0x07,0x00,0x07,0x00,
+ 0x00,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,
+ 0xE0,0x38,0xF0,0x18,0xFC,0x20,0xEC,0x30,
+ 0xE0,0x38,0xF0,0x40,0xD8,0x60,0xE0,0x30,
+ 0x00,0x00,0x00,0x00,0x20,0x00,0x32,0x00,
+ 0x16,0x00,0x04,0x00,0x00,0x00,0x00,0x00,
+ 0x03,0x02,0x03,0x06,0x0F,0x02,0x0F,0x01,
+ 0x07,0x01,0x01,0x07,0x0D,0x03,0x1B,0x06,
+ 0xAA,0xFE,0xAA,0xFE,0x28,0x7C,0x00,0x44,
+ 0x38,0x82,0xC6,0x82,0xDB,0xA7,0xDB,0xA6,
+ 0x00,0x00,0x00,0x00,0x38,0x00,0x44,0x00,
+ 0xBA,0x00,0xC6,0x82,0xDA,0xA6,0xDA,0xA6,
+ 0x00,0x00,0x07,0x00,0x07,0x00,0x07,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xF7,0x00,0xF7,0x00,0xF7,0x00,
+ 0x00,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,
+ 0xCF,0x80,0xF0,0x80,0xE0,0x80,0x60,0xC0,
+ 0xFE,0x40,0xA0,0xC0,0x40,0x80,0x80,0x00,
+ 0x79,0x01,0x07,0x01,0x01,0x01,0x03,0x02,
+ 0xCB,0x02,0x01,0x03,0x00,0x01,0x01,0x00,
+ 0xF0,0x40,0xC0,0x70,0xE0,0x30,0xF8,0x40,
+ 0xD8,0x60,0xC0,0x70,0xE0,0x80,0xB0,0xC0,
+ 0xBB,0xC7,0xA2,0xDE,0xA3,0xDF,0x67,0x5C,
+ 0x77,0x4F,0x54,0x6C,0x44,0x7C,0x00,0x38,
+ 0xBA,0xC6,0xA2,0xDE,0xA2,0xD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+ 0xEB,0x9C,0xFC,0xDF,0x38,0x78,0x84,0x03,
+ 0x0F,0x0C,0x0D,0x0C,0x05,0x04,0x45,0x8C,
+ 0xED,0x9C,0xFD,0xDC,0x3D,0x7C,0x85,0x04,
+ 0xE0,0x9F,0xFF,0x80,0xFF,0x80,0xFF,0x80,
+ 0xC0,0xFF,0xFF,0x80,0xFF,0x80,0xFF,0x80,
+ 0x07,0xF9,0xFF,0x01,0xFF,0x01,0xFF,0x01,
+ 0x03,0xFF,0xFF,0x01,0xDF,0x21,0xFF,0x01,
+ 0xF0,0x30,0x70,0x30,0x62,0x30,0x76,0x38,
+ 0x6D,0x3B,0x6A,0x2E,0x71,0x20,0x64,0x3B,
+ 0x00,0x00,0x00,0x00,0x38,0x00,0x44,0x00,
+ 0xBA,0x00,0xC6,0x82,0xDA,0xA6,0xFB,0xAF,
+ 0x77,0x10,0x37,0x30,0xA3,0x34,0xCB,0x64,
+ 0x93,0x8C,0x47,0x38,0x87,0x78,0x17,0xE8,
+ 0xE0,0x0C,0xCC,0x10,0xF8,0x24,0xD0,0x18,
+ 0xA0,0x4C,0x93,0x64,0x97,0x68,0xDE,0x28,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x03,0x00,0x0D,0x00,0x31,0x00,0xD1,0x00,
+ 0x03,0x00,0x0D,0x00,0x31,0x00,0xD1,0x00,
+ 0x11,0x00,0x01,0x00,0x01,0x00,0x11,0x00,
+ 0xFF,0x00,0x10,0x00,0x10,0x00,0x00,0x00,
+ 0x10,0x00,0x00,0x00,0x10,0x00,0x10,0x00,
+ 0xFF,0x00,0x08,0x00,0x08,0x00,0x08,0x00,
+ 0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,
+ 0xC0,0x00,0xF0,0x00,0xAC,0x00,0xDF,0x00,
+ 0xAA,0x00,0xDD,0x00,0xAA,0x00,0xDD,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xC0,0x00,0xF0,0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,0xF0,
+ 0x00,0xC0,0x83,0x40,0xFE,0x21,0x3B,0x3C,
+ 0x63,0x3C,0xE3,0x3C,0xF1,0xFE,0x0D,0x0E,
+ 0x02,0x03,0xC2,0x02,0x7E,0x84,0xDC,0x3C,
+ 0x13,0x9F,0x10,0x9F,0x00,0x9C,0x01,0x90,
+ 0x01,0x80,0x01,0x80,0x11,0x80,0x12,0x81,
+ 0xEE,0x19,0xC6,0x39,0x42,0xBD,0x04,0xFF,
+ 0x87,0xFF,0xFF,0x78,0xFF,0x00,0x8E,0x00,
+ 0x33,0xCE,0x33,0xCE,0x33,0xCE,0x33,0xCE,
+ 0x97,0xEE,0xCF,0x3C,0xFE,0x00,0x7C,0x00,
+ 0x04,0xFB,0x03,0xFC,0x00,0xFF,0x10,0xEF,
+ 0x90,0x6F,0x52,0x8C,0x7F,0x80,0x47,0x80,
+ 0xA0,0x5F,0xC0,0x3F,0x00,0xFF,0x04,0xFB,
+ 0x0D,0xF2,0x4A,0x31,0xFE,0x01,0xE2,0x01,
+ 0xF8,0x40,0x78,0xC0,0xF8,0x80,0xF0,0x80,
+ 0xF0,0x00,0xE0,0x00,0xC0,0x00,0x00,0x00,
+ 0x02,0x03,0x02,0x03,0x06,0x03,0x07,0x01,
+ 0x07,0x01,0x03,0x00,0x01,0x00,0x00,0x00,
+ 0x1F,0x10,0x1F,0x10,0x0F,0x09,0x02,0x0F,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xC0,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x03,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xF8,0x08,0xF8,0x08,0xF0,0x90,0x40,0xF0,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x02,0x80,0x07,0x80,0x08,0x80,0x70,0x80,
+ 0x3C,0x80,0x07,0x80,0x78,0x00,0xFF,0x00,
+ 0x40,0x01,0xE0,0x01,0x10,0x01,0x0E,0x01,
+ 0x3C,0x01,0xE0,0x01,0x1E,0x00,0xFF,0x00,
+ 0xBF,0x00,0xCF,0x00,0xF0,0x00,0xFF,0x00,
+ 0x7F,0x00,0xFF,0x00,0xFE,0x00,0xFF,0x00,
+ 0xFD,0x00,0xF3,0x00,0x0F,0x00,0xFF,0x00,
+ 0xFE,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0x16,0x08,0x14,0x08,0x01,0x0C,0x11,0x06,
+ 0x02,0x01,0x05,0x00,0x03,0x00,0x05,0x00,
+ 0x68,0x10,0x28,0x10,0x80,0x30,0x88,0x60,
+ 0x40,0x80,0xA0,0x00,0xC0,0x00,0xA0,0x00,
+ 0xC9,0x3E,0x3C,0x03,0x0F,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x73,0xFC,0x3C,0xC0,0xF0,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,
+ 0x2C,0x10,0x18,0x24,0x00,0x38,0x30,0x0C,
+ 0x6B,0x04,0xB7,0x08,0x5E,0x08,0x7C,0x0E,
+ 0x05,0x00,0x03,0x00,0x05,0x00,0x02,0x01,
+ 0x11,0x06,0x01,0x0C,0x14,0x08,0x16,0x08,
+ 0x01,0x00,0x28,0x00,0x51,0x00,0x41,0xBE,
+ 0x0C,0xF3,0xAE,0x50,0xA6,0x00,0x00,0x00,
+ 0x80,0x00,0x02,0x00,0x55,0x00,0x1E,0xE0,
+ 0x40,0xBF,0xCC,0x33,0x9C,0x00,0x18,0x00,
+ 0x01,0x00,0x82,0x00,0x55,0x00,0x9E,0x60,
+ 0xC0,0x3F,0x4C,0xB3,0x1C,0x00,0x18,0x00,
+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0x00,
+ 0x40,0xBF,0xCC,0x33,0x9C,0x00,0x18,0x00,
+ 0x38,0xC7,0x00,0xFF,0x07,0xF8,0x3F,0xC0,
+ 0x7F,0x80,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0xC0,0x3F,0xC0,0x20,0xCE,0x20,0xC0,0x20,
+ 0xDF,0x20,0xDF,0x20,0xF3,0x3F,0x19,0xDF,
+ 0x7C,0x83,0x71,0x8C,0x41,0xB0,0x11,0xC0,
+ 0x11,0x80,0x01,0x80,0x81,0x80,0x11,0x00,
+ 0x00,0xFF,0x10,0x00,0x10,0x00,0x00,0x00,
+ 0x10,0x00,0x00,0x00,0x10,0x00,0x10,0x00,
+ 0x00,0xFF,0x08,0x00,0x08,0x00,0x08,0x00,
+ 0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,
+ 0x3F,0xC0,0xCF,0x30,0xA3,0x0C,0xDC,0x03,
+ 0xAA,0x00,0xDD,0x00,0xAA,0x00,0xDD,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0x3F,0xC0,0xCF,0x30,0xA3,0x0C,0xDC,0x03,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0x9F,0x60,0x8F,0x30,0x2F,0x10,0x77,0x10,
+ 0xA0,0x00,0xC0,0x00,0xA0,0x00,0x40,0x80,
+ 0x88,0x60,0x80,0x30,0x28,0x10,0x68,0x10,
+ 0x10,0x0C,0x2C,0x10,0x18,0x24,0x00,0x38,
+ 0x30,0x0C,0x6B,0x04,0x77,0x08,0x5E,0x08,
+ 0x3C,0x0E,0x6C,0x06,0x57,0x08,0x3B,0x0C,
+ 0x30,0x0E,0x0C,0x10,0x26,0x18,0x10,0x0C,
+ 0x00,0x00,0x80,0x00,0xC2,0x10,0xD6,0x78,
+ 0x6C,0x9B,0xFD,0x0E,0xDF,0x00,0xF5,0x00,
+ 0x00,0x00,0x00,0x00,0x06,0x00,0x47,0x88,
+ 0xEB,0x9C,0x3C,0xDF,0xBF,0x78,0xAB,0x00
+};
+
+/* End of BIGMAP_TILES.C */
diff --git a/gbdk/gbdk-lib/examples/ap/large_map/bigmap_tiles.h b/gbdk/gbdk-lib/examples/ap/large_map/bigmap_tiles.h
new file mode 100644
index 00000000..708077e2
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/large_map/bigmap_tiles.h
@@ -0,0 +1,107 @@
+/*
+
+ BIGMAP_TILES.H
+
+ Include File.
+
+ Info:
+ Form : All tiles as one unit.
+ Format : Gameboy 4 color.
+ Compression : None.
+ Counter : None.
+ Tile size : 8 x 8
+ Tiles : 0 to 240
+
+ Palette colors : Included.
+ SGB Palette : None.
+ CGB Palette : None.
+
+ Convert to metatiles : No.
+
+ This file was generated by GBTD v2.2
+
+*/
+
+#ifndef __bigmap_tiles_h_INCLUDE
+#define __bigmap_tiles_h_INCLUDE
+
+/* Bank of tiles. */
+#define bigmap_tilesBank 0
+
+/* Super Gameboy palette 0 */
+#define bigmap_tilesSGBPal0c0 0
+#define bigmap_tilesSGBPal0c1 0
+#define bigmap_tilesSGBPal0c2 10240
+#define bigmap_tilesSGBPal0c3 400
+
+/* Super Gameboy palette 1 */
+#define bigmap_tilesSGBPal1c0 6076
+#define bigmap_tilesSGBPal1c1 8935
+#define bigmap_tilesSGBPal1c2 6596
+#define bigmap_tilesSGBPal1c3 5344
+
+/* Super Gameboy palette 2 */
+#define bigmap_tilesSGBPal2c0 6076
+#define bigmap_tilesSGBPal2c1 8935
+#define bigmap_tilesSGBPal2c2 6596
+#define bigmap_tilesSGBPal2c3 5344
+
+/* Super Gameboy palette 3 */
+#define bigmap_tilesSGBPal3c0 6076
+#define bigmap_tilesSGBPal3c1 8935
+#define bigmap_tilesSGBPal3c2 6596
+#define bigmap_tilesSGBPal3c3 5344
+
+/* Gameboy Color palette 0 */
+#define bigmap_tilesCGBPal0c0 0
+#define bigmap_tilesCGBPal0c1 10570
+#define bigmap_tilesCGBPal0c2 20083
+#define bigmap_tilesCGBPal0c3 32767
+
+/* Gameboy Color palette 1 */
+#define bigmap_tilesCGBPal1c0 6076
+#define bigmap_tilesCGBPal1c1 8935
+#define bigmap_tilesCGBPal1c2 6596
+#define bigmap_tilesCGBPal1c3 5344
+
+/* Gameboy Color palette 2 */
+#define bigmap_tilesCGBPal2c0 6076
+#define bigmap_tilesCGBPal2c1 8935
+#define bigmap_tilesCGBPal2c2 6596
+#define bigmap_tilesCGBPal2c3 5344
+
+/* Gameboy Color palette 3 */
+#define bigmap_tilesCGBPal3c0 6076
+#define bigmap_tilesCGBPal3c1 8935
+#define bigmap_tilesCGBPal3c2 6596
+#define bigmap_tilesCGBPal3c3 5344
+
+/* Gameboy Color palette 4 */
+#define bigmap_tilesCGBPal4c0 6076
+#define bigmap_tilesCGBPal4c1 8935
+#define bigmap_tilesCGBPal4c2 6596
+#define bigmap_tilesCGBPal4c3 5344
+
+/* Gameboy Color palette 5 */
+#define bigmap_tilesCGBPal5c0 6076
+#define bigmap_tilesCGBPal5c1 8935
+#define bigmap_tilesCGBPal5c2 6596
+#define bigmap_tilesCGBPal5c3 5344
+
+/* Gameboy Color palette 6 */
+#define bigmap_tilesCGBPal6c0 6076
+#define bigmap_tilesCGBPal6c1 8935
+#define bigmap_tilesCGBPal6c2 6596
+#define bigmap_tilesCGBPal6c3 5344
+
+/* Gameboy Color palette 7 */
+#define bigmap_tilesCGBPal7c0 6076
+#define bigmap_tilesCGBPal7c1 8935
+#define bigmap_tilesCGBPal7c2 6596
+#define bigmap_tilesCGBPal7c3 5344
+/* Start of tile array. */
+extern const unsigned char bigmap_tiles[];
+
+#endif
+
+/* End of BIGMAP_TILES.H */
diff --git a/gbdk/gbdk-lib/examples/ap/large_map/large_map.c b/gbdk/gbdk-lib/examples/ap/large_map/large_map.c
new file mode 100644
index 00000000..9349beb4
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/large_map/large_map.c
@@ -0,0 +1,96 @@
+#include <gb/gb.h>
+#include <stdint.h>
+
+#include "bigmap_map.h"
+#include "bigmap_tiles.h"
+
+#define camera_max_y ((bigmap_mapHeight - 18) * 8)
+#define camera_max_x ((bigmap_mapWidth - 20) * 8)
+
+#define MIN(A,B) ((A)<(B)?(A):(B))
+
+uint8_t joy;
+
+// current and old positions of the camera in pixels
+uint16_t camera_x, camera_y, old_camera_x, old_camera_y;
+// current and old position of the map in tiles
+uint8_t map_pos_x, map_pos_y, old_map_pos_x, old_map_pos_y;
+// redraw flag, indicates that camera position was changed
+uint8_t redraw;
+
+void set_camera() {
+ // update hardware scroll position
+ SCY_REG = camera_y; SCX_REG = camera_x;
+ // up or down
+ map_pos_y = (uint8_t)(camera_y >> 3u);
+ if (map_pos_y != old_map_pos_y) {
+ if (camera_y < old_camera_y) {
+ set_bkg_submap(map_pos_x, map_pos_y, MIN(21u, bigmap_mapWidth-map_pos_x), 1, bigmap_map, bigmap_mapWidth);
+ } else {
+ if ((bigmap_mapHeight - 18u) > map_pos_y) set_bkg_submap(map_pos_x, map_pos_y + 18u, MIN(21u, bigmap_mapWidth-map_pos_x), 1, bigmap_map, bigmap_mapWidth);
+ }
+ old_map_pos_y = map_pos_y;
+ }
+ // left or right
+ map_pos_x = (uint8_t)(camera_x >> 3u);
+ if (map_pos_x != old_map_pos_x) {
+ if (camera_x < old_camera_x) {
+ set_bkg_submap(map_pos_x, map_pos_y, 1, MIN(19u, bigmap_mapHeight - map_pos_y), bigmap_map, bigmap_mapWidth);
+ } else {
+ if ((bigmap_mapWidth - 20u) > map_pos_x) set_bkg_submap(map_pos_x + 20u, map_pos_y, 1, MIN(19u, bigmap_mapHeight - map_pos_y), bigmap_map, bigmap_mapWidth);
+ }
+ old_map_pos_x = map_pos_x;
+ }
+ // set old camera position to current camera position
+ old_camera_x = camera_x, old_camera_y = camera_y;
+}
+
+void main(){
+ DISPLAY_OFF;
+ SHOW_BKG;
+ set_bkg_data(0, 241u, bigmap_tiles);
+
+ map_pos_x = map_pos_y = 0;
+ old_map_pos_x = old_map_pos_y = 255;
+ set_bkg_submap(map_pos_x, map_pos_y, 20, 18, bigmap_map, bigmap_mapWidth);
+ DISPLAY_ON;
+
+ camera_x = camera_y = 0;
+ old_camera_x = camera_x; old_camera_y = camera_y;
+
+ redraw = FALSE;
+
+ SCX_REG = camera_x; SCY_REG = camera_y;
+ while (TRUE) {
+ joy = joypad();
+ // up or down
+ if (joy & J_UP) {
+ if (camera_y) {
+ camera_y--;
+ redraw = TRUE;
+ }
+ } else if (joy & J_DOWN) {
+ if (camera_y < camera_max_y) {
+ camera_y++;
+ redraw = TRUE;
+ }
+ }
+ // left or right
+ if (joy & J_LEFT) {
+ if (camera_x) {
+ camera_x--;
+ redraw = TRUE;
+ }
+ } else if (joy & J_RIGHT) {
+ if (camera_x < camera_max_x) {
+ camera_x++;
+ redraw = TRUE;
+ }
+ }
+ if (redraw) {
+ wait_vbl_done();
+ set_camera();
+ redraw = FALSE;
+ } else wait_vbl_done();
+ }
+} \ No newline at end of file
diff --git a/gbdk/gbdk-lib/examples/ap/lcd_isr_wobble/Makefile b/gbdk/gbdk-lib/examples/ap/lcd_isr_wobble/Makefile
new file mode 100644
index 00000000..cbb088bf
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/lcd_isr_wobble/Makefile
@@ -0,0 +1,17 @@
+CC = ../../../bin/lcc -msm83:ap -Wl-j -Wm-yS
+
+BINS = lcd_isr_wobble.pocket
+
+all: $(BINS)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+# Compile and link single file in one pass
+%.pocket: %.c
+ $(CC) -o $@ $<
+
+clean:
+ rm -f *.o *.lst *.map *.pocket *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi
+
diff --git a/gbdk/gbdk-lib/examples/ap/lcd_isr_wobble/lcd_isr_wobble.c b/gbdk/gbdk-lib/examples/ap/lcd_isr_wobble/lcd_isr_wobble.c
new file mode 100644
index 00000000..a76e6d1b
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/lcd_isr_wobble/lcd_isr_wobble.c
@@ -0,0 +1,28 @@
+#include <gb/gb.h>
+#include <stdint.h>
+#include <stdio.h>
+
+#include <gb/emu_debug.h>
+
+const uint8_t scanline_offsets_tbl[] = {0, 1, 2, 3, 3, 2, 1, 0, 0, 1, 2, 3, 3, 2, 1, 0};
+const uint8_t * scanline_offsets = scanline_offsets_tbl;
+
+void scanline_isr() {
+ SCX_REG = scanline_offsets[LY_REG & (uint8_t)7];
+}
+
+
+void main() {
+ printf("This is\na wobble\ntest\nfor DMG\n|\n|\n|\n|\n|");
+
+ CRITICAL {
+ STAT_REG = STATF_MODE01 | STATF_MODE00;
+ add_LCD(scanline_isr);
+ }
+ set_interrupts(VBL_IFLAG | LCD_IFLAG);
+
+ while (1) {
+ wait_vbl_done();
+ scanline_offsets = &scanline_offsets_tbl[(uint8_t)(sys_time >> 2) & 0x07u];
+ }
+} \ No newline at end of file
diff --git a/gbdk/gbdk-lib/examples/ap/linkerfile/Makefile b/gbdk/gbdk-lib/examples/ap/linkerfile/Makefile
new file mode 100644
index 00000000..23f0ba0f
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/linkerfile/Makefile
@@ -0,0 +1,70 @@
+#
+# A Makefile that compiles all .c and .s files in "src" and "res"
+# subdirectories and places the output in a "obj" subdirectory
+#
+
+# If you move this project you can change the directory
+# to match your GBDK root directory (ex: GBDK_HOME = "C:/GBDK/"
+GBDK_HOME = ../../../
+
+LCC = $(GBDK_HOME)bin/lcc
+
+# You can set flags for LCC here
+# For example, you can uncomment the line below to turn on debug output
+LCCFLAGS = -msm83:ap
+# LCCFLAGS += -debug
+# LCCFLAGS += -v
+
+# You can set the name of the .pocket ROM file here
+PROJECTNAME = Example
+
+SRCDIR = src
+OBJDIR = obj
+RESDIR = res
+BINS = $(OBJDIR)/$(PROJECTNAME).pocket
+CSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.c))) $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.c)))
+ASMSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.s)))
+OBJS = $(CSOURCES:%.c=$(OBJDIR)/%.o) $(ASMSOURCES:%.s=$(OBJDIR)/%.o)
+
+all: prepare $(BINS)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+# Compile .c files in "src/" to .o object files
+$(OBJDIR)/%.o: $(SRCDIR)/%.c
+ $(LCC) $(LCCFLAGS) -c -o $@ $<
+
+# Compile .c files in "res/" to .o object files
+$(OBJDIR)/%.o: $(RESDIR)/%.c
+ $(LCC) $(LCCFLAGS) -c -o $@ $<
+
+# Compile .s assembly files in "src/" to .o object files
+$(OBJDIR)/%.o: $(SRCDIR)/%.s
+ $(LCC) $(LCCFLAGS) -c -o $@ $<
+
+# If needed, compile .c files i n"src/" to .s assembly files
+# (not required if .c is compiled directly to .o)
+$(OBJDIR)/%.s: $(SRCDIR)/%.c
+ $(LCC) $(LCCFLAGS) -S -o $@ $<
+
+
+$(OBJDIR)/linkfile.lk: $(OBJS)
+ rm -f $@
+ @for obj in $(OBJS); do \
+ echo $$obj >>$@; \
+ done
+
+# Link the compiled object files (via linkerfile) into a .pocket ROM file
+$(BINS): $(OBJDIR)/linkfile.lk
+ $(LCC) $(LCCFLAGS) -o $(BINS) -Wl-f$<
+
+prepare:
+ mkdir -p $(OBJDIR)
+ mkdir -p $(RESDIR)
+
+clean:
+# rm -f *.pocket *.ihx *.cdb *.adb *.noi *.map
+ rm -f $(OBJDIR)/*.*
+
diff --git a/gbdk/gbdk-lib/examples/ap/linkerfile/Readme.md b/gbdk/gbdk-lib/examples/ap/linkerfile/Readme.md
new file mode 100644
index 00000000..dada1094
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/linkerfile/Readme.md
@@ -0,0 +1,18 @@
+
+# Example of how to use a linkerfile
+
+A linkerfile allows storing all the object files to be linked in a
+file which is passed to the linker instead of a list of filenames on
+the command line. This may be useful if your project has filenames
+that use up more length than will fit on the command line for Windows
+(8191 chars max).
+
+The typical extension for the linkerfile is ".lk".
+
+It is passed to sdldgb through lcc using `-Wl-f<pathtolinkerfile>`
+If calling sdldgb directly, use `-f<pathtolinkerfile>`
+
+The Makefile is configured to store all the compiled ".o" object files
+into `obj/linkerfile.lk`.
+
+
diff --git a/gbdk/gbdk-lib/examples/ap/linkerfile/src/main.c b/gbdk/gbdk-lib/examples/ap/linkerfile/src/main.c
new file mode 100644
index 00000000..0326df95
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/linkerfile/src/main.c
@@ -0,0 +1,15 @@
+#include <gb/gb.h>
+#include <stdint.h>
+
+
+void main(void)
+{
+ // Loop forever
+ while(1) {
+
+ // Game main loop processing goes here
+
+ // Done processing, yield CPU and wait for start of next frame
+ wait_vbl_done();
+ }
+}
diff --git a/gbdk/gbdk-lib/examples/ap/paint/Makefile b/gbdk/gbdk-lib/examples/ap/paint/Makefile
new file mode 100644
index 00000000..34252a27
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/paint/Makefile
@@ -0,0 +1,17 @@
+CC = ../../../bin/lcc -msm83:ap -Wl-j -Wm-yS
+
+BINS = paint.pocket
+
+all: $(BINS)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+# Compile and link single file in one pass
+%.pocket: %.c
+ $(CC) -o $@ $<
+
+clean:
+ rm -f *.o *.lst *.map *.pocket *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi
+
diff --git a/gbdk/gbdk-lib/examples/ap/paint/paint.c b/gbdk/gbdk-lib/examples/ap/paint/paint.c
new file mode 100644
index 00000000..8b9962b5
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/paint/paint.c
@@ -0,0 +1,528 @@
+#include <gb/gb.h>
+#include <stdint.h>
+#include <gb/drawing.h>
+
+#define NB_TOOLS 18
+#define NB_DATA_TILES 48
+
+#define ARROW 0
+#define PEN 1
+#define BRUSH 2
+#define FILL 3
+#define ERASER 4
+#define CROSS 5
+
+#define UNSELECTED 0
+#define SELECTED 1
+
+#define FIRST_TOOL 0
+#define LAST_TOOL 9
+#define FIRST_COLOR 10
+#define LAST_COLOR 13
+#define FIRST_MODE 14
+#define LAST_MODE 17
+
+typedef struct icon_info_
+{
+ uint8_t data_idx; /* Index of data in the data array */
+ uint8_t x, y, w, h; /* Position and size (in tiles) */
+ uint8_t up, down, left, right; /* Index of next icons (for cursor movements) */
+ uint8_t cursor; /* Cursor associated with icon */
+} icon_info;
+
+typedef struct cursor_info_
+{
+ uint8_t data_idx; /* Index of data in the data array */
+ uint8_t w, h; /* Size (in tiles) */
+ uint8_t hot_x, hot_y; /* Position of hot point, relatice to top-left of sprite (in pixels) */
+} cursor_info;
+
+const icon_info icons[] =
+{
+ /* Pen */
+ { 0, 0, 0, 2, 2, 10, 2, 1, 1, 1 }, /* 0 */
+ /* Brush */
+ { 4, 2, 0, 2, 2, 14, 3, 0, 0, 2 }, /* 1 */
+ /* Fill */
+ { 8, 0, 2, 2, 2, 0, 4, 3, 3, 3 }, /* 2 */
+ /* Eraser */
+ { 12, 2, 2, 2, 2, 1, 5, 2, 2, 4 }, /* 3 */
+ /* Line */
+ { 16, 0, 4, 2, 2, 2, 6, 5, 5, 5 }, /* 4 */
+ /* Line */
+ { 20, 2, 4, 2, 2, 3, 7, 4, 4, 5 }, /* 5 */
+ /* Rectangle */
+ { 24, 0, 6, 2, 2, 4, 8, 7, 7, 5 }, /* 6 */
+ /* Oval */
+ { 28, 2, 6, 2, 2, 5, 9, 6, 6, 5 }, /* 7 */
+ /* Filled rectangle */
+ { 32, 0, 8, 2, 2, 6, 10, 9, 9, 5 }, /* 8 */
+ /* Filled oval */
+ { 36, 2, 8, 2, 2, 7, 14, 8, 8, 5 }, /* 9 */
+ /* Color */
+ { 40, 0, 10, 1, 1, 8, 11, 16, 12, 0 }, /* 10 */
+ { 41, 0, 11, 1, 1, 10, 0, 17, 13, 0 }, /* 11 */
+ { 42, 1, 10, 1, 1, 8, 13, 10, 14, 0 }, /* 12 */
+ { 43, 1, 11, 1, 1, 12, 0, 11, 15, 0 }, /* 13 */
+ /* Mode */
+ { 44, 2, 10, 1, 1, 9, 15, 12, 16, 0 }, /* 14 */
+ { 45, 2, 11, 1, 1, 14, 1, 13, 17, 0 }, /* 15 */
+ { 46, 3, 10, 1, 1, 9, 17, 14, 10, 0 }, /* 16 */
+ { 47, 3, 11, 1, 1, 16, 1, 15, 11, 0 } /* 17 */
+};
+
+const unsigned char data[NB_DATA_TILES][0x10] =
+{
+ /* Pen */
+ { 0x00,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x01 },
+ { 0x7E,0x02,0x7D,0x05,0x7B,0x0A,0x77,0x14,0x7F,0x18,0x7F,0x27,0x7F,0x00,0x00,0x7F },
+ { 0x00,0x00,0xFE,0x01,0xFE,0x0D,0xF6,0x15,0xEE,0x29,0xDE,0x51,0xBE,0xA1,0x7E,0x41 },
+ { 0xFE,0x81,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0xFD,0xFE,0x01,0x00,0xFF },
+ /* Brush */
+ { 0x00,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x01 },
+ { 0x7E,0x02,0x7D,0x0D,0x7F,0x1E,0x7F,0x1E,0x7F,0x1D,0x7F,0x11,0x7F,0x00,0x00,0x7F },
+ { 0x00,0x00,0xFE,0x01,0xFE,0x0D,0xF6,0x15,0xEE,0x29,0xDE,0x51,0xBE,0xA1,0x7E,0x41 },
+ { 0xFE,0x81,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0xFD,0xFE,0xFD,0xFE,0x01,0x00,0xFF },
+ /* Fill */
+ { 0x00,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x01,0x7F,0x02,0x7E,0x0C,0x7D,0x18,0x7E,0x1D },
+ { 0x7F,0x1B,0x7F,0x19,0x7F,0x18,0x7F,0x08,0x7F,0x08,0x7F,0x08,0x7F,0x00,0x00,0x7F },
+ { 0x00,0x00,0xFE,0x01,0xFE,0x81,0xFE,0x41,0x7E,0x21,0xBE,0x71,0x5E,0xE9,0xAE,0xC5 },
+ { 0x5E,0x89,0xBE,0x11,0xFE,0xA1,0xFE,0x41,0xFE,0x01,0xFE,0x01,0xFE,0x01,0x00,0xFF },
+ /* Eraser */
+ { 0x00,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x01,0x7E,0x02,0x7C,0x04 },
+ { 0x78,0x08,0x7F,0x1F,0x71,0x11,0x7F,0x1F,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x00,0x7F },
+ { 0x00,0x00,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0xF9,0x1E,0x19,0x2E,0x29,0x5E,0x51 },
+ { 0xBE,0xA1,0x7E,0x41,0xFE,0x81,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0x00,0xFF },
+ /* Line */
+ { 0x00,0x00,0x7F,0x00,0x7F,0x20,0x7F,0x10,0x7F,0x08,0x7F,0x04,0x7F,0x02,0x7F,0x01 },
+ { 0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x00,0x7F },
+ { 0x00,0x00,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01 },
+ { 0xFE,0x81,0xFE,0x41,0xFE,0x21,0xFE,0x11,0xFE,0x09,0xFE,0x05,0xFE,0x01,0x00,0xFF },
+ /* Arc */
+ { 0x00,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x1E,0x7F,0x01,0x7F,0x00,0x7F,0x00,0x7F,0x00 },
+ { 0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x00,0x7F },
+ { 0x00,0x00,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x81,0xFE,0x41,0xFE,0x21,0xFE,0x11 },
+ { 0xFE,0x11,0xFE,0x09,0xFE,0x09,0xFE,0x09,0xFE,0x09,0xFE,0x01,0xFE,0x01,0x00,0xFF },
+ /* Rectangle */
+ { 0x00,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x3F,0x7F,0x20,0x7F,0x20,0x7F,0x20,0x7F,0x20 },
+ { 0x7F,0x20,0x7F,0x20,0x7F,0x20,0x7F,0x20,0x7F,0x3F,0x7F,0x00,0x7F,0x00,0x00,0x7F },
+ { 0x00,0x00,0xFE,0x01,0xFE,0x01,0xFE,0xFD,0xFE,0x05,0xFE,0x05,0xFE,0x05,0xFE,0x05 },
+ { 0xFE,0x05,0xFE,0x05,0xFE,0x05,0xFE,0x05,0xFE,0xFD,0xFE,0x01,0xFE,0x01,0x00,0xFF },
+ /* Oval */
+ { 0x00,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x03,0x7F,0x0C,0x7F,0x10,0x7F,0x20,0x7F,0x20 },
+ { 0x7F,0x20,0x7F,0x20,0x7F,0x10,0x7F,0x0C,0x7F,0x03,0x7F,0x00,0x7F,0x00,0x00,0x7F },
+ { 0x00,0x00,0xFE,0x01,0xFE,0x01,0xFE,0xC1,0xFE,0x31,0xFE,0x09,0xFE,0x05,0xFE,0x05 },
+ { 0xFE,0x05,0xFE,0x05,0xFE,0x09,0xFE,0x31,0xFE,0xC1,0xFE,0x01,0xFE,0x01,0x00,0xFF },
+ /* Filled rectangle */
+ { 0x00,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x3F,0x6A,0x3F,0x75,0x3F,0x6A,0x3F,0x75,0x3F },
+ { 0x6A,0x3F,0x75,0x3F,0x6A,0x3F,0x75,0x3F,0x7F,0x3F,0x7F,0x00,0x7F,0x00,0x00,0x7F },
+ { 0x00,0x00,0xFE,0x01,0xFE,0x01,0xFE,0xFD,0xAE,0xFD,0x56,0xFD,0xAE,0xFD,0x56,0xFD },
+ { 0xAE,0xFD,0x56,0xFD,0xAE,0xFD,0x56,0xFD,0xFE,0xFD,0xFE,0x01,0xFE,0x01,0x00,0xFF },
+ /* Filled oval */
+ { 0x00,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x03,0x7E,0x0F,0x75,0x1F,0x6A,0x3F,0x75,0x3F },
+ { 0x6A,0x3F,0x75,0x3F,0x7A,0x1F,0x7D,0x0F,0x7F,0x03,0x7F,0x00,0x7F,0x00,0x00,0x7F },
+ { 0x00,0x00,0xFE,0x01,0xFE,0x01,0xFE,0xC1,0xBE,0xF1,0x5E,0xF9,0xAE,0xFD,0x56,0xFD },
+ { 0xAE,0xFD,0x56,0xFD,0xAE,0xF9,0x7E,0xF1,0xFE,0xC1,0xFE,0x01,0xFE,0x01,0x00,0xFF },
+ /* Color */
+ { 0x00,0x00,0x7F,0x7F,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40 },
+ { 0x40,0x7F,0x40,0x7F,0x40,0x7F,0x40,0x7F,0x40,0x7F,0x40,0x7F,0x7F,0x7F,0x00,0x7F },
+ { 0x00,0x00,0xFE,0xFF,0xFE,0x03,0xFE,0x03,0xFE,0x03,0xFE,0x03,0xFE,0x03,0xFE,0x03 },
+ { 0xFE,0xFF,0xFE,0xFF,0xFE,0xFF,0xFE,0xFF,0xFE,0xFF,0xFE,0xFF,0xFE,0xFF,0x00,0xFF },
+ /* Mode */
+ { 0x00,0x00,0x7F,0x00,0x7F,0x0C,0x7F,0x10,0x7F,0x08,0x7F,0x04,0x7F,0x18,0x7F,0x00 },
+ { 0x7F,0x00,0x7F,0x08,0x7F,0x14,0x7F,0x14,0x7F,0x14,0x7F,0x08,0x7F,0x00,0x00,0x7F },
+ { 0x00,0x01,0xFE,0x01,0xFE,0x29,0xFE,0x29,0xFE,0x11,0xFE,0x29,0xFE,0x29,0xFE,0x01 },
+ { 0xFE,0x01,0xFE,0x11,0xFE,0x29,0xFE,0x39,0xFE,0x29,0xFE,0x29,0xFE,0x01,0x00,0xFF }
+};
+
+const unsigned char selected_data[NB_DATA_TILES][0x10] =
+{
+ /* Pen */
+ { 0xFF,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFE },
+ { 0x81,0xFD,0x82,0xFA,0x84,0xF5,0x88,0xEB,0x80,0xE7,0x80,0xD8,0x80,0xFF,0xFF,0x80 },
+ { 0xFF,0xFF,0x01,0xFE,0x01,0xF2,0x09,0xEA,0x11,0xD6,0x21,0xAE,0x41,0x5E,0x81,0xBE },
+ { 0x01,0x7E,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0x02,0x01,0xFE,0xFF,0x00 },
+ /* Brush */
+ { 0xFF,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFE },
+ { 0x81,0xFD,0x82,0xF2,0x80,0xE1,0x80,0xE1,0x80,0xE2,0x80,0xEE,0x80,0xFF,0xFF,0x80 },
+ { 0xFF,0xFF,0x01,0xFE,0x01,0xF2,0x09,0xEA,0x11,0xD6,0x21,0xAE,0x41,0x5E,0x81,0xBE },
+ { 0x01,0x7E,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0x02,0x01,0x02,0x01,0xFE,0xFF,0x00 },
+ /* Fill */
+ { 0xFF,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFE,0x80,0xFD,0x81,0xF3,0x82,0xE7,0x81,0xE2 },
+ { 0x80,0xE4,0x80,0xE7,0x80,0xE7,0x80,0xF7,0x80,0xF7,0x80,0xF7,0x80,0xFF,0xFF,0x80 },
+ { 0xFF,0xFF,0x01,0xFE,0x01,0x7E,0x01,0xBE,0x81,0xDE,0x41,0x8E,0xA1,0x16,0x51,0x3A },
+ { 0xA1,0x76,0x41,0xEE,0x01,0x5E,0x01,0xBE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0xFF,0x00 },
+ /* Eraser */
+ { 0xFF,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFE,0x81,0xFD,0x83,0xFB },
+ { 0x87,0xF7,0x80,0xE0,0x8E,0xEE,0x80,0xE0,0x80,0xFF,0x80,0xFF,0x80,0xFF,0xFF,0x80 },
+ { 0xFF,0xFF,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0x06,0xE1,0xE6,0xD1,0xD6,0xA1,0xAE },
+ { 0x41,0x5E,0x81,0xBE,0x01,0x7E,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0xFF,0x00 },
+ /* Line */
+ { 0xFF,0xFF,0x80,0xFF,0x80,0xDF,0x80,0xEF,0x80,0xF7,0x80,0xFB,0x80,0xFD,0x80,0xFE },
+ { 0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0xFF,0x80 },
+ { 0xFF,0xFF,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE },
+ { 0x01,0x7E,0x01,0xBE,0x01,0xDE,0x01,0xEE,0x01,0xF6,0x01,0xFA,0x01,0xFE,0xFF,0x00 },
+ /* Arc */
+ { 0xFF,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xE1,0x80,0xFE,0x80,0xFF,0x80,0xFF,0x80,0xFF },
+ { 0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0xFF,0x80 },
+ { 0xFF,0xFF,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0x7E,0x01,0xBE,0x01,0xDE,0x01,0xEE },
+ { 0x01,0xEE,0x01,0xF6,0x01,0xF6,0x01,0xF6,0x01,0xF6,0x01,0xFE,0x01,0xFE,0xFF,0x00 },
+ /* Rectangle */
+ { 0xFF,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xC0,0x80,0xDF,0x80,0xDF,0x80,0xDF,0x80,0xDF },
+ { 0x80,0xDF,0x80,0xDF,0x80,0xDF,0x80,0xDF,0x80,0xC0,0x80,0xFF,0x80,0xFF,0xFF,0x80 },
+ { 0xFF,0xFF,0x01,0xFE,0x01,0xFE,0x01,0x02,0x01,0xFA,0x01,0xFA,0x01,0xFA,0x01,0xFA },
+ { 0x01,0xFA,0x01,0xFA,0x01,0xFA,0x01,0xFA,0x01,0x02,0x01,0xFE,0x01,0xFE,0xFF,0x00 },
+ /* Oval */
+ { 0xFF,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFC,0x80,0xF3,0x80,0xEF,0x80,0xDF,0x80,0xDF },
+ { 0x80,0xDF,0x80,0xDF,0x80,0xEF,0x80,0xF3,0x80,0xFC,0x80,0xFF,0x80,0xFF,0xFF,0x80 },
+ { 0xFF,0xFF,0x01,0xFE,0x01,0xFE,0x01,0x3E,0x01,0xCE,0x01,0xF6,0x01,0xFA,0x01,0xFA },
+ { 0x01,0xFA,0x01,0xFA,0x01,0xF6,0x01,0xCE,0x01,0x3E,0x01,0xFE,0x01,0xFE,0xFF,0x00 },
+ /* Filled rectangle */
+ { 0xFF,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xC0,0x9F,0xC0,0x9F,0xC0,0x9F,0xC0,0x9F,0xC0 },
+ { 0x9F,0xC0,0x9F,0xC0,0x9F,0xC0,0x9F,0xC0,0x80,0xC0,0x80,0xFF,0x80,0xFF,0xFF,0x80 },
+ { 0xFF,0xFF,0x01,0xFE,0x01,0xFE,0x01,0x02,0xF9,0x02,0xF9,0x02,0xF9,0x02,0xF9,0x02 },
+ { 0xF9,0x02,0xF9,0x02,0xF9,0x02,0xF9,0x02,0x01,0x02,0x01,0xFE,0x01,0xFE,0xFF,0x00 },
+ /* Filled oval */
+ { 0xFF,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFC,0x83,0xF0,0x8F,0xE0,0x9F,0xC0,0x9F,0xC0 },
+ { 0x9F,0xC0,0x9F,0xC0,0x8F,0xE0,0x83,0xF0,0x80,0xFC,0x80,0xFF,0x80,0xFF,0xFF,0x80 },
+ { 0xFF,0xFF,0x01,0xFE,0x01,0xFE,0x01,0x3E,0xC1,0x0E,0xF1,0x06,0xF9,0x02,0xF9,0x02 },
+ { 0xF9,0x02,0xF9,0x02,0xF1,0x06,0xC1,0x0E,0x01,0x3E,0x01,0xFE,0x01,0xFE,0xFF,0x00 },
+ /* Color */
+ { 0x00,0x00,0x7F,0x7F,0x61,0x61,0x52,0x52,0x4C,0x4C,0x4C,0x4C,0x52,0x52,0x61,0x61 },
+ { 0x40,0x5E,0x40,0x6D,0x40,0x73,0x40,0x73,0x40,0x6D,0x40,0x5E,0x7F,0x7F,0x00,0x7F },
+ { 0x00,0x00,0xFE,0xFF,0xFE,0x87,0xFE,0x4B,0xFE,0x33,0xFE,0x33,0xFE,0x4B,0xFE,0x87 },
+ { 0x7A,0x7B,0xB6,0xB7,0xCE,0xCF,0xCE,0xCF,0xB6,0xB7,0x7A,0x7B,0xFE,0xFF,0x00,0xFF },
+ /* Mode */
+ { 0x00,0x00,0x7F,0x7F,0x73,0x73,0x6F,0x6F,0x77,0x77,0x7B,0x7B,0x67,0x67,0x7F,0x7F },
+ { 0x7F,0x7F,0x77,0x77,0x6B,0x6B,0x6B,0x6B,0x6B,0x6B,0x77,0x77,0x7F,0x7F,0x00,0x7F },
+ { 0x00,0x01,0xFE,0xFF,0xD6,0xD7,0xD6,0xD7,0xEE,0xEF,0xD6,0xD7,0xD6,0xD7,0xFE,0xFF },
+ { 0xFE,0xFF,0xEE,0xEF,0xD6,0xD7,0xC6,0xC7,0xD6,0xD7,0xD6,0xD7,0xFE,0xFF,0x00,0xFF }
+};
+
+const cursor_info cursors[] =
+{
+ /* Arrow */
+ { 0, 1, 1, 0, 0 },
+ /* Pen */
+ { 1, 2, 2, 0, 15 },
+ /* Brush */
+ { 5, 2, 2, 0, 15 },
+ /* Fill */
+ { 9, 2, 2, 2, 15 },
+ /* Eraser */
+ { 13, 2, 2, 0, 15 },
+ /* Cross */
+ { 17, 2, 2, 5, 10 }
+};
+
+const unsigned char cursors_data[][0x10] = {
+ /* Arrow */
+ { 0xFF,0x00,0xFF,0x7E,0xFF,0x7C,0xFE,0x78,0xFF,0x7C,0xFF,0x6E,0xFF,0x46,0xEF,0x00 },
+ /* Pen */
+ { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x03,0x00,0x07,0x01 },
+ { 0x0F,0x02,0x1F,0x05,0x3F,0x0A,0x7F,0x14,0x7E,0x28,0xFC,0x30,0xF8,0x40,0x60,0x00 },
+ { 0x00,0x00,0x00,0x00,0x3C,0x00,0x7C,0x18,0xFC,0x28,0xFC,0x50,0xF8,0xA0,0xF0,0x40 },
+ { 0xE0,0x80,0xC0,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
+ /* Brush */
+ { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x03,0x00,0x07,0x01,0x0F,0x02 },
+ { 0x1F,0x05,0x7F,0x0A,0xFF,0x34,0xFE,0x78,0xFC,0x78,0xFC,0x70,0xF8,0x40,0x60,0x00 },
+ { 0x00,0x00,0x00,0x00,0x78,0x00,0xF8,0x30,0xF8,0x50,0xF8,0xA0,0xF0,0x40,0xE0,0x80 },
+ { 0xC0,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
+ /* Fill */
+ { 0x00,0x00,0x00,0x00,0x07,0x00,0x0F,0x02,0x1F,0x05,0x7F,0x08,0xFE,0x31,0xFD,0x63 },
+ { 0xFA,0x77,0xFD,0x6E,0xFF,0x64,0xFF,0x62,0xF7,0x21,0x73,0x20,0x70,0x20,0x50,0x00 },
+ { 0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0xC0,0x00,0xE0,0x80,0xF0,0xC0,0x78,0xA0 },
+ { 0xF8,0x10,0xF8,0x20,0xF0,0x40,0xE0,0x80,0xC0,0x00,0x80,0x00,0x00,0x00,0x00,0x00 },
+ /* Eraser */
+ { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x0F,0x03 },
+ { 0x1F,0x04,0x3F,0x08,0x7F,0x11,0xFF,0x22,0xFF,0x7D,0xFF,0x46,0xFF,0x7C,0x7E,0x00 },
+ { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x00,0xF0,0xE0 },
+ { 0xF0,0x60,0xF0,0xA0,0xF0,0x40,0xE0,0x80,0xC0,0x00,0x80,0x00,0x00,0x00,0x00,0x00 },
+ /* Cross */
+ { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0E,0x00,0x0E,0x04,0x0E,0x04 },
+ { 0x0E,0x04,0xFF,0x04,0xFB,0x7B,0xFF,0x04,0x0E,0x04,0x0E,0x04,0x0E,0x04,0x0E,0x00 },
+ { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
+ { 0x00,0x00,0xE0,0x00,0xE0,0xC0,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
+};
+
+unsigned char data_buffer[NB_DATA_TILES][0x10];
+
+const uint8_t colors[] = { WHITE, DKGREY, LTGREY, BLACK };
+const uint8_t modes[] = { SOLID, OR, XOR, AND };
+
+uint8_t current_tool;
+uint8_t current_color;
+uint8_t current_mode;
+uint8_t current_cursor;
+uint8_t menu_cursor_pos;
+
+uint8_t cursor_x;
+uint8_t cursor_y;
+
+void set_cursor()
+{
+ uint8_t x, y, i;
+
+ i = 0;
+ for(x = 0; x < cursors[current_cursor].w; x++)
+ for(y = 0; y < cursors[current_cursor].h; y++) {
+ set_sprite_data(i,
+ 1,
+ cursors_data[cursors[current_cursor].data_idx+i]);
+ set_sprite_tile(i, i);
+ set_sprite_prop(i, 0x10);
+ i++;
+ }
+ /* Hide unused sprites */
+ for(; i < 4; i++) {
+ move_sprite(i, 0, 0);
+ }
+}
+
+void move_cursor()
+{
+ uint8_t x, y;
+
+ for(x = 0; x < cursors[current_cursor].w; x++)
+ for(y = 0; y < cursors[current_cursor].h; y++)
+ move_sprite((x<<1)+y,
+ cursor_x+8 - cursors[current_cursor].hot_x + (x<<3),
+ cursor_y+16 - cursors[current_cursor].hot_y + (y<<3));
+}
+
+void move_menu_cursor()
+{
+ move_sprite(0,
+ ((icons[menu_cursor_pos].x+icons[menu_cursor_pos].w)<<3) + 4,
+ ((icons[menu_cursor_pos].y+icons[menu_cursor_pos].h)<<3) + 12);
+}
+
+void set_icon(uint8_t icon, uint8_t selected)
+{
+ uint8_t x, y;
+
+ for(x = 0; x < icons[icon].w; x++)
+ for(y = 0; y < icons[icon].h; y++) {
+ uint16_t index = icons[icon].data_idx+((uint16_t)x<<1)+y;
+ switch_data(icons[icon].x + x,
+ icons[icon].y + y,
+ selected ? selected_data[index] : data[index],
+ data_buffer[index]);
+ }
+}
+
+void change_icon(uint8_t icon, uint8_t selected)
+{
+ uint8_t x, y;
+
+ for(x = 0; x < icons[icon].w; x++)
+ for(y = 0; y < icons[icon].h; y++)
+ switch_data(icons[icon].x + x,
+ icons[icon].y + y,
+ (selected ?
+ selected_data[icons[icon].data_idx+((uint16_t)x<<1)+y] :
+ data[icons[icon].data_idx+((uint16_t)x<<1)+y]),
+ NULL);
+}
+
+void reset_icon(uint8_t icon)
+{
+ uint8_t x, y;
+
+ for(x = 0; x < icons[icon].w; x++)
+ for(y = 0; y < icons[icon].h; y++)
+ switch_data(icons[icon].x + x,
+ icons[icon].y + y,
+ data_buffer[icons[icon].data_idx+(x<<1)+y],
+ NULL);
+}
+
+void splash()
+{
+ uint8_t x, y;
+
+ cursor_x = 40;
+ cursor_y = 50;
+ current_cursor = PEN;
+ set_cursor();
+ move_cursor();
+ SHOW_SPRITES;
+
+ for(; cursor_x < 120; cursor_x++) {
+ wait_vbl_done();
+ move_cursor();
+ plot(cursor_x, cursor_y, BLACK, SOLID);
+ }
+ for(; cursor_y < 94; cursor_y++) {
+ wait_vbl_done();
+ move_cursor();
+ plot(cursor_x, cursor_y, BLACK, SOLID);
+ }
+ for(; cursor_x > 40; cursor_x--) {
+ wait_vbl_done();
+ move_cursor();
+ plot(cursor_x, cursor_y, BLACK, SOLID);
+ }
+ for(; cursor_y > 50; cursor_y--) {
+ wait_vbl_done();
+ move_cursor();
+ plot(cursor_x, cursor_y, BLACK, SOLID);
+ }
+ cursor_x = 160/2;
+ cursor_y = 144/2;
+ current_cursor = FILL;
+ set_cursor();
+ move_cursor();
+
+ for(y = 51; y < 94; y++)
+ for(x = 41; x < 120; x++)
+ plot(x, y, LTGREY, SOLID);
+
+ // HIDE_SPRITES;
+}
+
+void menu()
+{
+ uint8_t i, key;
+ uint8_t slowdown;
+ uint8_t cursor;
+
+ slowdown = 50;
+
+ for(i = 0; i < NB_TOOLS; i++)
+ set_icon(i,
+ i == FIRST_TOOL + current_tool ||
+ i == FIRST_COLOR + current_color ||
+ i == FIRST_MODE + current_mode);
+
+ cursor = current_cursor;
+ current_cursor = ARROW;
+ set_cursor();
+ move_menu_cursor();
+ SHOW_SPRITES;
+ waitpadup();
+ do {
+ wait_vbl_done();
+ key = joypad();
+ if(key & (J_UP|J_DOWN|J_LEFT|J_RIGHT)) {
+ if(key & J_UP)
+ menu_cursor_pos = icons[menu_cursor_pos].up;
+ if(key & J_DOWN)
+ menu_cursor_pos = icons[menu_cursor_pos].down;
+ if(key & J_LEFT)
+ menu_cursor_pos = icons[menu_cursor_pos].left;
+ if(key & J_RIGHT)
+ menu_cursor_pos = icons[menu_cursor_pos].right;
+ move_menu_cursor();
+ while(slowdown && key == joypad()) {
+ wait_vbl_done();
+ slowdown--;
+ }
+ slowdown = 10;
+ } else
+ slowdown = 50;
+ if(key & J_A) {
+ if( /* menu_cursor_pos >= FIRST_TOOL && */ menu_cursor_pos <= LAST_TOOL) {
+ if(menu_cursor_pos != /* FIRST_TOOL + */ current_tool) {
+ change_icon(/* FIRST_TOOL + */ current_tool, UNSELECTED);
+ current_tool = menu_cursor_pos /* - FIRST_TOOL */;
+ change_icon(/* FIRST_TOOL + */ current_tool, SELECTED);
+ cursor = icons[/* FIRST_TOOL + */ current_tool].cursor;
+ }
+ } else if(menu_cursor_pos >= FIRST_COLOR && menu_cursor_pos <= LAST_COLOR) {
+ if(menu_cursor_pos != FIRST_COLOR + current_color) {
+ change_icon(FIRST_COLOR + current_color, UNSELECTED);
+ current_color = menu_cursor_pos - FIRST_COLOR;
+ change_icon(FIRST_COLOR + current_color, SELECTED);
+ }
+ } else if(menu_cursor_pos >= FIRST_MODE && menu_cursor_pos <= LAST_MODE) {
+ if(menu_cursor_pos != FIRST_MODE + current_mode) {
+ change_icon(FIRST_MODE + current_mode, UNSELECTED);
+ current_mode = menu_cursor_pos - FIRST_MODE;
+ change_icon(FIRST_MODE + current_mode, SELECTED);
+ }
+ }
+ }
+ } while(key != J_SELECT);
+ waitpadup();
+ for(i = 0; i < NB_TOOLS; i++)
+ reset_icon(i);
+ HIDE_SPRITES;
+ current_cursor = cursor;
+}
+
+void run()
+{
+ uint8_t key;
+ uint8_t slowdown;
+ uint8_t drawn, erased;
+
+ slowdown = 10;
+ drawn = erased = 0;
+
+ set_cursor();
+ move_cursor();
+ SHOW_SPRITES;
+
+ while(1) {
+ wait_vbl_done();
+ key = joypad();
+ if(key & (J_UP|J_DOWN|J_LEFT|J_RIGHT)) {
+ if(key & J_UP && cursor_y > 0)
+ cursor_y--;
+ if(key & J_DOWN && cursor_y < 143)
+ cursor_y++;
+ if(key & J_LEFT && cursor_x > 0)
+ cursor_x--;
+ if(key & J_RIGHT && cursor_x < 159)
+ cursor_x++;
+ move_cursor();
+ while(slowdown && key == joypad()) {
+ wait_vbl_done();
+ slowdown--;
+ }
+ slowdown = 1;
+ drawn = erased = 0;
+ } else
+ slowdown = 10;
+ if(key & J_SELECT) {
+ HIDE_SPRITES;
+ menu();
+ set_cursor();
+ move_cursor();
+ SHOW_SPRITES;
+ }
+ if((key & (J_A|J_B)) == J_A) {
+ if(!drawn) {
+ drawn++;
+ plot(cursor_x, cursor_y, colors[current_color], modes[current_mode]);
+ }
+ } else
+ drawn = 0;
+ if((key & (J_A|J_B)) == J_B) {
+ if(!erased) {
+ erased++;
+ plot(cursor_x, cursor_y, WHITE, SOLID);
+ }
+ } else
+ erased = 0;
+ }
+}
+
+void main()
+{
+ /* Initialize sprite palette */
+ OBP1_REG = 0xE0U;
+
+ splash();
+
+ current_tool = 0;
+ current_color = BLACK;
+ current_mode = SOLID;
+ current_cursor = PEN;
+ menu_cursor_pos = 0;
+ cursor_x = 160/2;
+ cursor_y = 144/2;
+
+ run();
+}
diff --git a/gbdk/gbdk-lib/examples/ap/ram_function/Makefile b/gbdk/gbdk-lib/examples/ap/ram_function/Makefile
new file mode 100644
index 00000000..ed70eb76
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/ram_function/Makefile
@@ -0,0 +1,32 @@
+CC = ../../../bin/lcc -msm83:ap -Wl-j -Wm-yS
+
+BINS = ram_fn.pocket
+
+all: $(BINS)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+%.o: %.c
+ $(CC) -c -o $@ $<
+
+%.s: %.c
+ $(CC) -S -o $@ $<
+
+%.o: %.s
+ $(CC) -c -o $@ $<
+
+%.pocket: %.o
+ $(CC) -o $@ $<
+
+clean:
+ rm -f *.o *.lst *.map *.pocket *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi
+
+
+ram_fn.o: ram_fn.c
+ $(CC) -D_inc_ram=0xD000 -D_inc_hiram=0xFFA0 -c -o $@ $<
+
+ram_fn.pocket: ram_fn.o
+ $(CC) -Wl-g_inc_ram=0xD000 -Wl-g_inc_hiram=0xFFA0 -o $@ $<
+
diff --git a/gbdk/gbdk-lib/examples/ap/ram_function/ram_fn.c b/gbdk/gbdk-lib/examples/ap/ram_function/ram_fn.c
new file mode 100644
index 00000000..b6527714
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/ram_function/ram_fn.c
@@ -0,0 +1,71 @@
+#include <gb/gb.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+
+uint16_t counter = 0;
+
+// inc() must be a relocatable function, be careful!
+void inc() {
+ counter++;
+}
+// dummy function, needed to calculate inc() size, must be after it
+void inc_end() {}
+
+// calculate the distance between objects
+#define object_distance(a, b) ((void *)&(b) - (void *)&(a))
+
+// variables at an absolute addresses which are defined by passing parameters to compiler
+unsigned char __at _inc_ram ram_buffer[];
+unsigned char __at _inc_hiram hiram_buffer[];
+
+// those are function pointer variables, we can initialize them right here
+typedef void (*inc_t)(void);
+inc_t inc_ram_var = (inc_t)ram_buffer;
+inc_t inc_hiram_var = (inc_t)hiram_buffer;
+
+// those are defined by passing parameters to the linker, they must be located at the same
+// addresses where ram_buffer and hiram_buffer are located
+extern void inc_ram();
+extern void inc_hiram();
+
+void print_counter() {
+ printf(" Counter is %u\n", counter);
+}
+
+void main() {
+ // copy inc() function to it's new destinations: hiram_buffer and ram_buffer
+ hiramcpy((uint8_t)&hiram_buffer, (void *)&inc, (uint8_t)object_distance(inc, inc_end));
+ memcpy(&ram_buffer, (void *)&inc, (uint16_t)object_distance(inc, inc_end));
+
+ // print initial counter state
+ puts("Program Start...");
+ print_counter();
+
+ // Call function in ROM
+ puts("Call ROM");
+ inc();
+ print_counter();
+
+ // Call function in RAM using link-time address
+ puts("Call RAM direct");
+ inc_ram();
+ print_counter();
+
+ // Call function in RAM using pointer-to-function variable
+ puts("Call RAM indirect");
+ inc_ram_var();
+ print_counter();
+
+ // Call function in HIRAM using link-time address
+ puts("Call HIRAM direct");
+ inc_hiram();
+ print_counter();
+
+ // Call function in HIRAM using pointer-to-function variable
+ puts("Call HIRAM indirect");
+ inc_hiram_var();
+ print_counter();
+
+ puts("The End...");
+}
diff --git a/gbdk/gbdk-lib/examples/ap/rand/Makefile b/gbdk/gbdk-lib/examples/ap/rand/Makefile
new file mode 100644
index 00000000..97fde46a
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/rand/Makefile
@@ -0,0 +1,17 @@
+CC = ../../../bin/lcc -msm83:ap -Wl-j -Wm-yS
+
+BINS = rand.pocket
+
+all: $(BINS)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+# Compile and link single file in one pass
+%.pocket: %.c
+ $(CC) -o $@ $<
+
+clean:
+ rm -f *.o *.lst *.map *.pocket *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi
+
diff --git a/gbdk/gbdk-lib/examples/ap/rand/rand.c b/gbdk/gbdk-lib/examples/ap/rand/rand.c
new file mode 100644
index 00000000..c16a1d36
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/rand/rand.c
@@ -0,0 +1,59 @@
+/***************************************************************************
+ * *
+ * Module : rand.c *
+ * *
+ * Purpose : A test for the rand() function, for the GBDK *
+ * *
+ * Version : 1, Januari 6 1998 *
+ * *
+ * Author : Luc Van den Borre ( Homepage : NOC.BASE.ORG ) *
+ * *
+ **************************************************************************/
+
+#include <gb/gb.h>
+#include <stdint.h>
+#include <rand.h>
+#include <gb/drawing.h>
+#include <stdio.h>
+#include <string.h>
+
+uint8_t accu[80];
+uint8_t accua[80];
+
+void main(void)
+{
+ uint8_t r, s, t = 0, u = 0;
+ uint16_t seed;
+
+ memset(accu, 0, sizeof(accu));
+ memset(accua, 0, sizeof(accua));
+
+ /* We use the DIV register to get a random initial seed */
+ puts("Getting seed");
+ puts("Push any key (1)");
+ waitpad(0xFF);
+ waitpadup();
+ seed = DIV_REG;
+ puts("Push any key (2)");
+ waitpad(0xFF);
+ waitpadup();
+ seed |= (uint16_t)DIV_REG << 8;
+
+ /* initarand() calls initrand() */
+ initarand(seed);
+
+ do {
+ r = rand();
+ s = arand();
+
+ if(r < 80) {
+ t = ++accu[r];
+ plot(r, 144-t, LTGREY, SOLID);
+ }
+ if(s < 80) {
+ u = ++accua[s];
+ plot(s+80, 144-u, DKGREY, SOLID);
+ }
+ }
+ while(t != 144 && u != 144);
+}
diff --git a/gbdk/gbdk-lib/examples/ap/rpn/Makefile b/gbdk/gbdk-lib/examples/ap/rpn/Makefile
new file mode 100644
index 00000000..527625c2
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/rpn/Makefile
@@ -0,0 +1,17 @@
+CC = ../../../bin/lcc -msm83:ap -Wl-j -Wm-yS
+
+BINS = rpn.pocket
+
+all: $(BINS)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+# Compile and link single file in one pass
+%.pocket: %.c
+ $(CC) -o $@ $<
+
+clean:
+ rm -f *.o *.lst *.map *.pocket *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi
+
diff --git a/gbdk/gbdk-lib/examples/ap/rpn/rpn.c b/gbdk/gbdk-lib/examples/ap/rpn/rpn.c
new file mode 100644
index 00000000..7f322db2
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/rpn/rpn.c
@@ -0,0 +1,102 @@
+#include <stdint.h>
+#include <stdio.h>
+#include <ctype.h>
+
+#define MAXOP 40
+#define NUMBER '0'
+#define STACKSIZE 40
+
+uint8_t sp;
+int16_t stack[STACKSIZE];
+
+char s[MAXOP];
+uint8_t pos;
+int16_t n;
+
+void push(int16_t l)
+{
+ if(sp < STACKSIZE)
+ stack[sp++] = l;
+ else
+ puts("Stack full");
+}
+
+int16_t pop(void)
+{
+ if(sp > 0)
+ return stack[--sp];
+ else
+ puts("Stack empty");
+ return 0;
+}
+
+int16_t top(void)
+{
+ if(sp > 0)
+ return stack[sp-1];
+ else
+ puts("Stack empty");
+ return 0;
+}
+
+int8_t read_op(void)
+{
+ if(pos == 0) {
+ gets(s);
+ }
+
+ while(s[pos] == ' ' || s[pos] == '\t')
+ pos++;
+
+ if(s[pos] == '\0') {
+ pos = 0;
+ return('\n');
+ }
+
+ if(!isdigit(s[pos]))
+ return(s[pos++]);
+
+ n = s[pos] - '0';
+ while(isdigit(s[++pos]))
+ n = 10 * n + s[pos] - '0';
+
+ return NUMBER;
+}
+
+void main(void)
+{
+ int8_t type;
+ int16_t op2;
+
+ puts("RPN Calculator");
+ sp = 0;
+ pos = 0;
+
+ while((type = read_op()) != 0) {
+ switch(type) {
+ case NUMBER:
+ push(n);
+ break;
+ case '+':
+ push(pop() + pop());
+ break;
+ case '*':
+ push(pop() * pop());
+ break;
+ case '-':
+ op2 = pop();
+ push(pop() - op2);
+ break;
+ case '/':
+ op2 = pop();
+ if(op2 != 0)
+ push(pop() / op2);
+ else
+ puts("Divide by 0");
+ break;
+ case '\n':
+ printf("==> %d\n", top());
+ break;
+ }
+ }
+}
diff --git a/gbdk/gbdk-lib/examples/ap/scroller/Makefile b/gbdk/gbdk-lib/examples/ap/scroller/Makefile
new file mode 100644
index 00000000..c9232858
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/scroller/Makefile
@@ -0,0 +1,17 @@
+CC = ../../../bin/lcc -msm83:ap -Wl-j -Wm-yS
+
+BINS = text_scroller.pocket
+
+all: $(BINS)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+# Compile and link single file in one pass
+%.pocket: %.c
+ $(CC) -o $@ $<
+
+clean:
+ rm -f *.o *.lst *.map *.pocket *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi
+
diff --git a/gbdk/gbdk-lib/examples/ap/scroller/text_scroller.c b/gbdk/gbdk-lib/examples/ap/scroller/text_scroller.c
new file mode 100644
index 00000000..0c136200
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/scroller/text_scroller.c
@@ -0,0 +1,72 @@
+#include <gb/gb.h>
+#include <stdint.h>
+#include <stdio.h>
+
+#include <gb/emu_debug.h>
+
+const uint8_t scanline_offsets_tbl[] = {0, 1, 2, 3, 3, 2, 1, 0, 0, 1, 2, 3, 3, 2, 1, 0};
+const uint8_t * scanline_offsets = scanline_offsets_tbl;
+
+#define SCROLL_POS 15
+#define SCROLL_POS_PIX_START (SCROLL_POS * 8) - 1
+#define SCROLL_POS_PIX_END ((SCROLL_POS + 1) * 8) - 1
+
+uint8_t scroller_x = 0;
+
+void scanline_isr() {
+ switch (LYC_REG) {
+ case 0:
+ SCX_REG = 0;
+ LYC_REG = SCROLL_POS_PIX_START;
+ break;
+ case SCROLL_POS_PIX_START:
+ SCX_REG = scroller_x;
+ LYC_REG = SCROLL_POS_PIX_END;
+ break;
+ case SCROLL_POS_PIX_END:
+ SCX_REG = LYC_REG = 0;
+ break;
+ }
+}
+
+const uint8_t scroller_text[] = "This is a text scroller demo for GBDK-2020. You can use ideas, that are "\
+"shown in this demo, to make different parallax effects, scrolling of tilemaps which are larger than 32x32 "\
+"tiles and TEXT SCROLLERS, of course! Need to write something else to make this text longer than 256 characters. "\
+"The quick red fox jumps over the lazy brown dog. 0123456789. ";
+
+const uint8_t * scroller_next_char = scroller_text;
+uint8_t * scroller_vram_addr;
+uint16_t base, limit;
+
+void main() {
+ printf("Scrolling %d chars", sizeof(scroller_text) - 1);
+
+ CRITICAL {
+ STAT_REG |= STATF_LYC; LYC_REG = 0;
+ add_LCD(scanline_isr);
+ }
+ set_interrupts(VBL_IFLAG | LCD_IFLAG);
+
+ scroller_vram_addr = get_bkg_xy_addr(20, SCROLL_POS);
+ set_vram_byte(scroller_vram_addr, *scroller_next_char - 0x20);
+
+ base = (uint16_t) scroller_vram_addr & 0xffe0;
+ limit = base + 0x20;
+
+ while (1) {
+ scroller_x++;
+ if ((scroller_x & 0x07) == 0) {
+ // next letter
+ scroller_next_char++;
+ if (*scroller_next_char == 0) scroller_next_char = scroller_text;
+
+ // next vram position
+ scroller_vram_addr++;
+ if (scroller_vram_addr == (uint8_t *)limit) scroller_vram_addr = (uint8_t *)base;
+
+ // put next char
+ set_vram_byte(scroller_vram_addr, *scroller_next_char - 0x20);
+ }
+ wait_vbl_done();
+ }
+} \ No newline at end of file
diff --git a/gbdk/gbdk-lib/examples/ap/sgb_border/Makefile b/gbdk/gbdk-lib/examples/ap/sgb_border/Makefile
new file mode 100644
index 00000000..e013dec8
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/sgb_border/Makefile
@@ -0,0 +1,11 @@
+CC = ../../../bin/lcc
+
+all:
+ $(CC) -msm83:ap -Wl-j -Wm-yS -Wm-ys -o border.pocket border.c sgb_border.c border_data.c
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+clean:
+ rm -f *.o *.lst *.map *.pocket *.ihx *.sym *.cdb *.adb *.asm
diff --git a/gbdk/gbdk-lib/examples/ap/sgb_border/border.c b/gbdk/gbdk-lib/examples/ap/sgb_border/border.c
new file mode 100644
index 00000000..143412ac
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/sgb_border/border.c
@@ -0,0 +1,18 @@
+#include <gb/gb.h>
+#include <stdint.h>
+#include "sgb_border.h"
+
+#include "border_data.h"
+
+void main(void) {
+
+ // Wait 4 frames
+ // For SGB on PAL SNES this delay is required on startup, otherwise borders don't show up
+ for (uint8_t i = 4; i != 0; i--) wait_vbl_done();
+
+ DISPLAY_ON;
+ set_sgb_border(border_chr, border_chr_size, border_map, border_map_size, border_pal, border_pal_size);
+ while(1) {
+ wait_vbl_done();
+ }
+} \ No newline at end of file
diff --git a/gbdk/gbdk-lib/examples/ap/sgb_border/border_data.c b/gbdk/gbdk-lib/examples/ap/sgb_border/border_data.c
new file mode 100644
index 00000000..9db223f2
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/sgb_border/border_data.c
@@ -0,0 +1,192 @@
+const unsigned char border_chr[]={
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfc,0x00,
+0x02,0x02,0x0b,0x08,0x1c,0x13,0x30,0x2f,0x61,0x5f,0x22,0x1e,0xc4,0xbc,0x49,0x39,0xfe,0xfd,0xfb,0xf4,0xfc,0xe0,0xf0,0xc0,0xe0,0x81,0xa0,0xc3,0xc0,0x07,0x40,0x8f,
+0x7f,0x80,0x80,0x7f,0x00,0xff,0x38,0xf8,0x80,0x80,0x1c,0x1f,0xc0,0xff,0x00,0xff,0x7f,0x00,0x80,0x00,0x00,0x00,0x00,0x3f,0x00,0xff,0x00,0xfc,0x00,0xc0,0x00,0x00,
+0xff,0x00,0x00,0xff,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0xff,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,
+0xfe,0x01,0x01,0xfe,0x00,0xff,0x1c,0x1f,0x01,0x01,0x38,0xf8,0x03,0xff,0x00,0xff,0xfe,0x00,0x01,0x00,0x00,0x00,0x00,0xfc,0x00,0xff,0x00,0x3f,0x00,0x03,0x00,0x00,
+0x40,0x40,0xd0,0x10,0x38,0xc8,0x0c,0xf4,0x86,0xfa,0x44,0x78,0x23,0x3d,0x92,0x9c,0x7f,0xbf,0xdf,0x2f,0x3f,0x07,0x0f,0x03,0x07,0x81,0x05,0xc3,0x03,0xe0,0x02,0xf1,
+0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0xfe,0xfe,0xfe,0xfe,0xff,0xfe,0xff,0xfe,0xff,0xfe,0xff,0xfe,0xff,0xfe,0xff,0xfe,
+0x4a,0xbb,0x82,0x73,0x90,0x73,0x94,0x77,0x94,0x77,0x84,0x67,0x80,0x67,0x80,0x67,0x40,0x0e,0x80,0x0e,0x80,0x1c,0x80,0x1c,0x80,0x1c,0x80,0x1c,0x80,0x18,0x80,0x18,
+0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0xff,0x00,0x00,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0xff,0x00,0x00,0xff,0x00,0x00,0xff,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x00,0x00,
+0x00,0xff,0x00,0xff,0x0e,0xfe,0x09,0xfd,0x09,0xff,0x09,0xfd,0x0e,0xfe,0x00,0xff,0x00,0x00,0x00,0x00,0x06,0x01,0x00,0x02,0x00,0x00,0x00,0x02,0x06,0x01,0x00,0x00,
+0x00,0xff,0x00,0xff,0x33,0xb7,0x49,0xcf,0x49,0xff,0x49,0xcf,0x31,0xb7,0x00,0xff,0x00,0x00,0x00,0x00,0x31,0x48,0x00,0x30,0x00,0x00,0x00,0x30,0x30,0x48,0x00,0x00,
+0x00,0xff,0x00,0xff,0x81,0xff,0x01,0xfd,0x03,0xff,0x02,0xfe,0x02,0xff,0x00,0xff,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x02,0x03,0x00,0x00,0x01,0x00,0x00,0x00,0x00,
+0x00,0xff,0x00,0xff,0x42,0xfa,0x45,0x5d,0xe5,0xf7,0xaf,0xbf,0x28,0xff,0x00,0xff,0x00,0x00,0x00,0x00,0x40,0x05,0x05,0xa2,0xe0,0x08,0x0a,0x40,0x00,0x00,0x00,0x00,
+0x00,0xff,0x00,0xff,0x3b,0xff,0x12,0xff,0x13,0x7f,0x92,0xff,0x92,0xff,0x00,0xff,0x00,0x00,0x00,0x00,0x11,0x00,0x00,0x00,0x01,0x80,0x80,0x00,0x00,0x00,0x00,0x00,
+0x00,0xff,0x00,0xff,0x94,0xbd,0x52,0x7a,0x91,0xbd,0x92,0xba,0x54,0x7d,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x42,0x02,0x85,0x80,0x42,0x02,0x45,0x00,0x82,0x00,0x00,
+0x00,0xff,0x00,0xff,0x41,0x7f,0x81,0xbf,0x01,0x7f,0x80,0xbe,0x40,0x7f,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x40,0x01,0x80,0x80,0x41,0x00,0x80,0x00,0x00,
+0x00,0xff,0x00,0xff,0x15,0xff,0x14,0xff,0x54,0x5f,0xa4,0xaf,0xa4,0xff,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0xa0,0xa0,0x50,0x00,0x00,0x00,0x00,
+0x00,0xff,0x00,0xff,0xd2,0xff,0x92,0xff,0x9e,0xff,0x92,0xff,0x92,0xff,0x00,0xff,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0xff,0x00,0xff,0x07,0xf7,0x08,0xfb,0x06,0xf6,0x01,0xfd,0x0e,0xfe,0x00,0xff,0x00,0x00,0x00,0x00,0x05,0x08,0x00,0x04,0x00,0x09,0x00,0x02,0x0a,0x01,0x00,0x00,
+0x00,0xff,0x00,0xff,0x77,0xff,0x24,0xff,0x27,0xff,0x24,0xff,0x27,0xff,0x00,0xff,0x00,0x00,0x00,0x00,0x22,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00,
+0x00,0xff,0x00,0xff,0x73,0xf7,0x4a,0xef,0x73,0xf7,0x52,0xf7,0x4b,0xef,0x00,0xff,0x00,0x00,0x00,0x00,0x21,0x08,0x00,0x10,0x30,0x08,0x00,0x08,0x01,0x10,0x00,0x00,
+0x00,0xff,0x00,0xff,0x98,0xdb,0x24,0xe7,0xa4,0xff,0x24,0xe7,0x98,0xdb,0x00,0xff,0x00,0x00,0x00,0x00,0x18,0x24,0x00,0x18,0x80,0x00,0x00,0x18,0x18,0x24,0x00,0x00,
+0x00,0xff,0x00,0xff,0x0e,0xef,0x10,0xf7,0x0c,0xed,0x02,0xfb,0x1c,0xfd,0x00,0xff,0x00,0x00,0x00,0x00,0x0a,0x10,0x00,0x08,0x00,0x12,0x00,0x04,0x14,0x02,0x00,0x00,
+0x00,0xff,0x00,0xff,0x64,0x6f,0x94,0x9f,0x94,0xff,0x94,0x9c,0x63,0x6b,0x00,0xff,0x00,0x00,0x00,0x00,0x64,0x90,0x00,0x60,0x00,0x00,0x00,0x63,0x63,0x94,0x00,0x00,
+0x00,0xff,0x00,0xff,0xa5,0xff,0xb5,0xff,0xbd,0xff,0xad,0xff,0x25,0x7f,0x00,0xff,0x00,0x00,0x00,0x00,0x84,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x20,0x80,0x00,0x00,
+0x00,0xff,0x00,0xff,0xc0,0xdf,0x20,0xbf,0x20,0xff,0x20,0xbf,0xc0,0xdf,0x00,0xff,0x00,0x00,0x00,0x00,0xc0,0x20,0x00,0x40,0x00,0x00,0x00,0x40,0xc0,0x20,0x00,0x00,
+0x52,0xdd,0x41,0xce,0x09,0xce,0x29,0xee,0x29,0xee,0x21,0xe6,0x01,0xe6,0x01,0xe6,0x02,0x70,0x01,0x70,0x01,0x38,0x01,0x38,0x01,0x38,0x01,0x38,0x01,0x18,0x01,0x18,
+0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x7f,0x7f,0x7f,0x7f,0xff,0x7f,0xff,0x7f,0xff,0x7f,0xff,0x7f,0xff,0x7f,0xff,0x7f,
+0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0xff,0xfe,0xff,0xfe,0xff,0xfe,0xff,0xfe,0xff,0xfe,0xff,0xfe,0xff,0xfe,0xff,0xfe,
+0x80,0x67,0x80,0x67,0x80,0x67,0x80,0x67,0x80,0x67,0x80,0x67,0x80,0x67,0x80,0x67,0x80,0x18,0x80,0x18,0x80,0x18,0x80,0x18,0x80,0x18,0x80,0x18,0x80,0x18,0x80,0x18,
+0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x01,0xfe,0x03,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x03,0x00,
+0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0xff,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0xff,0x00,
+0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x80,0x7f,0xc0,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0xc0,0x00,
+0x01,0xe6,0x01,0xe6,0x01,0xe6,0x01,0xe6,0x01,0xe6,0x01,0xe6,0x01,0xe6,0x01,0xe6,0x01,0x18,0x01,0x18,0x01,0x18,0x01,0x18,0x01,0x18,0x01,0x18,0x01,0x18,0x01,0x18,
+0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0xff,0x7f,0xff,0x7f,0xff,0x7f,0xff,0x7f,0xff,0x7f,0xff,0x7f,0xff,0x7f,0xff,0x7f,
+0x03,0xfc,0x03,0xfc,0x03,0xfc,0x03,0xfc,0x03,0xfc,0x03,0xfc,0x03,0xfc,0x03,0xfc,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0xc0,0x3f,0xc0,0x3f,0xc0,0x3f,0xc0,0x3f,0xc0,0x3f,0xc0,0x3f,0xc0,0x3f,0xc0,0x3f,0xc0,0x00,0xc0,0x00,0xc0,0x00,0xc0,0x00,0xc0,0x00,0xc0,0x00,0xc0,0x00,0xc0,0x00,
+0x3c,0xc3,0x78,0x83,0xec,0x00,0xfc,0x00,0xfd,0x01,0x39,0x83,0x02,0x87,0x18,0xdb,0x3c,0x00,0x44,0x10,0x92,0x39,0x82,0x39,0x83,0x10,0x45,0x00,0x3a,0x40,0x18,0x24,
+0x00,0xff,0x00,0xff,0xc4,0xd5,0xae,0xff,0xca,0xdf,0xae,0xff,0xca,0xdf,0x00,0xff,0x00,0x00,0x00,0x00,0x40,0x2a,0x2e,0x00,0xc0,0x20,0x2e,0x00,0x40,0x20,0x00,0x00,
+0x00,0xff,0x00,0xff,0xee,0xff,0x44,0xff,0x44,0xff,0x44,0xff,0x44,0xff,0x00,0xff,0x00,0x00,0x00,0x00,0xee,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x44,0x00,0x00,0x00,
+0x00,0xff,0x00,0xff,0xee,0xff,0x8a,0xff,0xec,0xfd,0x8a,0xfb,0xea,0xff,0x00,0xff,0x00,0x00,0x00,0x00,0x66,0x00,0x00,0x00,0xec,0x02,0x02,0x04,0x60,0x00,0x00,0x00,
+0x03,0xfc,0x03,0xfc,0xa3,0xfc,0xa3,0xbc,0xe3,0xfc,0x43,0xfc,0x43,0xfc,0x03,0xfc,0x03,0x00,0x03,0x00,0xa3,0x00,0x03,0x40,0xe3,0x00,0x03,0x00,0x03,0x00,0x03,0x00,
+0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0xff,0x7f,0xff,0x7f,0xff,0x7f,0xff,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,
+0x29,0xee,0x2a,0xec,0x2a,0xec,0x0a,0xcc,0x03,0xcd,0x43,0xcd,0x53,0xdd,0x55,0xd9,0x01,0x38,0x02,0x39,0x02,0x39,0x02,0x39,0x03,0x30,0x03,0x70,0x02,0x70,0x04,0x72,
+0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0x7f,0x7f,0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x01,0xff,0x01,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x01,
+0x15,0x99,0x06,0x9a,0xa6,0xba,0xaa,0xb2,0x28,0x30,0x0c,0x34,0x4c,0x74,0x54,0x64,0x04,0x72,0x07,0x61,0x07,0xe1,0x09,0xe5,0x0b,0xe7,0x0f,0xc3,0x0f,0xc3,0x13,0xcb,
+0x00,0xfe,0x02,0xfe,0x00,0xfc,0x01,0xf9,0x08,0xf9,0x00,0xf3,0x04,0xe7,0x21,0xe6,0x00,0x01,0x00,0x03,0x00,0x03,0x00,0x07,0x00,0x0e,0x00,0x0c,0x00,0x1c,0x01,0x38,
+0x10,0x60,0x98,0xe8,0x20,0xc0,0x30,0xd0,0x40,0x80,0x60,0xa0,0xc0,0x40,0x40,0x40,0x17,0x8f,0x1f,0x87,0x2f,0x1f,0x3f,0x0f,0x5f,0x3f,0x5f,0x1f,0xff,0x3f,0x3f,0xbf,
+0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0xff,0xfe,0xff,0xfe,0xff,0xfe,0xff,0xfe,0xff,0xfe,0xff,0xfe,0xfe,0xfe,0xfe,0xfe,
+0x80,0x67,0x80,0x67,0x84,0x67,0x94,0x77,0x94,0x77,0x90,0x73,0x82,0x73,0x4a,0xbb,0x80,0x18,0x80,0x18,0x80,0x1c,0x80,0x1c,0x80,0x1c,0x80,0x1c,0x80,0x0e,0x40,0x0e,
+0x03,0xfc,0x01,0xfe,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x03,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0xff,0x00,0xff,0x00,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0xff,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0xc0,0x3f,0x80,0x7f,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0xc0,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x03,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,
+0x00,0xff,0x00,0xff,0x00,0xfe,0x00,0xfc,0x08,0xf8,0x02,0xe3,0x40,0xc7,0x11,0x1e,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x03,0x00,0x0f,0x00,0x1e,0x00,0x78,0x01,0xf0,
+0x41,0xce,0x93,0x9d,0x27,0x3b,0x4a,0x72,0x14,0xe4,0x28,0xc8,0x70,0xb0,0xc0,0x40,0x01,0x70,0x03,0xf0,0x06,0xe0,0x09,0xc5,0x13,0x0b,0x27,0x17,0x6f,0x0f,0xff,0x3f,
+0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+0x49,0x39,0xc4,0xbc,0x22,0x1e,0x61,0x5f,0x30,0x2f,0x1c,0x13,0x0b,0x08,0x02,0x02,0x40,0x8f,0xc0,0x07,0xa0,0xc3,0xe0,0x81,0xf0,0xc0,0xfc,0xe0,0xfb,0xf4,0xfe,0xfd,
+0x00,0xff,0xc0,0xff,0x1c,0x1f,0x80,0x80,0x38,0xf8,0x00,0xff,0x80,0x7f,0x7f,0x80,0x00,0x00,0x00,0xc0,0x00,0xfc,0x00,0xff,0x00,0x3f,0x00,0x00,0x80,0x00,0x7f,0x00,
+0x00,0xff,0x00,0xff,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0xff,0x00,0x00,0x00,0x00,0xff,0x00,
+0x00,0xff,0x07,0xff,0xe0,0xe0,0x03,0x03,0xf0,0xff,0x01,0xfe,0x7e,0x80,0x8f,0x0f,0x00,0x00,0x00,0x07,0x00,0xff,0x00,0xff,0x00,0xf0,0x01,0x00,0x7e,0x01,0x8c,0x70,
+0x30,0xf0,0x03,0x03,0x38,0x3f,0x81,0xfe,0x1e,0xe0,0xe7,0x07,0x70,0x70,0x80,0x80,0x00,0x3f,0x00,0xff,0x00,0xf8,0x01,0x80,0x1e,0x01,0xe6,0x18,0x6f,0x8f,0x7f,0x7f,
+0x42,0x7c,0x0f,0xf3,0x34,0xc4,0xd0,0x10,0x40,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0xc1,0x0e,0x00,0x33,0x0b,0xdf,0x2f,0x7f,0xbf,0xff,0xff,0xff,0xff,0xff,0xff,
+0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x07,0x04,0xff,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfe,0xff,0xff,0xfb,
+0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x9c,0xe3,0xff,0x00,0xf3,0x0c,0xff,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x9c,0x7f,0xff,0xff,0xf3,0xff,
+0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x87,0xcf,0x08,0x87,0x48,0xff,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf8,0x7f,0xff,0xf7,0xb7,0xff,
+0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x00,0x80,0x80,0x00,0xff,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x7f,0xff,0xff,0xff,
+0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x28,0x70,0x48,0x38,0x40,0xff,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xd7,0xff,0xf7,0xbf,0xbf,0xff,
+0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x1c,0x08,0x14,0x3c,0x20,0xff,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf3,0xef,0xeb,0xff,0xff,0xdf,
+0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x20,0x3f,0x20,0x1f,0x20,0xff,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xdf,0xff,0xdf,0xdf,0xff,
+0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x10,0xf0,0x10,0xd0,0x30,0xff,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0xff,0xff,0xef,0xdf,0xef,
+0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1e,0x01,0x3f,0x20,0x3b,0x24,0xff,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfe,0xff,0xff,0xdf,0xfb,0xdf,
+0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0xc0,0xc0,0x20,0xe0,0x11,0xff,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0xbf,0xdf,0xff,0xee,0xff,
+0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x4a,0x76,0x7f,0x81,0xff,0x00,0xff,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xcb,0xbd,0x7f,0xfe,0xff,0xff,
+0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x10,0x38,0x48,0x70,0x48,0xff,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0xff,0xbf,0xf7,0xf7,0xbf,
+0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1c,0x24,0x70,0x48,0x38,0x48,0xff,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xdf,0xfb,0xf7,0xbf,0xbf,0xf7,
+0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+0xc0,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x3f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x08,0x7c,0x04,0x78,0x04,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf7,0xff,0xff,0xfb,0xfb,0xff,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xec,0x02,0xec,0x02,0xe0,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfd,0xff,0xfd,0xff,0xff,0xff,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x10,0xf8,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0xff,0xff,0xff,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0e,0x00,0x0e,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+0x0f,0x08,0x0e,0x01,0x0c,0x12,0x1e,0x02,0x38,0x24,0x1c,0x24,0x3c,0x04,0x38,0x00,0xff,0xf7,0xfe,0xff,0xed,0xff,0xff,0xfd,0xfb,0xdf,0xdf,0xfb,0xff,0xfb,0xff,0xff,
+0x63,0xe3,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0x41,0xfe,0x80,0x7f,0x9c,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xbf,0xfe,0xff,0x7f,
+0x4f,0xc0,0x1f,0x10,0x0f,0x10,0x1d,0x02,0x3f,0x22,0x18,0x25,0x3c,0x05,0x77,0x4f,0x7f,0xbf,0xff,0xef,0xef,0xff,0xfd,0xff,0xff,0xdd,0xda,0xff,0xfe,0xfb,0xf7,0xb8,
+0xc0,0x40,0xc0,0x40,0x80,0x40,0x80,0x40,0xc0,0x00,0xe0,0x20,0xe1,0x21,0xc0,0x21,0xff,0xbf,0xff,0xbf,0xbf,0xff,0xbf,0xff,0xff,0xff,0xff,0xdf,0xff,0xde,0xde,0xff,
+0x3c,0x44,0x7c,0x04,0xf8,0x84,0x78,0x84,0x7c,0x80,0xdf,0x23,0xde,0x23,0xed,0x32,0xbf,0xfb,0xff,0xfb,0xfb,0x7f,0x7b,0xff,0x7f,0xff,0xdf,0xfc,0xde,0xfd,0xed,0xdf,
+0x1c,0x20,0x7e,0x42,0x3e,0x42,0xfe,0x82,0x6c,0x92,0xcc,0x32,0xec,0x32,0x9e,0x50,0xdf,0xff,0xff,0xbd,0xbf,0xfd,0xff,0x7d,0x6d,0xff,0xcd,0xff,0xed,0xdf,0xbf,0xef,
+0x1c,0x24,0x1c,0x24,0x38,0x00,0x30,0x08,0x30,0x08,0x7f,0x40,0x7f,0x40,0x7f,0x40,0xdf,0xfb,0xdf,0xfb,0xff,0xff,0xf7,0xff,0xf7,0xff,0xff,0xbf,0xff,0xbf,0xff,0xbf,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x20,0xe0,0x20,0xa0,0x60,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xdf,0xff,0xff,0xdf,0xbf,0xdf,
+0x1c,0x24,0x18,0x20,0x38,0x00,0x30,0x08,0x76,0x4f,0x7f,0x40,0x3f,0x40,0x3f,0x40,0xdf,0xfb,0xdf,0xff,0xff,0xff,0xf7,0xff,0xf6,0xb9,0xff,0xbf,0xbf,0xff,0xbf,0xff,
+0x73,0x82,0xf1,0x82,0xf1,0x82,0x67,0x94,0xf3,0x14,0xc3,0x24,0xf3,0x14,0xe7,0x10,0x7f,0xfd,0xfd,0x7f,0xfd,0x7f,0x6f,0xfb,0xfb,0xef,0xdb,0xff,0xfb,0xef,0xef,0xff,
+0xe7,0x18,0xe3,0x24,0x87,0x44,0xc3,0x40,0x03,0x80,0x83,0x80,0x83,0x80,0x07,0x04,0xe7,0xff,0xfb,0xdf,0xbf,0xfb,0xff,0xbf,0x7f,0xff,0xff,0x7f,0xff,0x7f,0xff,0xfb,
+0xb0,0x88,0x98,0xa0,0x3d,0xa5,0x18,0x85,0x8f,0x12,0x9f,0x10,0x8f,0x00,0x06,0x89,0xf7,0x7f,0xdf,0x7f,0x7f,0xda,0x7a,0xff,0xef,0xfd,0xff,0xef,0xff,0xff,0x76,0xff,
+0xe0,0x90,0x70,0x90,0xc0,0x20,0xe0,0x20,0x80,0x40,0xc0,0x40,0x00,0x80,0x80,0x80,0xef,0x7f,0x7f,0xef,0xdf,0xff,0xff,0xdf,0xbf,0xff,0xff,0xbf,0x7f,0xff,0xff,0x7f,
+0x76,0x0a,0x7c,0x0a,0x73,0x05,0x76,0x05,0x71,0x02,0x73,0x02,0x70,0x01,0x00,0x00,0xf7,0xfd,0xfd,0xf7,0xfb,0xfe,0xfe,0xfb,0xfd,0xff,0xff,0xfd,0xfe,0xff,0xff,0xff,
+0xe0,0x0e,0xee,0x00,0xee,0x00,0xee,0x00,0xee,0x00,0xee,0x00,0xee,0x00,0x00,0x00,0xf1,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+0xe8,0x0e,0xfe,0x01,0xee,0x19,0xf7,0x10,0xe7,0x00,0xe7,0x00,0xe7,0x00,0x00,0x00,0xf9,0xf7,0xfe,0xff,0xee,0xf7,0xff,0xef,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+0x61,0x12,0x63,0x14,0x63,0x14,0x67,0x10,0x63,0x14,0x63,0x14,0x61,0x12,0x00,0x00,0xed,0xff,0xeb,0xff,0xeb,0xff,0xef,0xff,0xeb,0xff,0xeb,0xff,0xed,0xff,0xff,0xff,
+0xe3,0x10,0xf3,0xc8,0x33,0x08,0xfb,0x00,0x03,0x00,0x53,0x68,0xe3,0x10,0x00,0x00,0xef,0xff,0xf7,0x3f,0xf7,0xff,0xff,0xff,0xff,0xff,0xd7,0xbf,0xef,0xff,0xff,0xff,
+0xa0,0x38,0xf8,0x05,0xb8,0x65,0xdd,0x40,0x9c,0x01,0x9c,0x01,0x9c,0x00,0x00,0x00,0xe7,0xdf,0xfa,0xff,0xba,0xdf,0xff,0xbf,0xfe,0xff,0xfe,0xff,0xff,0xff,0xff,0xff,
+0x7e,0x80,0xfe,0x30,0xce,0x00,0xce,0x00,0xce,0x00,0xfe,0x30,0x7e,0x80,0x00,0x00,0x7f,0xff,0xff,0xcf,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xcf,0x7f,0xff,0xff,0xff,
+0x3c,0x42,0x7e,0x99,0x66,0x81,0xe7,0x00,0x66,0x81,0x7e,0x99,0x3c,0x42,0x00,0x00,0xbd,0xff,0x7e,0xe7,0x7e,0xff,0xff,0xff,0x7e,0xff,0x7e,0xe7,0xbd,0xff,0xff,0xff,
+0x38,0x00,0x3c,0x04,0x3c,0x04,0x18,0x24,0x3d,0x23,0x0f,0x10,0x07,0x08,0x05,0x06,0xff,0xff,0xff,0xfb,0xff,0xfb,0xdb,0xff,0xfd,0xde,0xef,0xff,0xf7,0xff,0xfd,0xfb,
+0x7c,0x82,0x0e,0x12,0x1c,0x00,0x38,0x24,0x7c,0x44,0x79,0x81,0xf0,0x09,0xd1,0x30,0x7d,0xff,0xef,0xfd,0xff,0xff,0xfb,0xdf,0xff,0xbb,0x7f,0xfe,0xf6,0xff,0xdf,0xef,
+0x3f,0x40,0x7f,0x00,0xef,0x9f,0x70,0x90,0xe0,0x00,0xc0,0x20,0xe0,0x20,0xc0,0x00,0xbf,0xff,0xff,0xff,0xef,0x70,0x7f,0xef,0xff,0xff,0xdf,0xff,0xff,0xdf,0xff,0xff,
+0xc0,0x21,0xe1,0x00,0x73,0x92,0x71,0x92,0xe1,0x92,0xe3,0x90,0x7f,0x0c,0x3b,0x4c,0xde,0xff,0xff,0xff,0x7f,0xed,0x7d,0xef,0xed,0x7f,0xef,0x7f,0xff,0xf3,0xbb,0xf7,
+0xcd,0x12,0x9f,0x50,0x8f,0x40,0xc6,0x49,0x87,0x09,0x0c,0x8a,0x0e,0x8a,0x80,0x84,0xed,0xff,0xbf,0xef,0xbf,0xff,0xf6,0xbf,0xf7,0xfe,0x7d,0xf7,0x7f,0xf5,0xfb,0x7f,
+0xde,0x50,0x0f,0x81,0x8f,0x81,0x07,0x09,0x06,0x09,0x06,0x09,0x0e,0x09,0x0f,0x08,0xff,0xaf,0x7f,0xfe,0xff,0x7e,0xf7,0xfe,0xf6,0xff,0xf6,0xff,0xfe,0xf7,0xff,0xf7,
+0x38,0x48,0x38,0x48,0xb0,0xc0,0xe0,0x90,0xe0,0x90,0xff,0x80,0xff,0x80,0xff,0x80,0xbf,0xf7,0xbf,0xf7,0xbf,0x7f,0xef,0x7f,0xef,0x7f,0xff,0x7f,0xff,0x7f,0xff,0x7f,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x10,0xf0,0x10,0xd0,0x30,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0xff,0xff,0xef,0xdf,0xef,
+0x79,0x09,0x78,0x08,0xf0,0x80,0xe0,0x90,0x6d,0x9e,0x7f,0x80,0xff,0x00,0xf9,0x07,0xff,0xf6,0xff,0xf7,0xff,0x7f,0xef,0x7f,0x6d,0xf3,0x7f,0xff,0xff,0xff,0xf9,0xfe,
+0x77,0x80,0xf7,0x80,0xf3,0x84,0x63,0x94,0xf7,0x14,0xc3,0x20,0x83,0x42,0x81,0x81,0x7f,0xff,0xff,0x7f,0xfb,0x7f,0x6b,0xff,0xff,0xeb,0xdf,0xff,0xbf,0xfd,0xff,0x7e,
+0x07,0x04,0x03,0x04,0x8f,0x88,0x16,0x99,0xaf,0x71,0xfc,0x02,0xf8,0x04,0x48,0xb8,0xff,0xfb,0xfb,0xff,0xff,0x77,0x76,0xef,0xaf,0xde,0xfd,0xff,0xfb,0xff,0x4f,0xf7,
+0x0e,0x89,0x8e,0x89,0x87,0x89,0x07,0x09,0x0e,0x00,0x0e,0x00,0x1c,0x12,0x1c,0x12,0x7e,0xf7,0xfe,0x77,0xf7,0x7e,0xf7,0xfe,0xff,0xff,0xff,0xff,0xfd,0xef,0xfd,0xef,
+0x00,0x00,0x00,0x00,0x1c,0x22,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x00,0x08,0xff,0xff,0xff,0xff,0xdd,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf7,0xff,
+0x00,0x00,0x00,0x00,0x00,0x88,0x88,0x50,0xf8,0x20,0xa8,0x50,0xa8,0x00,0x20,0xa8,0xff,0xff,0xff,0xff,0x77,0xff,0xaf,0xff,0xff,0xdf,0xaf,0xff,0xff,0xff,0x77,0xdf,
+};
+extern const unsigned int border_chr_size = sizeof(border_chr);
+const unsigned char border_map[]={
+0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,
+0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,
+0x00,0x10,0x00,0x10,0x01,0x10,0x02,0x10,0x02,0x10,0x02,0x10,0x02,0x10,0x02,0x10,0x02,0x10,0x02,0x10,0x02,0x10,0x02,0x10,0x02,0x10,0x02,0x10,0x02,0x10,0x02,0x10,
+0x02,0x10,0x02,0x10,0x02,0x10,0x02,0x10,0x02,0x10,0x02,0x10,0x02,0x10,0x02,0x10,0x02,0x10,0x02,0x10,0x02,0x10,0x02,0x10,0x02,0x10,0x03,0x10,0x00,0x10,0x00,0x10,
+0x00,0x10,0x04,0x10,0x05,0x10,0x06,0x10,0x06,0x10,0x06,0x10,0x06,0x10,0x06,0x10,0x06,0x10,0x06,0x10,0x06,0x10,0x06,0x10,0x06,0x10,0x06,0x10,0x06,0x10,0x06,0x10,
+0x06,0x10,0x06,0x10,0x06,0x10,0x06,0x10,0x06,0x10,0x06,0x10,0x06,0x10,0x06,0x10,0x06,0x10,0x06,0x10,0x06,0x10,0x06,0x10,0x06,0x10,0x07,0x10,0x08,0x10,0x00,0x10,
+0x09,0x10,0x0a,0x10,0x0b,0x10,0x0c,0x10,0x0c,0x10,0x0c,0x10,0x0c,0x10,0x0c,0x10,0x0c,0x10,0x0c,0x10,0x0d,0x10,0x0e,0x10,0x0f,0x10,0x10,0x10,0x11,0x10,0x12,0x10,
+0x13,0x10,0x14,0x10,0x15,0x10,0x16,0x10,0x17,0x10,0x18,0x10,0x19,0x10,0x1a,0x10,0x1b,0x10,0x1c,0x10,0x1d,0x10,0x0c,0x10,0x0c,0x10,0x0b,0x10,0x1e,0x10,0x1f,0x10,
+0x20,0x10,0x21,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x22,0x10,0x23,0x10,0x23,0x10,0x23,0x10,0x23,0x10,0x23,0x10,0x23,0x10,0x23,0x10,0x23,0x10,0x23,0x10,0x23,0x10,
+0x23,0x10,0x23,0x10,0x23,0x10,0x23,0x10,0x23,0x10,0x23,0x10,0x23,0x10,0x23,0x10,0x23,0x10,0x23,0x10,0x24,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x25,0x10,0x26,0x10,
+0x20,0x10,0x21,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x27,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,
+0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x29,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x25,0x10,0x26,0x10,
+0x20,0x10,0x21,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x27,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,
+0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x29,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x25,0x10,0x26,0x10,
+0x20,0x10,0x21,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x27,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,
+0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x29,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x25,0x10,0x26,0x10,
+0x20,0x10,0x21,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x27,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,
+0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x29,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x25,0x10,0x26,0x10,
+0x20,0x10,0x21,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x27,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,
+0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x29,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x25,0x10,0x26,0x10,
+0x20,0x10,0x21,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x27,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,
+0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x29,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x25,0x10,0x26,0x10,
+0x20,0x10,0x21,0x10,0x0b,0x10,0x2a,0x10,0x0b,0x10,0x27,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,
+0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x29,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x25,0x10,0x26,0x10,
+0x20,0x10,0x21,0x10,0x2b,0x10,0x2c,0x10,0x2d,0x10,0x2e,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,
+0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x29,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x25,0x10,0x26,0x10,
+0x20,0x10,0x21,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x27,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,
+0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x29,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x25,0x10,0x26,0x10,
+0x20,0x10,0x21,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x27,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,
+0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x29,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x25,0x10,0x26,0x10,
+0x20,0x10,0x21,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x27,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,
+0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x29,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x25,0x10,0x26,0x10,
+0x20,0x10,0x21,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x27,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,
+0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x29,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x25,0x10,0x26,0x10,
+0x20,0x10,0x21,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x27,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,
+0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x29,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x25,0x10,0x26,0x10,
+0x20,0x10,0x21,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x27,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,
+0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x29,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x25,0x10,0x26,0x10,
+0x20,0x10,0x21,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x27,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,
+0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x29,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x25,0x10,0x2f,0x10,
+0x20,0x10,0x21,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x27,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,
+0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x29,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x30,0x10,0x31,0x10,
+0x20,0x10,0x21,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x27,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,
+0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x29,0x10,0x0b,0x10,0x0b,0x10,0x32,0x10,0x33,0x10,0x00,0x10,
+0x20,0x10,0x21,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x27,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,
+0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x28,0x10,0x29,0x10,0x0b,0x10,0x0b,0x10,0x34,0x10,0x35,0x10,0x00,0x10,
+0x36,0x10,0x37,0x10,0x0b,0x10,0x0b,0x10,0x0b,0x10,0x38,0x10,0x39,0x10,0x39,0x10,0x39,0x10,0x39,0x10,0x39,0x10,0x39,0x10,0x39,0x10,0x39,0x10,0x39,0x10,0x39,0x10,
+0x39,0x10,0x39,0x10,0x39,0x10,0x39,0x10,0x39,0x10,0x39,0x10,0x39,0x10,0x39,0x10,0x39,0x10,0x39,0x10,0x3a,0x10,0x3b,0x10,0x3c,0x10,0x3d,0x10,0x3e,0x10,0x00,0x10,
+0x00,0x10,0x3f,0x10,0x40,0x10,0x41,0x10,0x41,0x10,0x41,0x10,0x41,0x10,0x41,0x10,0x41,0x10,0x41,0x10,0x41,0x10,0x41,0x10,0x41,0x10,0x41,0x10,0x41,0x10,0x41,0x10,
+0x41,0x10,0x41,0x10,0x41,0x10,0x41,0x10,0x41,0x10,0x41,0x10,0x41,0x10,0x41,0x10,0x41,0x10,0x41,0x10,0x42,0x10,0x43,0x10,0x44,0x10,0x45,0x10,0x00,0x10,0x00,0x10,
+0x00,0x10,0x00,0x10,0x46,0x10,0x47,0x10,0x47,0x10,0x47,0x10,0x47,0x10,0x47,0x10,0x47,0x10,0x47,0x10,0x48,0x10,0x49,0x10,0x4a,0x10,0x4b,0x10,0x4c,0x10,0x4d,0x10,
+0x4e,0x10,0x4f,0x10,0x50,0x10,0x51,0x10,0x52,0x10,0x53,0x10,0x54,0x10,0x47,0x10,0x47,0x10,0x55,0x10,0x56,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,
+0x00,0x10,0x00,0x10,0x57,0x10,0x58,0x10,0x00,0x10,0x59,0x10,0x00,0x10,0x00,0x10,0x5a,0x10,0x00,0x10,0x5b,0x10,0x5c,0x10,0x5d,0x10,0x5e,0x10,0x5f,0x10,0x60,0x10,
+0x61,0x10,0x62,0x10,0x63,0x10,0x64,0x10,0x65,0x10,0x66,0x10,0x67,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,
+0x00,0x10,0x00,0x10,0x68,0x10,0x69,0x10,0x6a,0x10,0x6b,0x10,0x6c,0x10,0x6d,0x10,0x6e,0x10,0x6f,0x10,0x70,0x10,0x71,0x10,0x72,0x10,0x73,0x10,0x74,0x10,0x75,0x10,
+0x76,0x10,0x77,0x10,0x78,0x10,0x79,0x10,0x7a,0x10,0x7b,0x10,0x7c,0x10,0x7d,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,
+};
+extern const unsigned int border_map_size = sizeof(border_map);
+const unsigned char border_pal[]={
+0x1f,0x7c,0x98,0x39,0xad,0x3d,0x19,0x63,0x11,0x31,0x49,0x1d,0xed,0x2c,0x94,0x52,0xef,0x45,0xdf,0x59,0xab,0x51,0xce,0x41,0x7c,0x73,0x06,0x3d,0x1f,0x7c,0x1f,0x7c,
+};
+extern const unsigned int border_pal_size = sizeof(border_pal);
diff --git a/gbdk/gbdk-lib/examples/ap/sgb_border/border_data.h b/gbdk/gbdk-lib/examples/ap/sgb_border/border_data.h
new file mode 100644
index 00000000..407d5df1
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/sgb_border/border_data.h
@@ -0,0 +1,14 @@
+#ifndef __SGB_BORDER_DATA_H_INCLUDE
+#define __SGB_BORDER_DATA_H_INCLUDE
+
+#include <gb/gb.h>
+#include <stdint.h>
+
+extern const unsigned char border_chr[];
+extern const unsigned int border_chr_size;
+extern const unsigned char border_map[];
+extern const unsigned int border_map_size;
+extern const unsigned char border_pal[];
+extern const unsigned int border_pal_size;
+
+#endif \ No newline at end of file
diff --git a/gbdk/gbdk-lib/examples/ap/sgb_border/sgb_border.c b/gbdk/gbdk-lib/examples/ap/sgb_border/sgb_border.c
new file mode 100644
index 00000000..1280b191
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/sgb_border/sgb_border.c
@@ -0,0 +1,69 @@
+#include "sgb_border.h"
+
+#include <gb/gb.h>
+#include <stdint.h>
+#include <gb/sgb.h>
+#include <string.h>
+
+#define SGB_CHR_BLOCK0 0
+#define SGB_CHR_BLOCK1 1
+
+#define SGB_SCR_FREEZE 1
+#define SGB_SCR_UNFREEZE 0
+
+#define SGB_TRANSFER(A,B) map_buf[0]=(A),map_buf[1]=(B),sgb_transfer(map_buf)
+
+void set_sgb_border(unsigned char * tiledata, size_t tiledata_size,
+ unsigned char * tilemap, size_t tilemap_size,
+ unsigned char * palette, size_t palette_size) {
+ if (sgb_check()) {
+ unsigned char map_buf[20];
+ memset(map_buf, 0, sizeof(map_buf));
+
+ SGB_TRANSFER((SGB_MASK_EN << 3) | 1, SGB_SCR_FREEZE);
+
+ BGP_REG = OBP0_REG = OBP1_REG = 0xE4U;
+ SCX_REG = SCY_REG = 0U;
+
+ uint8_t tmp_lcdc = LCDC_REG;
+
+ HIDE_SPRITES, HIDE_WIN, SHOW_BKG;
+ DISPLAY_ON;
+ // prepare tilemap for SGB_BORDER_CHR_TRN (should display all 256 tiles)
+ uint8_t i = 0U;
+ for (uint8_t y = 0; y != 14U; ++y) {
+ uint8_t * dout = map_buf;
+ for (uint8_t x = 0U; x != 20U; ++x) {
+ *dout++ = i++;
+ }
+ set_bkg_tiles(0, y, 20, 1, map_buf);
+ }
+ memset(map_buf, 0, sizeof(map_buf));
+
+ // transfer tile data
+ uint8_t ntiles = (tiledata_size > 256 * 32) ? 0 : tiledata_size >> 5;
+ if ((!ntiles) || (ntiles > 128U)) {
+ set_bkg_data(0, 0, tiledata);
+ SGB_TRANSFER((SGB_CHR_TRN << 3) | 1, SGB_CHR_BLOCK0);
+ if (ntiles) ntiles -= 128U;
+ tiledata += (128 * 32);
+ set_bkg_data(0, ntiles << 1, tiledata);
+ SGB_TRANSFER((SGB_CHR_TRN << 3) | 1, SGB_CHR_BLOCK1);
+ } else {
+ set_bkg_data(0, ntiles << 1, tiledata);
+ SGB_TRANSFER((SGB_CHR_TRN << 3) | 1, SGB_CHR_BLOCK0);
+ }
+
+ // transfer map and palettes
+ set_bkg_data(0, (uint8_t)(tilemap_size >> 4), tilemap);
+ set_bkg_data(128, (uint8_t)(palette_size >> 4), palette);
+ SGB_TRANSFER((SGB_PCT_TRN << 3) | 1, 0);
+
+ LCDC_REG = tmp_lcdc;
+
+ // clear SCREEN
+ fill_bkg_rect(0, 0, 20, 18, 0);
+
+ SGB_TRANSFER((SGB_MASK_EN << 3) | 1, SGB_SCR_UNFREEZE);
+ }
+}
diff --git a/gbdk/gbdk-lib/examples/ap/sgb_border/sgb_border.h b/gbdk/gbdk-lib/examples/ap/sgb_border/sgb_border.h
new file mode 100644
index 00000000..a1967cab
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/sgb_border/sgb_border.h
@@ -0,0 +1,24 @@
+#ifndef __SGB_BORDER_H_INCLUDE
+#define __SGB_BORDER_H_INCLUDE
+
+#include <gb/gb.h>
+#include <stdint.h>
+
+#define SNES_RGB(R,G,B) (uint16_t)((B) << 10 | (G) << 5 | (R))
+
+/** sets SGB border
+
+ When using the SGB with a PAL SNES, a delay should be added
+ just after program startup such as:
+
+ \code{.c}
+ // Wait 4 frames
+ // For PAL SNES this delay is required on startup
+ for (uint8_t i = 4; i != 0; i--) wait_vbl_done();
+ \endcode
+*/
+void set_sgb_border(unsigned char * tiledata, size_t tiledata_size,
+ unsigned char * tilemap, size_t tilemap_size,
+ unsigned char * palette, size_t palette_size);
+
+#endif \ No newline at end of file
diff --git a/gbdk/gbdk-lib/examples/ap/sgb_multiplayer/Makefile b/gbdk/gbdk-lib/examples/ap/sgb_multiplayer/Makefile
new file mode 100644
index 00000000..8473a878
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/sgb_multiplayer/Makefile
@@ -0,0 +1,17 @@
+CC = ../../../bin/lcc -msm83:ap -Wl-j -Wm-yS -Wm-ys
+
+BINS = sgb_multiplayer.pocket
+
+all: $(BINS)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+# Compile and link single file in one pass
+%.pocket: %.c
+ $(CC) -o $@ $<
+
+clean:
+ rm -f *.o *.lst *.map *.pocket *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi
+
diff --git a/gbdk/gbdk-lib/examples/ap/sgb_multiplayer/sgb_multiplayer.c b/gbdk/gbdk-lib/examples/ap/sgb_multiplayer/sgb_multiplayer.c
new file mode 100644
index 00000000..1677e190
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/sgb_multiplayer/sgb_multiplayer.c
@@ -0,0 +1,43 @@
+#include <gb/gb.h>
+#include <stdint.h>
+#include <gb/sgb.h>
+
+uint8_t sprite_data[] = {
+ 0x3C,0x3C,0x42,0x7E,0x99,0xFF,0xA9,0xFF,0x89,0xFF,0x89,0xFF,0x42,0x7E,0x3C,0x3C,
+ 0x3C,0x3C,0x42,0x7E,0xB9,0xFF,0x89,0xFF,0x91,0xFF,0xB9,0xFF,0x42,0x7E,0x3C,0x3C,
+ 0x3C,0x3C,0x42,0x7E,0x99,0xFF,0x89,0xFF,0x99,0xFF,0x89,0xFF,0x5A,0x7E,0x3C,0x3C,
+ 0x3C,0x3C,0x42,0x7E,0xA9,0xFF,0xA9,0xFF,0xB9,0xFF,0x89,0xFF,0x42,0x7E,0x3C,0x3C
+};
+
+joypads_t joypads;
+
+void main(void) {
+ BGP_REG = OBP0_REG = OBP1_REG = 0xE4;
+ set_sprite_data(0, 4, sprite_data);
+ for (uint8_t i = 0; i < 4; i++) {
+ set_sprite_tile(i, i);
+ move_sprite(i, (i << 3) + 64, 64);
+ }
+ SHOW_SPRITES;
+
+ // init joypads
+ joypad_init(4, &joypads);
+
+ while(1) {
+ // poll joypads
+ joypad_ex(&joypads);
+ // iterate joypads, move sprites
+ for (uint8_t i = 0; i < joypads.npads; i++) {
+ uint8_t joy = joypads.joypads[i];
+ if (joy & J_LEFT) scroll_sprite(i, -1, 0);
+ if (joy & J_RIGHT) scroll_sprite(i, 1, 0);
+ if (joy & J_UP) scroll_sprite(i, 0, -1);
+ if (joy & J_DOWN) scroll_sprite(i, 0, 1);
+ }
+ // start on joypad 1 resets position
+ if (joypads.joy0 & J_START) {
+ for (uint8_t i = 0; i < 4; i++) move_sprite(i, (i << 3) + 64, 64);
+ }
+ wait_vbl_done();
+ }
+} \ No newline at end of file
diff --git a/gbdk/gbdk-lib/examples/ap/sound/Makefile b/gbdk/gbdk-lib/examples/ap/sound/Makefile
new file mode 100644
index 00000000..1c1cc2bc
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/sound/Makefile
@@ -0,0 +1,17 @@
+CC = ../../../bin/lcc -msm83:ap -Wl-j -Wm-yS
+
+BINS = sound.pocket
+
+all: $(BINS)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+# Compile and link single file in one pass
+%.pocket: %.c
+ $(CC) -o $@ $<
+
+clean:
+ rm -f *.o *.lst *.map *.pocket *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi
+
diff --git a/gbdk/gbdk-lib/examples/ap/sound/readme.md b/gbdk/gbdk-lib/examples/ap/sound/readme.md
new file mode 100644
index 00000000..cc9a9faf
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/sound/readme.md
@@ -0,0 +1,13 @@
+Updated version of the original Sound Sample that merges
+in changes made at: https://github.com/gbdk-2020/GBSoundDemo
+
+Keys:
+- Select: change current channel menu
+- Start: play current Sound
+- Start + A: play a song
+- Arrows: navigate throught options
+- Arrows + A: Increments/Decrements current value by 10
+- Arrows + B: Increments/Decrements current value by 100
+- Arrows + A + B: set Min/Max value to current option
+- Select + A: Dump Registers
+
diff --git a/gbdk/gbdk-lib/examples/ap/sound/sound.c b/gbdk/gbdk-lib/examples/ap/sound/sound.c
new file mode 100644
index 00000000..57193f37
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/sound/sound.c
@@ -0,0 +1,1067 @@
+#include <gb/gb.h>
+#include <gbdk/console.h>
+#include <stdint.h>
+#include <stdio.h>
+
+#define ARROW_CHAR '>'
+#define SPACE_CHAR ' '
+
+#define ARROW_X 0
+#define VAL_X 15
+#define TITLE_Y 0
+#define FIRST_X (ARROW_X+1)
+#define FIRST_Y (TITLE_Y+2)
+
+#define PLAY 0x20
+#define FREQUENCY 0x21
+
+#define MIN(x,y) ((x) > (y) ? (y) : (x))
+#define MAX(x,y) ((x) < (y) ? (y) : (x))
+
+#define NB_MODES 5
+
+#define UNSIGNED 0
+
+uint8_t previous_keys = 0;
+int8_t keys = 0;
+#define UPDATE_KEYS() previous_keys = keys; keys = joypad()
+#define KEY_PRESSED(K) (keys & (K))
+#define KEY_TICKED(K) ((keys & (K)) && !(previous_keys & (K)))
+
+void show_register_channel(uint8_t mode);
+
+void clss() {
+ uint8_t i = 0;
+ for(i = 0; i < 18; ++i) {
+ gotoxy(0, i);
+ printf(" ");
+ }
+}
+
+void print(const char* str) {
+ printf("%s", str);
+}
+
+const char hex[] = "0123456789ABCDEF";
+void printn(uint16_t n, uint8_t base, uint8_t sign) {
+ (void) sign;
+ if(base == 16u) {
+ printf("%c", hex[0x000Fu & (n >> 4u)]);
+ printf("%c", hex[0x000Fu & (n)]);
+ } else {
+ printf("%d", n);
+ }
+}
+
+
+void println(uint16_t n, uint8_t base, uint8_t sign) {
+ printn(n, base, sign);
+ printf("\n");
+}
+
+enum notes {
+ C0, Cd0, D0, Dd0, E0, F0, Fd0, G0, Gd0, A0, Ad0, B0,
+ C1, Cd1, D1, Dd1, E1, F1, Fd1, G1, Gd1, A1, Ad1, B1,
+ C2, Cd2, D2, Dd2, E2, F2, Fd2, G2, Gd2, A2, Ad2, B2,
+ C3, Cd3, D3, Dd3, E3, F3, Fd3, G3, Gd3, A3, Ad3, B3,
+ C4, Cd4, D4, Dd4, E4, F4, Fd4, G4, Gd4, A4, Ad4, B4,
+ C5, Cd5, D5, Dd5, E5, F5, Fd5, G5, Gd5, A5, Ad5, B5,
+ SILENCE, END
+};
+
+const uint16_t frequencies[] = {
+ 44, 156, 262, 363, 457, 547, 631, 710, 786, 854, 923, 986,
+ 1046, 1102, 1155, 1205, 1253, 1297, 1339, 1379, 1417, 1452, 1486, 1517,
+ 1546, 1575, 1602, 1627, 1650, 1673, 1694, 1714, 1732, 1750, 1767, 1783,
+ 1798, 1812, 1825, 1837, 1849, 1860, 1871, 1881, 1890, 1899, 1907, 1915,
+ 1923, 1930, 1936, 1943, 1949, 1954, 1959, 1964, 1969, 1974, 1978, 1982,
+ 1985, 1988, 1992, 1995, 1998, 2001, 2004, 2006, 2009, 2011, 2013, 2015
+};
+
+const uint8_t music[] = {
+ C3, C3, G3, G3, A3, A3, G3, SILENCE,
+ F3, F3, E3, E3, D3, D3, C3, SILENCE,
+ G3, G3, F3, F3, E3, E3, D3, D3,
+ G3, G3, F3, F3, E3, E3, D3, D3,
+ C3, C3, G3, G3, A3, A3, G3, SILENCE,
+ F3, F3, E3, E3, D3, D3, C3, SILENCE,
+ END
+};
+
+struct Params {
+ char *name;
+ uint16_t max;
+};
+
+const struct Params params_0[] = {
+ { "Main Controls" , 0 },
+ { "All On/Off" , 1 },
+ { "Vin->SO1" , 1 },
+ { "Vin->SO2" , 1 },
+ { "SO1 Volume" , 7 },
+ { "SO2 Volume" , 7 },
+ { NULL , 0 }
+};
+
+const struct Params params_1[] = {
+ { "Sound Mode #1" , 0 },
+ { "Swp Time" , 7 },
+ { "Swp Mode" , 1 },
+ { "Swp Shifts" , 7 },
+ { "Pat Duty" , 3 },
+ { "Sound Len" , 63 },
+ { "Env Init" , 15 },
+ { "Env Mode" , 1 },
+ { "Env Nb Swp" , 7 },
+ { "Frequency" , 2047 },
+ { "Cons Sel" , 1 },
+ { "Out to SO1" , 1 },
+ { "Out to SO2" , 1 },
+ { "On/Off" , 1 },
+ { NULL , 0 }
+};
+
+const struct Params params_2[] = {
+ { "Sound Mode #2" , 0 },
+ { "Pat Duty" , 3 },
+ { "Sound Len" , 63 },
+ { "Env Init" , 15 },
+ { "Env Mode" , 1 },
+ { "Env Nb Step" , 7 },
+ { "Frequency" , 2047 },
+ { "Cons Sel" , 1 },
+ { "Out to SO1" , 1 },
+ { "Out to SO2" , 1 },
+ { "On/Off" , 1 },
+ { NULL , 0 }
+};
+
+const struct Params params_3[] = {
+ { "Sound Mode #3" , 0 },
+ { "Sound On/Off" , 1 },
+ { "Sound Len" , 255 },
+ { "Sel Out Level" , 3 },
+ { "Frequency" , 2047 },
+ { "Cons Sel" , 1 },
+ { "Out to SO1" , 1 },
+ { "Out to SO2" , 1 },
+ { "On/Off" , 1 },
+ { NULL , 0 }
+};
+
+const struct Params params_4[] = {
+ { "Sound Mode #4" , 0 },
+ { "Sound Len" , 63 },
+ { "Env Init" , 15 },
+ { "Env Mode" , 1 },
+ { "Env Nb Step" , 7 },
+ { "Poly Cnt Freq" , 15 },
+ { "Poly Cnt Step" , 1 },
+ { "Poly Cnt Div" , 7 },
+ { "Cons Sel" , 1 },
+ { "Out to SO1" , 1 },
+ { "Out to SO2" , 1 },
+ { "On/Off" , 1 },
+ { NULL , 0 }
+};
+
+const struct Params *params_array[] = {
+ params_0,
+ params_1,
+ params_2,
+ params_3,
+ params_4,
+};
+
+const struct Params *params;
+
+struct SoundReg {
+ struct {
+ //NR10 0xFF10
+ uint16_t sweepShifts ;//: 3;
+ uint16_t sweepMode ;//: 1;
+ uint16_t sweepTime ;//: 3;
+ uint16_t unused_1 ;//: 1;
+
+ //NR11 0xFF11
+ uint16_t soundLength ;//: 6;
+ uint16_t patternDuty ;//: 2;
+
+ //NR12 0xFF12
+ uint16_t envNbSweep ;//: 3;
+ uint16_t envMode ;//: 1;
+ uint16_t envInitialValue ;//: 4;
+
+ //NR13 0xFF13
+ uint16_t frequencyLow;
+
+ //NR14 0xFF14
+ uint16_t frequencyHigh ;//: 3;
+ uint16_t unused_2 ;//: 3;
+ uint16_t counter_ConsSel ;//: 1;
+ uint16_t restart ;//: 1;
+ } mode1;
+ struct {
+ //NR20 0xFF15
+ uint16_t unused_1;
+
+ //NR21 0xFF16
+ uint16_t soundLength ;//: 6;
+ uint16_t patternDuty ;//: 2;
+
+ //NR22 0xFF17
+ uint16_t envNbStep ;//: 3;
+ uint16_t envMode ;//: 1;
+ uint16_t envInitialValue ;//: 4;
+
+ //NR23 0xFF18
+ uint16_t frequencyLow;
+
+ //NR24 0xFF19
+ uint16_t frequencyHigh ;//: 3;
+ uint16_t unused_2 ;//: 3;
+ uint16_t counter_ConsSel ;//: 1;
+ uint16_t restart ;//: 1;
+ } mode2;
+ struct {
+ //NR30 0xFF1A
+ uint16_t unused_1 ;//: 7;
+ uint16_t on_Off ;//: 1;
+
+ //NR31 0xFF1B
+ uint16_t soundLength;
+
+ //NR32 0xFF1C
+ uint16_t unused_2 ;//: 5;
+ uint16_t selOutputLevel ;//: 2;
+ uint16_t unused_3 ;//: 1;
+
+ //NR33 0xFF1D
+ uint16_t frequencyLow;
+
+ //NR34 0xFF1E
+ uint16_t frequencyHigh ;//: 3;
+ uint16_t unused_4 ;//: 3;
+ uint16_t counter_ConsSel ;//: 1;
+ uint16_t restart ;//: 1;
+ } mode3;
+ struct {
+ //NR40 0xFF1F
+ uint16_t unused_1;
+
+ //NR41 0xFF20
+ uint16_t soundLength ;//: 6;
+ uint16_t unused_2 ;//: 2;
+
+ //NR42 0xFF21
+ uint16_t envNbStep ;//: 3;
+ uint16_t envMode ;//: 1;
+ uint16_t envInitialValue ;//: 4;
+
+ //NR43 0xFF22
+ uint16_t polyCounterDiv ;//: 3;
+ uint16_t polyCounterStep ;//: 1;
+ uint16_t polyCounterFreq ;//: 4;
+
+ //NR44 0xFF23
+ uint16_t unused_3 ;//: 6;
+ uint16_t counter_ConsSel ;//: 1;
+ uint16_t restart ;//: 1;
+ } mode4;
+ struct {
+ // NR50 0xFF24
+ uint16_t SO1_OutputLevel ;//: 3;
+ uint16_t Vin_SO1 ;//: 1;
+ uint16_t SO2_OutputLevel ;//: 3;
+ uint16_t Vin_SO2 ;//: 1;
+
+ // NR51 0xFF25
+ uint16_t Sound1_To_SO1 ;//: 1;
+ uint16_t Sound2_To_SO1 ;//: 1;
+ uint16_t Sound3_To_SO1 ;//: 1;
+ uint16_t Sound4_To_SO1 ;//: 1;
+ uint16_t Sound1_To_SO2 ;//: 1;
+ uint16_t Sound2_To_SO2 ;//: 1;
+ uint16_t Sound3_To_SO2 ;//: 1;
+ uint16_t Sound4_To_SO2 ;//: 1;
+
+ // NR52 0xFF26
+ uint16_t Sound1_On_Off ;//: 1;
+ uint16_t Sound2_On_Off ;//: 1;
+ uint16_t Sound3_On_Off ;//: 1;
+ uint16_t Sound4_On_Off ;//: 1;
+ uint16_t unused_1 ;//: 3;
+ uint16_t global_On_Off ;//: 1;
+ } control;
+};
+
+struct SoundReg *soundReg;
+
+struct SoundReg s = {
+ { 0u, 0u, 0u, 0u,
+ 1, 2,
+ 3, 0, 4,
+ 0x73U,
+ 6, 0, 0, 0 },
+ { 0,
+ 1, 2,
+ 4, 0, 8,
+ 0xD7U,
+ 6, 0, 0, 0 },
+ { 0, 1,
+ 0,
+ 0, 3, 0,
+ 0xD6U,
+ 6, 0, 1, 0 },
+ { 0,
+ 58, 0,
+ 1, 0, 10,
+ 0, 0, 0,
+ 0, 1, 0 },
+ { 7, 0, 7, 0,
+ 1, 1, 1, 1, 1, 1, 1, 1,
+ 0, 0, 0, 0, 0, 1 }
+};
+
+uint8_t NR10() {
+ return soundReg->mode1.sweepShifts | (soundReg->mode1.sweepMode << 3) | (soundReg->mode1.sweepTime << 4);
+}
+
+uint8_t NR11() {
+ return soundReg->mode1.soundLength | (soundReg->mode1.patternDuty << 6);
+}
+
+uint8_t NR12() {
+ return soundReg->mode1.envNbSweep | (soundReg->mode1.envMode << 3) | (soundReg->mode1.envInitialValue << 4);
+}
+
+uint8_t NR13() {
+ return soundReg->mode1.frequencyLow;
+}
+
+uint8_t NR14() {
+ return soundReg->mode1.frequencyHigh | (soundReg->mode1.counter_ConsSel << 6) | (soundReg->mode1.restart << 7);
+}
+
+//--------------------------
+uint8_t NR21() {
+ return soundReg->mode2.soundLength | (soundReg->mode2.patternDuty << 6);
+}
+
+uint8_t NR22() {
+ return soundReg->mode2.envNbStep | (soundReg->mode2.envMode << 3) | (soundReg->mode2.envInitialValue << 4);
+}
+
+uint8_t NR23() {
+ return soundReg->mode2.frequencyLow;
+}
+
+uint8_t NR24() {
+ return soundReg->mode2.frequencyHigh | (soundReg->mode2.counter_ConsSel << 6) | (soundReg->mode2.restart << 7);
+}
+
+//-------------------------------
+uint8_t NR30() {
+ return soundReg->mode3.on_Off << 7;
+}
+
+uint8_t NR31() {
+ return soundReg->mode3.soundLength;
+}
+
+uint8_t NR32() {
+ return soundReg->mode3.selOutputLevel << 5;
+}
+
+uint8_t NR33() {
+ return soundReg->mode3.frequencyLow;
+}
+
+uint8_t NR34() {
+ return soundReg->mode3.frequencyHigh | (soundReg->mode3.counter_ConsSel << 6) | (soundReg->mode3.restart << 7);
+}
+
+//-------------------------------
+uint8_t NR41() {
+ return soundReg->mode4.soundLength;
+}
+
+uint8_t NR42() {
+ return soundReg->mode4.envNbStep | (soundReg->mode4.envMode << 3) | (soundReg->mode4.envInitialValue << 4);
+}
+
+uint8_t NR43() {
+ return soundReg->mode4.polyCounterDiv | (soundReg->mode4.polyCounterStep << 3) | (soundReg->mode4.polyCounterFreq << 4);
+}
+
+uint8_t NR44() {
+ return (soundReg->mode4.counter_ConsSel << 6) | (soundReg->mode4.restart << 7);
+}
+
+//-------------------------------
+uint8_t NR50() {
+ return soundReg->control.SO1_OutputLevel | (soundReg->control.Vin_SO1 << 3u) | (soundReg->control.SO2_OutputLevel << 4u) |
+ (soundReg->control.Vin_SO2 << 7u);
+}
+
+uint8_t NR51() {
+ return soundReg->control.Sound1_To_SO1 | (soundReg->control.Sound2_To_SO1 << 1) | (soundReg->control.Sound3_To_SO1 << 2) |
+ (soundReg->control.Sound4_To_SO1 << 3) | (soundReg->control.Sound1_To_SO2 << 4) | (soundReg->control.Sound2_To_SO2 << 5) |
+ (soundReg->control.Sound3_To_SO2 << 6)| (soundReg->control.Sound4_To_SO2 << 7);
+}
+
+uint8_t NR52() {
+ return soundReg->control.global_On_Off << 7;
+}
+
+//---------------------------------------------------------------------------------
+uint16_t current_value(uint8_t mode, uint8_t line)
+{
+ if(mode == 0) {
+ switch(line)
+ {
+ case 0: // global_On_Off
+ return soundReg->control.global_On_Off;
+ case 1: // Vin_SO1
+ return soundReg->control.Vin_SO1;
+ case 2: // Vin_SO2
+ return soundReg->control.Vin_SO2;
+ case 3: // SO1_OutputLevel
+ return soundReg->control.SO1_OutputLevel;
+ case 4: // SO2_OutputLevel
+ return soundReg->control.SO2_OutputLevel;
+ }
+ } else if(mode == 1) {
+ switch(line)
+ {
+ case 0: // sweepTime
+ return soundReg->mode1.sweepTime;
+ case 1: // sweepMode
+ return soundReg->mode1.sweepMode;
+ case 2: // sweepShifts
+ return soundReg->mode1.sweepShifts;
+ case 3: // patternDuty
+ return soundReg->mode1.patternDuty;
+ case 4: // soundLength
+ return soundReg->mode1.soundLength;
+ case 5: // envInitialValue
+ return soundReg->mode1.envInitialValue;
+ case 6: // envMode
+ return soundReg->mode1.envMode;
+ case 7: // envNbSweep
+ return soundReg->mode1.envNbSweep;
+ case 8: // frequency
+ case FREQUENCY:
+ return (soundReg->mode1.frequencyHigh << 8) | soundReg->mode1.frequencyLow;
+ case 9: // counter_ConsSel
+ return soundReg->mode1.counter_ConsSel;
+ case 10: // Sound1_To_SO1
+ return soundReg->control.Sound1_To_SO1;
+ case 11: // Sound1_To_SO2
+ return soundReg->control.Sound1_To_SO2;
+ case 12: // Sound1_On_Off
+ return soundReg->control.Sound1_On_Off;
+ }
+ } else if(mode == 2) {
+ switch(line)
+ {
+ case 0: // patternDuty
+ return soundReg->mode2.patternDuty;
+ case 1: // soundLength
+ return soundReg->mode2.soundLength;
+ case 2: // envInitialValue
+ return soundReg->mode2.envInitialValue;
+ case 3: // envMode
+ return soundReg->mode2.envMode;
+ case 4: // envNbStep
+ return soundReg->mode2.envNbStep;
+ case 5: // frequency
+ case FREQUENCY:
+ return (soundReg->mode2.frequencyHigh << 8) | soundReg->mode2.frequencyLow;
+ case 6: // counter_ConsSel
+ return soundReg->mode2.counter_ConsSel;
+ case 7: // Sound2_To_SO1
+ return soundReg->control.Sound2_To_SO1;
+ case 8: // Sound2_To_SO2
+ return soundReg->control.Sound2_To_SO2;
+ case 9: // Sound2_On_Off
+ return soundReg->control.Sound2_On_Off;
+ }
+ } else if(mode == 3) {
+ switch(line)
+ {
+ case 0: // on_Off
+ return soundReg->mode3.on_Off;
+ case 1: // soundLength
+ return soundReg->mode3.soundLength;
+ case 2: // selOutputLevel
+ return soundReg->mode3.selOutputLevel;
+ case 3: // frequency
+ case FREQUENCY:
+ return (soundReg->mode3.frequencyHigh << 8) | soundReg->mode3.frequencyLow;
+ case 4: // counter_ConsSel
+ return soundReg->mode3.counter_ConsSel;
+ case 5: // Sound3_To_SO1
+ return soundReg->control.Sound3_To_SO1;
+ case 6: // Sound3_To_SO2
+ return soundReg->control.Sound3_To_SO2;
+ case 7: // Sound3_On_Off
+ return soundReg->control.Sound3_On_Off;
+ }
+ } else if(mode == 4) {
+ switch(line)
+ {
+ case 0: // soundLength
+ return soundReg->mode4.soundLength;
+ case 1: // envInitialValue
+ return soundReg->mode4.envInitialValue;
+ case 2: // envMode
+ return soundReg->mode4.envMode;
+ case 3: // envNbStep
+ return soundReg->mode4.envNbStep;
+ case 4: // polyCounterFreq
+ return soundReg->mode4.polyCounterFreq;
+ case 5: // polyCounterStep
+ return soundReg->mode4.polyCounterStep;
+ case 6: // polyCounterDiv
+ return soundReg->mode4.polyCounterDiv;
+ case 7: // counter_ConsSel
+ return soundReg->mode4.counter_ConsSel;
+ case 8: // Sound4_To_SO1
+ return soundReg->control.Sound4_To_SO1;
+ case 9: // Sound4_To_SO2
+ return soundReg->control.Sound4_To_SO2;
+ case 10: // Sound4_On_Off
+ return soundReg->control.Sound4_On_Off;
+ }
+ }
+ return 0;
+}
+
+void update_value(uint8_t mode, uint8_t line, uint16_t value)
+{
+ if(mode == 0) {
+ switch(line)
+ {
+ case 0: // global_On_Off
+ soundReg->control.global_On_Off = value;
+ NR52_REG = NR52();
+ break;
+ case 1: // Vin_SO1
+ soundReg->control.Vin_SO1 = value;
+ NR50_REG = NR50();
+ break;
+ case 2: // Vin_SO2
+ soundReg->control.Vin_SO2 = value;
+ NR50_REG = NR50();
+ break;
+ case 3: // SO1_OutputLevel
+ soundReg->control.SO1_OutputLevel = value;
+ NR50_REG = NR50();
+ break;
+ case 4: // SO2_OutputLevel
+ soundReg->control.SO2_OutputLevel = value;
+ NR50_REG = NR50();
+ break;
+ case FREQUENCY:
+ update_value(1, FREQUENCY, value);
+ update_value(2, FREQUENCY, value);
+ update_value(3, FREQUENCY, value);
+ break;
+ case PLAY: // restart
+ update_value(1, FREQUENCY, current_value(1, FREQUENCY));
+ update_value(2, FREQUENCY, current_value(2, FREQUENCY));
+ update_value(3, FREQUENCY, current_value(3, FREQUENCY));
+ soundReg->mode1.restart = value;
+ soundReg->mode2.restart = value;
+ soundReg->mode3.restart = value;
+ soundReg->mode4.restart = value;
+ NR14_REG = NR14();
+ NR24_REG = NR24();
+ NR34_REG = NR34();
+ NR44_REG = NR44();
+ soundReg->mode1.restart = 0;
+ soundReg->mode2.restart = 0;
+ soundReg->mode3.restart = 0;
+ soundReg->mode4.restart = 0;
+ break;
+ }
+ } else if(mode == 1) {
+ switch(line)
+ {
+ case 0: // sweepTime
+ soundReg->mode1.sweepTime = value;
+ NR10_REG = NR10();
+ break;
+ case 1: // sweepMode
+ soundReg->mode1.sweepMode = value;
+ NR10_REG = NR10();
+ break;
+ case 2: // sweepShifts
+ soundReg->mode1.sweepShifts = value;
+ NR10_REG = NR10();
+ break;
+ case 3: // patternDuty
+ soundReg->mode1.patternDuty = value;
+ NR11_REG = NR11();
+ break;
+ case 4: // soundLength
+ soundReg->mode1.soundLength = value;
+ NR11_REG = NR11();
+ break;
+ case 5: // envInitialValue
+ soundReg->mode1.envInitialValue = value;
+ NR12_REG = NR12();
+ break;
+ case 6: // envMode
+ soundReg->mode1.envMode = value;
+ NR12_REG = NR12();
+ break;
+ case 7: // envNbSweep
+ soundReg->mode1.envNbSweep = value;
+ NR12_REG = NR12();
+ break;
+ case 8: // frequency
+ case FREQUENCY:
+ soundReg->mode1.frequencyHigh = value >> 8;
+ soundReg->mode1.frequencyLow = 0xFF & value;
+ NR13_REG = NR13();
+ NR14_REG = NR14();
+ break;
+ case 9: // counter_ConsSel
+ soundReg->mode1.counter_ConsSel = value;
+ NR14_REG = NR14();
+ break;
+ case 10: // Sound1_To_SO1
+ soundReg->control.Sound1_To_SO1 = value;
+ NR51_REG = NR51();
+ break;
+ case 11: // Sound1_To_SO2
+ soundReg->control.Sound1_To_SO2 = value;
+ NR51_REG = NR51();
+ break;
+ case 12: // Sound1_On_Off
+ soundReg->control.Sound1_On_Off = value;
+ NR52_REG = NR52();
+ break;
+ case PLAY: // restart
+ update_value(mode, FREQUENCY, current_value(mode, FREQUENCY));
+ soundReg->mode1.restart = value;
+ NR14_REG = NR14();
+ soundReg->mode1.restart = 0;
+ break;
+ }
+ } else if(mode == 2) {
+ switch(line)
+ {
+ case 0: // patternDuty
+ soundReg->mode2.patternDuty = value;
+ NR21_REG = NR21();
+ break;
+ case 1: // soundLength
+ soundReg->mode2.soundLength = value;
+ NR21_REG = NR21();
+ break;
+ case 2: // envInitialValue
+ soundReg->mode2.envInitialValue = value;
+ NR22_REG = NR22();
+ break;
+ case 3: // envMode
+ soundReg->mode2.envMode = value;
+ NR22_REG = NR22();
+ break;
+ case 4: // envNbStep
+ soundReg->mode2.envNbStep = value;
+ NR22_REG = NR22();
+ break;
+ case 5: // frequency
+ case FREQUENCY:
+ soundReg->mode2.frequencyHigh = value >> 8;
+ soundReg->mode2.frequencyLow = 0xFF & value;
+ NR23_REG = NR23();
+ NR24_REG = NR24();
+ break;
+ case 6: // counter_ConsSel
+ soundReg->mode2.counter_ConsSel = value;
+ NR24_REG = NR24();
+ break;
+ case 7: // Sound2_To_SO1
+ soundReg->control.Sound2_To_SO1 = value;
+ NR51_REG = NR51();
+ break;
+ case 8: // Sound2_To_SO2
+ soundReg->control.Sound2_To_SO2 = value;
+ NR51_REG = NR51();
+ break;
+ case 9: // Sound2_On_Off
+ soundReg->control.Sound2_On_Off = value;
+ NR52_REG = NR52();
+ break;
+ case PLAY: // restart
+ update_value(mode, FREQUENCY, current_value(mode, FREQUENCY));
+ soundReg->mode2.restart = value;
+ NR24_REG = NR24();
+ soundReg->mode2.restart = 0;
+ break;
+ }
+ } else if(mode == 3) {
+ switch(line)
+ {
+ case 0: // on_Off
+ soundReg->mode3.on_Off = value;
+ NR30_REG = NR30();
+ break;
+ case 1: // soundLength
+ soundReg->mode3.soundLength = value;
+ NR31_REG = NR31();
+ break;
+ case 2: // selOutputLevel
+ soundReg->mode3.selOutputLevel = value;
+ NR32_REG = NR32();
+ break;
+ case 3: // frequency
+ case FREQUENCY:
+ soundReg->mode3.frequencyHigh = value >> 8;
+ soundReg->mode3.frequencyLow = 0xFF & value;
+ NR33_REG = NR33();
+ NR34_REG = NR34();
+ break;
+ case 4: // counter_ConsSel
+ soundReg->mode3.counter_ConsSel = value;
+ NR34_REG = NR34();
+ break;
+ case 5: // Sound3_To_SO1
+ soundReg->control.Sound3_To_SO1 = value;
+ NR51_REG = NR51();
+ break;
+ case 6: // Sound3_To_SO2
+ soundReg->control.Sound3_To_SO2 = value;
+ NR51_REG = NR51();
+ break;
+ case 7: // Sound3_On_Off
+ soundReg->control.Sound3_On_Off = value;
+ NR52_REG = NR52();
+ break;
+ case PLAY: // restart
+ update_value(mode, FREQUENCY, current_value(mode, FREQUENCY));
+ soundReg->mode3.restart = value;
+ NR34_REG = NR34();
+ soundReg->mode3.restart = 0;
+ break;
+ }
+ } else if(mode == 4) {
+ switch(line)
+ {
+ case 0: // soundLength
+ soundReg->mode4.soundLength = value;
+ NR41_REG = NR41();
+ break;
+ case 1: // envInitialValue
+ soundReg->mode4.envInitialValue = value;
+ NR42_REG = NR42();
+ break;
+ case 2: // envMode
+ soundReg->mode4.envMode = value;
+ NR42_REG = NR42();
+ break;
+ case 3: // envNbStep
+ soundReg->mode4.envNbStep = value;
+ NR42_REG = NR42();
+ break;
+ case 4: // polyCounterFreq
+ soundReg->mode4.polyCounterFreq = value;
+ NR43_REG = NR43();
+ break;
+ case 5: // polyCounterStep
+ soundReg->mode4.polyCounterStep = value;
+ NR43_REG = NR43();
+ break;
+ case 6: // polyCounterDiv
+ soundReg->mode4.polyCounterDiv = value;
+ NR43_REG = NR43();
+ break;
+ case 7: // counter_ConsSel
+ soundReg->mode4.counter_ConsSel = value;
+ NR44_REG = NR44();
+ break;
+ case 8: // Sound4_To_SO1
+ soundReg->control.Sound4_To_SO1 = value;
+ NR51_REG = NR51();
+ break;
+ case 9: // Sound4_To_SO2
+ soundReg->control.Sound4_To_SO2 = value;
+ NR51_REG = NR51();
+ break;
+ case 10: // Sound4_On_Off
+ soundReg->control.Sound4_On_Off = value;
+ NR52_REG = NR52();
+ break;
+ case PLAY: // restart
+ soundReg->mode4.restart = value;
+ NR44_REG = NR44();
+ soundReg->mode4.restart = 0;
+ break;
+ }
+ }
+}
+
+uint8_t draw_screen(uint8_t mode)
+{
+ uint8_t i;
+
+ clss();
+ gotoxy(FIRST_X, TITLE_Y);
+ print(params[0].name);
+
+ for(i = 0; params[i+1].name; i++) {
+ gotoxy(FIRST_X, FIRST_Y+i);
+ print(params[i+1].name);
+ gotoxy(VAL_X, FIRST_Y+i);
+ println(current_value(mode, i), 10, UNSIGNED);
+ }
+
+ return i-1;
+}
+
+
+void play_music(uint8_t mode)
+{
+ uint8_t i = 0;
+
+ while(music[i] != END) {
+ if(music[i] != SILENCE) {
+ update_value(mode, FREQUENCY, frequencies[music[i]]);
+ update_value(mode, PLAY, 1);
+ }
+ delay(500);
+ i++;
+ }
+}
+
+
+void show_register_channel(uint8_t mode) {
+
+ switch (mode) {
+ case 1:
+ gotoxy(0, 16);
+ print("NR10-14:");
+
+ gotoxy(1, 17); // Last line
+ printn(NR10(), 16, UNSIGNED); print(", ");
+ printn(NR11(), 16, UNSIGNED); print(", ");
+ printn(NR12(), 16, UNSIGNED); print(", ");
+ printn(NR13(), 16, UNSIGNED); print(", ");
+ printn(0x80 | NR14(), 16, UNSIGNED);
+
+ break;
+
+ case 2:
+ gotoxy(0, 16);
+ print("NR21-24:");
+
+ gotoxy(1, 17); // Last line
+ printn(NR21(), 16, UNSIGNED); print(", ");
+ printn(NR22(), 16, UNSIGNED); print(", ");
+ printn(NR23(), 16, UNSIGNED); print(", ");
+ printn(0x80 | NR24(), 16, UNSIGNED);
+
+ break;
+
+ case 3:
+ gotoxy(0, 16);
+ print("NR30-34:");
+
+ gotoxy(1, 17); // Last line
+ printn(NR30(), 16, UNSIGNED); print(", ");
+ printn(NR31(), 16, UNSIGNED); print(", ");
+ printn(NR32(), 16, UNSIGNED); print(", ");
+ printn(NR33(), 16, UNSIGNED); print(", ");
+ printn(0x80 | NR34(), 16, UNSIGNED);
+
+ break;
+
+ case 4:
+ gotoxy(0, 16);
+ print("NR41-44:");
+
+ gotoxy(1, 17); // Last line
+ printn(NR41(), 16, UNSIGNED); print(", ");
+ printn(NR42(), 16, UNSIGNED); print(", ");
+ printn(NR43(), 16, UNSIGNED); print(", ");
+ printn(0x80 | NR44(), 16, UNSIGNED);
+
+ break;
+
+ case 0:
+ gotoxy(0, 16);
+ print("NR50-52:");
+
+ gotoxy(1, 17); // Last line
+ printn(NR50(), 16, UNSIGNED); print(", ");
+ printn(NR51(), 16, UNSIGNED); print(", ");
+ printn(NR52(), 16, UNSIGNED); print(", ");
+
+ break;
+
+ }
+}
+
+
+void dump_registers()
+{
+ clss();
+ gotoxy(FIRST_X, TITLE_Y);
+ print("Register Dump\n\n");
+
+ print("NR10:");println(NR10(), 16, UNSIGNED);
+ print("NR11:");printn(NR11(), 16, UNSIGNED); print(" NR21:");println(NR21(), 16, UNSIGNED);
+ print("NR12:");printn(NR12(), 16, UNSIGNED); print(" NR22:");println(NR22(), 16, UNSIGNED);
+ print("NR13:");printn(NR13(), 16, UNSIGNED); print(" NR23:");println(NR23(), 16, UNSIGNED);
+ print("NR14:");printn(0x80 | NR14(), 16, UNSIGNED); print(" NR24:");println(0x80 | NR24(), 16, UNSIGNED);
+ printf("\n");
+
+ print("NR30:");println(NR30(), 16, UNSIGNED);
+ print("NR31:");printn(NR31(), 16, UNSIGNED); print(" NR41:");println(NR41(), 16, UNSIGNED);
+ print("NR32:");printn(NR32(), 16, UNSIGNED); print(" NR42:");println(NR42(), 16, UNSIGNED);
+ print("NR33:");printn(NR33(), 16, UNSIGNED); print(" NR43:");println(NR43(), 16, UNSIGNED);
+ print("NR34:");printn(0x80 | NR34(), 16, UNSIGNED); print(" NR44:");println(0x80 | NR44(), 16, UNSIGNED);
+ printf("\n");
+
+ print("NR50:");println(NR50(), 16, UNSIGNED);
+ print("NR51:");println(NR51(), 16, UNSIGNED);
+ print("NR52:");println(NR52(), 16, UNSIGNED);
+}
+
+void wait_event(uint8_t mode)
+{
+ uint8_t y, last_y;
+ uint16_t l = 0;
+ uint16_t m = 0;
+
+ while(1) {
+ params = params_array[mode];
+ last_y = draw_screen(mode) + FIRST_Y;
+ y = FIRST_Y;
+ gotoxy(ARROW_X, y);
+ setchar(ARROW_CHAR);
+
+ show_register_channel(mode);
+
+ while(1) {
+ if(KEY_TICKED(J_UP)) {
+ gotoxy(ARROW_X, y); setchar(SPACE_CHAR);
+ if(--y < FIRST_Y)
+ y = last_y;
+ gotoxy(ARROW_X, y); setchar(ARROW_CHAR);
+
+ } else if(KEY_TICKED(J_DOWN)) {
+ gotoxy(ARROW_X, y); setchar(SPACE_CHAR);
+ if(++y > last_y)
+ y = FIRST_Y;
+ gotoxy(ARROW_X, y); setchar(ARROW_CHAR);
+
+ } else if(KEY_TICKED(J_LEFT)) {
+ l = current_value(mode, y-FIRST_Y);
+ if(l != 0) {
+ if(KEY_PRESSED(J_A) && KEY_PRESSED(J_B))
+ l = 0;
+ else if(KEY_PRESSED(J_A))
+ l = (l > 10) ? (l - 10) : 0;
+ else if(KEY_PRESSED(J_B))
+ l = (l > 100) ? (l - 100) : 0;
+ else
+ l--;
+ update_value(mode, y-FIRST_Y, l);
+ }
+ gotoxy(VAL_X, y); print(" ");
+ gotoxy(VAL_X, y); println(l, 10, UNSIGNED);
+
+ show_register_channel(mode);
+
+ } else if(KEY_TICKED(J_RIGHT)) {
+ l = current_value(mode, y-FIRST_Y);
+ m = params[y-(FIRST_Y-1)].max;
+ if(l != m) {
+ if(KEY_PRESSED(J_A) && KEY_PRESSED(J_B)) {
+ l = m;
+ }
+ else if(KEY_PRESSED(J_A)) {
+ l += 10;
+ if(l > m)
+ l = m;
+ } else if(KEY_PRESSED(J_B)) {
+ l += 100;
+ if(l > m)
+ l = m;
+ }
+ else
+ l++;
+ update_value(mode, y-FIRST_Y, l);
+ }
+ gotoxy(VAL_X, y); print(" ");
+ gotoxy(VAL_X, y); println(l, 10, UNSIGNED);
+
+ show_register_channel(mode);
+
+ } else if(KEY_TICKED(J_START)) {
+ if (KEY_PRESSED(J_A))
+ play_music(mode);
+ else
+ update_value(mode, PLAY, 1);
+
+ } else if(KEY_PRESSED(J_SELECT)) {
+ if(KEY_PRESSED(J_A))
+ dump_registers();
+ else {
+ mode = (mode+1) % NB_MODES;
+ }
+ waitpadup();
+ keys = 0;
+ break;
+ }
+ wait_vbl_done();
+ UPDATE_KEYS();
+ }
+ }
+}
+
+void main()
+{
+ //
+ // Before modifying any sound register, sound must be turned on!
+ // (it is turned off by default to save batteries)
+ //
+ NR52_REG = 0x80;
+
+ soundReg = &s;
+ NR10_REG = NR10();
+ NR11_REG = NR11();
+ NR12_REG = NR12();
+ NR13_REG = NR13();
+ NR14_REG = NR14();
+
+ NR21_REG = NR21();
+ NR22_REG = NR22();
+ NR23_REG = NR23();
+ NR24_REG = NR24();
+
+ NR30_REG = NR30();
+ NR31_REG = NR31();
+ NR32_REG = NR32();
+ NR33_REG = NR33();
+ NR34_REG = NR34();
+
+ NR41_REG = NR41();
+ NR42_REG = NR42();
+ NR43_REG = NR43();
+ NR44_REG = NR44();
+
+ NR50_REG = NR50();
+ NR51_REG = NR51();
+ NR52_REG = NR52();
+
+ clss();
+
+ wait_event(1);
+}
+
diff --git a/gbdk/gbdk-lib/examples/ap/space/Makefile b/gbdk/gbdk-lib/examples/ap/space/Makefile
new file mode 100644
index 00000000..b9161581
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/space/Makefile
@@ -0,0 +1,18 @@
+GBDK = ../../..
+CC = $(GBDK)/bin/lcc -msm83:ap -Wl-j -Wm-yS
+
+BINS = space.pocket
+
+all: $(BINS)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+# Compile and link single file in one pass
+%.pocket: %.s
+ $(CC) -o $@ $<
+
+clean:
+ rm -f *.o *.lst *.map *.pocket *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi
+
diff --git a/gbdk/gbdk-lib/examples/ap/space/space.s b/gbdk/gbdk-lib/examples/ap/space/space.s
new file mode 100644
index 00000000..02aab15c
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/space/space.s
@@ -0,0 +1,1296 @@
+ ;; Little demo illustrating how to use the graphical possibilities
+ ;; of the GB (background, window and animated sprite)
+ ;; I have used fixed-point values for both the position and
+ ;; speed of objects to get smooth movements
+ ;;
+ ;; OBJ data : 0x8000 -> 0x8FFF (unsigned)
+ ;; Window data : 0x8800 -> 0x97FF (signed)
+ ;; Background data : 0x8800 -> 0x97FF (signed)
+ ;;
+ ;; Tiled 0xFC -> 0xFF are standard tiles (all black -> all white)
+ ;;
+ ;; Keys:
+ ;; Arrow keys : Change the speed (and direction) of the sprite
+ ;; Arrow keys + A : Change the speed (and direction) of the window
+ ;; Arrow keys + B : Change the speed (and direction) of the background
+ ;; START : Open/close the door
+ ;; SELECT : Basic fading effect
+ ;;
+ ;; Note that the window is kept in the lower right part of the screen
+ ;; since it can't be made transparent
+
+ .include "global.s"
+
+ .globl .init_vram
+ .globl .copy_vram
+ .globl .init_wtt
+ .globl .init_btt
+ .globl .set_xy_wtt
+ .globl .mv_sprite
+ .globl .set_sprite_prop
+ .globl .set_sprite_tile
+ .globl .jpad
+
+ .NBDFRAMES = .endfilm-.film ; Nb frames for the door
+ .NBSFRAMES = 0x07 ; Nb frames for the sprite
+ .WINSZX = 0x80 ; Size of the picture in the window
+ .WINSZY = 0x50
+ .MINWINX = .MAXWNDPOSX-.WINSZX+1 ; Bounds of the window origin
+ .MINWINY = .MAXWNDPOSY-.WINSZY+1
+ .MAXWINX = .MAXWNDPOSX
+ .MAXWINY = .MAXWNDPOSY
+ .FADESTEP = 0x10 ; Nb steps for the fading effect
+ .STARTFADE = 0x06*.FADESTEP ; Initial value for the fading effect
+
+ .CLOSED = 0x00
+ .OPENING = 0x01
+ .OPENED = 0x02
+ .CLOSING = 0x03
+
+ .module Space
+
+ .area _DATA
+
+.time: ; Global "time" value (counter)
+ .ds 0x01
+
+.doorstate: ; State of the door (OPENED, CLOSED...)
+ .ds 0x01
+.doorpos: ; Current position in the door animation
+ .ds 0x01
+
+.color: ; Current color for fading effect
+ .ds 0x01
+
+.sframe: ; Current frame of the sprite
+ .ds 0x01
+
+.bposx: ; Background position (fixed point)
+ .ds 0x02
+.bposy:
+ .ds 0x02
+.bspx: ; Background speed (fixed point)
+ .ds 0x02
+.bspy:
+ .ds 0x02
+
+.wposx: ; Window position (fixed point)
+ .ds 0x02
+.wposy:
+ .ds 0x02
+.wspx: ; Window speed (fixed point)
+ .ds 0x02
+.wspy:
+ .ds 0x02
+
+.sposx: ; Sprite position (fixed point)
+ .ds 0x02
+.sposy:
+ .ds 0x02
+.sspx: ; Sprite speed (fixed point)
+ .ds 0x02
+.sspy:
+ .ds 0x02
+
+ .area _CODE
+
+_main::
+ DI ; Disable interrupts
+ ;; Turn the screen off
+ CALL .display_off
+
+ XOR A
+ LD (.time),A
+ LD (.color),A
+
+ LD A,#0b11100100
+ LDH (.BGP),A
+ LDH (.OBP0),A
+
+ ; Initialize tiles
+ LD HL,#0x8000
+ LD DE,#0x1000
+ LD B,#0x00
+ CALL .init_vram ; Init the tile set at 0x8000 with 0x00
+ LD B,#0xFF
+ CALL .init_btt ; Init the tiles tables with 0xFF
+ CALL .init_wtt
+
+ LD BC,#.tp0 ; Move tiles (standard tiles)
+ LD HL,#0x9000-(.endtp0-.tp0)
+ LD DE,#.endtp0-.tp0
+ CALL .copy_vram
+
+ LD BC,#.tp1 ; Move tiles (earth)
+ LD HL,#0x8000
+ LD DE,#.endtp1-.tp1
+ CALL .copy_vram
+
+ LD BC,#.tp2 ; Move tiles (door)
+ LD HL,#0x8800
+ LD DE,#.endtp2-.tp2
+ CALL .copy_vram
+
+ LD BC,#.tp3 ; Move tiles (background)
+ LD HL,#0x9000
+ LD DE,#.endtp3-.tp3
+ CALL .copy_vram
+
+ ;; Draw the background
+ LD BC,#.bkg_tiles
+ LD HL,#0x9800
+ LD DE,#0x0400 ; One whole GB Screen
+ CALL .copy_vram
+
+ ;; Draw the frame in the window
+ LD BC,#.frame_tiles
+ LD DE,#0x0000/8 ; Place image at (0x00,0x00)
+ LD HL,#0x8050/8 ; Image size is 0x80 x 0x50
+ CALL .set_xy_wtt
+
+ ;; Draw the door in the window
+ LD BC,#.door1_tiles
+ LD DE,#0x1010/8 ; Place image at (0x10,0x10)
+ LD HL,#0x6030/8 ; Image size is 0x60 x 0x30
+ CALL .set_xy_wtt
+ LD A,#.CLOSED
+ LD (.doorstate),A
+
+ ; Initialize background
+ XOR A
+ LD (.bposx),A
+ LDH (.SCX),A
+ LD (.bposx+1),A
+ LD (.bposy),A
+ LDH (.SCY),A
+ LD (.bposy+1),A
+ LD A,#-0x01
+ LD (.bspx),A
+ XOR A
+ LD (.bspx+1),A
+ XOR A
+ LD (.bspy),A
+ LD A,#0x80
+ LD (.bspy+1),A
+
+ ; Initialize window
+ LD A,#.MAXWNDPOSX
+ LD (.wposx),A
+ LDH (.WX),A
+ XOR A
+ LD (.wposx+1),A
+ LD A,#.MAXWNDPOSY
+ LD (.wposy),A
+ LDH (.WY),A
+ XOR A
+ LD (.wposy+1),A
+ LD A,#-0x01
+ LD (.wspx),A
+ LD A,#0x80
+ LD (.wspx+1),A
+ LD A,#-0x01
+ LD (.wspy),A
+ LD A,#0xC0
+ LD (.wspy+1),A
+
+ ; Initialize sprite
+ XOR A
+ LD (.sframe),A
+ LD C,#0x00 ; Sprite 0x00
+ LD D,#0x00 ; Default sprite properties
+ CALL .set_sprite_prop
+ LD C,#0x01 ; Sprite 0x01
+ LD D,#0x00 ; Default sprite properties
+ CALL .set_sprite_prop
+
+ LD A,#0x10
+ LD (.sposx),A
+ XOR A
+ LD (.sposx+1),A
+ LD A,#0x10
+ LD (.sposy),A
+ XOR A
+ LD (.sposy+1),A
+ XOR A
+ LD (.sspx),A
+ LD A,#0x40
+ LD (.sspx+1),A
+ XOR A
+ LD (.sspy),A
+ LD A,#0x40
+ LD (.sspy+1),A
+ CALL .tile_sprite ; Set sprite tiles
+ CALL .place_sprite ; Place sprites
+
+ LD A,#0b11100111 ; LCD = On
+ ; WindowBank = 0x9C00
+ ; Window = On
+ ; BG Chr = 0x8800
+ ; BG Bank = 0x9800
+ ; OBJ = 8x16
+ ; OBJ = On
+ ; BG = On
+ LDH (.LCDC),A
+ EI ; Enable interrupts
+1$:
+ LD A,(.time)
+ INC A
+ LD (.time),A
+
+ LD B,#0x04 ; Skip four VBLs (slow down animation)
+2$:
+ CALL .wait_vbl_done
+ DEC B
+ JR NZ,2$
+
+ CALL .fade
+ CALL .door
+ CALL .scroll
+ CALL .animate_sprite
+
+ CALL .jpad
+ LD D,A
+
+ AND #.B ; Is B pressed ?
+ JP NZ,10$
+
+ LD A,D
+ AND #.A ; Is A pressed ?
+ JP NZ,20$
+
+ LD A,D
+ AND #.SELECT ; Is SELECT pressed ?
+ JR Z,3$
+ LD A,#.STARTFADE
+ LD (.color),A
+3$:
+ LD A,D
+ AND #.START ; Is START pressed ?
+ JR Z,5$
+ LD A,(.doorstate)
+ CP #.CLOSED
+ JR NZ,4$
+ LD A,#.OPENING
+ LD (.doorstate),A
+ XOR A
+ LD (.doorpos),A
+ JR 5$
+4$:
+ CP #.OPENED
+ JR NZ,5$
+ LD A,#.CLOSING
+ LD (.doorstate),A
+ LD A,#.NBDFRAMES
+ LD (.doorpos),A
+5$:
+ LD A,D
+ AND #.UP ; Is UP pressed ?
+ JR Z,6$
+ LD BC,#0x0010
+ LD A,(.sspy) ; Load speed into HL
+ LD H,A
+ LD A,(.sspy+1)
+ LD L,A
+ LD A,L ; Substract BC from HL
+ SUB C
+ LD (.sspy+1),A
+ LD A,H
+ SBC B
+ LD (.sspy),A ; Store new speed
+ JR 7$
+6$:
+ LD A,D
+ AND #.DOWN ; Is DOWN pressed ?
+ JR Z,7$
+ LD BC,#0x0010
+ LD A,(.sspy) ; Load speed into HL
+ LD H,A
+ LD A,(.sspy+1)
+ LD L,A
+ ADD HL,BC ; Add them
+ LD A,H ; Store new speed
+ LD (.sspy),A
+ LD A,L
+ LD (.sspy+1),A
+7$:
+ LD A,D
+ AND #.LEFT ; Is LEFT pressed ?
+ JR Z,8$
+ LD BC,#0x0010
+ LD A,(.sspx) ; Load speed into HL
+ LD H,A
+ LD A,(.sspx+1)
+ LD L,A
+ LD A,L ; Substract BC from HL
+ SUB C
+ LD (.sspx+1),A
+ LD A,H
+ SBC B
+ LD (.sspx),A ; Store new speed
+ JP 1$
+8$:
+ LD A,D
+ AND #.RIGHT ; Is RIGHT pressed ?
+ JP Z,1$
+ LD BC,#0x0010
+ LD A,(.sspx) ; Load speed into HL
+ LD H,A
+ LD A,(.sspx+1)
+ LD L,A
+ ADD HL,BC ; Add them
+ LD A,H ; Store new speed
+ LD (.sspx),A
+ LD A,L
+ LD (.sspx+1),A
+ JP 1$
+
+10$:
+ LD A,D
+ AND #.UP ; Is UP pressed ?
+ JP Z,11$
+ LD BC,#0x0010
+ LD A,(.bspy) ; Load speed into HL
+ LD H,A
+ LD A,(.bspy+1)
+ LD L,A
+ LD A,L ; Substract BC from HL
+ SUB C
+ LD (.bspy+1),A
+ LD A,H
+ SBC B
+ LD (.bspy),A ; Store new speed
+ JR 12$
+11$:
+ LD A,D
+ AND #.DOWN ; Is DOWN pressed ?
+ JP Z,12$
+ LD BC,#0x0010
+ LD A,(.bspy) ; Load speed into HL
+ LD H,A
+ LD A,(.bspy+1)
+ LD L,A
+ ADD HL,BC ; Add them
+ LD A,H ; Store new speed
+ LD (.bspy),A
+ LD A,L
+ LD (.bspy+1),A
+12$:
+ LD A,D
+ AND #.LEFT ; Is LEFT pressed ?
+ JP Z,13$
+ LD BC,#0x0010
+ LD A,(.bspx) ; Load speed into HL
+ LD H,A
+ LD A,(.bspx+1)
+ LD L,A
+ LD A,L ; Substract BC from HL
+ SUB C
+ LD (.bspx+1),A
+ LD A,H
+ SBC B
+ LD (.bspx),A ; Store new speed
+ JP 1$
+13$:
+ LD A,D
+ AND #.RIGHT ; Is RIGHT pressed ?
+ JP Z,1$
+ LD BC,#0x0010
+ LD A,(.bspx) ; Load speed into HL
+ LD H,A
+ LD A,(.bspx+1)
+ LD L,A
+ ADD HL,BC ; Add them
+ LD A,H ; Store new speed
+ LD (.bspx),A
+ LD A,L
+ LD (.bspx+1),A
+ JP 1$
+
+20$:
+ LD A,D
+ AND #.UP ; Is UP pressed ?
+ JP Z,21$
+ LD BC,#0x0010
+ LD A,(.wspy) ; Load speed into HL
+ LD H,A
+ LD A,(.wspy+1)
+ LD L,A
+ LD A,L ; Substract BC from HL
+ SUB C
+ LD (.wspy+1),A
+ LD A,H
+ SBC B
+ LD (.wspy),A ; Store new speed
+ JR 22$
+21$:
+ LD A,D
+ AND #.DOWN ; Is DOWN pressed ?
+ JP Z,22$
+ LD BC,#0x0010
+ LD A,(.wspy) ; Load speed into HL
+ LD H,A
+ LD A,(.wspy+1)
+ LD L,A
+ ADD HL,BC ; Add them
+ LD A,H ; Store new speed
+ LD (.wspy),A
+ LD A,L
+ LD (.wspy+1),A
+22$:
+ LD A,D
+ AND #.LEFT ; Is LEFT pressed ?
+ JP Z,23$
+ LD BC,#0x0010
+ LD A,(.wspx) ; Load speed into HL
+ LD H,A
+ LD A,(.wspx+1)
+ LD L,A
+ LD A,L ; Substract BC from HL
+ SUB C
+ LD (.wspx+1),A
+ LD A,H
+ SBC B
+ LD (.wspx),A ; Store new speed
+ JP 1$
+23$:
+ LD A,D
+ AND #.RIGHT ; Is RIGHT pressed ?
+ JP Z,1$
+ LD BC,#0x0010
+ LD A,(.wspx) ; Load speed into HL
+ LD H,A
+ LD A,(.wspx+1)
+ LD L,A
+ ADD HL,BC ; Add them
+ LD A,H ; Store new speed
+ LD (.wspx),A
+ LD A,L
+ LD (.wspx+1),A
+ JP 1$
+
+ RET
+
+ ;; Fade the screen (off and on)
+.fade:
+
+ LD A,(.color) ; Load color into A
+ CP #0x00
+ RET Z
+ CP #.STARTFADE
+ JR NZ,1$
+ LD A,#0b11111001
+ JR 6$
+1$:
+ CP #.STARTFADE-.FADESTEP
+ JR NZ,2$
+ LD A,#0b11111110
+ JR 6$
+2$:
+ CP #.STARTFADE-0x02*.FADESTEP
+ JR NZ,3$
+ LD A,#0b11111111
+ JR 6$
+3$:
+ CP #.STARTFADE-0x03*.FADESTEP
+ JR NZ,4$
+ LD A,#0b11111110
+ JR 6$
+4$:
+ CP #.STARTFADE-0x04*.FADESTEP
+ JR NZ,5$
+ LD A,#0b11111001
+ JR 6$
+5$:
+ CP #.STARTFADE-0x05*.FADESTEP
+ JR NZ,7$
+ LD A,#0b11100100
+6$:
+ LDH (.BGP),A
+7$:
+ LD A,(.color)
+ DEC A
+ LD (.color),A
+ RET
+
+ ;; Scroll the background, the window and the sprite
+.scroll:
+
+ ;; Update background
+ LD A,(.bposx) ; Load background position into HL
+ LD H,A
+ LD A,(.bposx+1)
+ LD L,A
+ LD A,(.bspx) ; Load background speed into BC
+ LD B,A
+ LD A,(.bspx+1)
+ LD C,A
+ ADD HL,BC ; Add them
+ LD A,L ; Store new background position
+ LD (.bposx+1),A
+ LD A,H
+ LD (.bposx),A
+ LDH (.SCX),A ; Update position
+
+ LD A,(.bposy) ; Load background position into HL
+ LD H,A
+ LD A,(.bposy+1)
+ LD L,A
+ LD A,(.bspy) ; Load background speed into BC
+ LD B,A
+ LD A,(.bspy+1)
+ LD C,A
+ ADD HL,BC ; Add them
+ LD A,L ; Store new background position
+ LD (.bposy+1),A
+ LD A,H
+ LD (.bposy),A
+ LDH (.SCY),A ; Update position
+
+ ;; Update window
+ LD A,(.wspx) ; Load window speed into BC
+ LD B,A
+ LD A,(.wspx+1)
+ LD C,A
+ LD A,(.wposx) ; Load window position into HL
+ LD H,A
+ LD A,(.wposx+1)
+ LD L,A
+ ADD HL,BC ; Add them
+ LD A,L ; Store new window position
+ LD (.wposx+1),A
+ LD A,H
+ LD (.wposx),A
+
+ ;; X position
+ LD A,(.wposx) ; Check window position
+ LD H,#0x00 ; We must use 16 bit registers since the
+ LD L,A ; window is not less than 0x80 pixels
+ LD BC,#.MAXWINX
+ LD A,L ; Substract BC from HL
+ SUB C
+ LD A,H
+ SBC B
+ AND #0x80
+ JR NZ,1$ ; Maximum value ?
+ LD A,#.MAXWINX
+ LD (.wposx),A ; Correct window position
+ LD A,(.wspx+1) ; Load window speed into BC
+ LD C,A
+ LD A,(.wspx)
+ LD B,A
+ AND #0x80 ; Speed is already negative ?
+ JR NZ,3$
+ JR 2$
+1$:
+ LD A,(.wposx) ; Check window position
+ LD H,#0x00 ; We must use 16 bit registers since the
+ LD L,A ; window is not less than 0x80 pixels
+ LD BC,#.MINWINX+1
+ LD A,L ; Substract BC from HL
+ SUB C
+ LD A,H
+ SBC B
+ AND #0x80
+ JR Z,3$ ; Minimum value ?
+ LD A,#.MINWINX
+ LD (.wposx),A ; Correct window position
+ LD A,(.wspx+1) ; Load window speed into BC
+ LD C,A
+ LD A,(.wspx)
+ LD B,A
+ AND #0x80 ; Speed is already positive ?
+ JR Z,3$
+2$:
+ LD HL,#0x00 ; Invert speed
+ LD A,L ; Substract BC from HL
+ SUB C
+ LD (.wspx+1),A
+ LD A,H
+ SBC B
+ LD (.wspx),A ; Store new speed
+3$:
+ LD A,(.wposx)
+ LDH (.WX),A ; Update position
+
+ LD A,(.wspy) ; Load window speed into BC
+ LD B,A
+ LD A,(.wspy+1)
+ LD C,A
+ LD A,(.wposy) ; Load window position into HL
+ LD H,A
+ LD A,(.wposy+1)
+ LD L,A
+ ADD HL,BC ; Add them
+ LD A,L ; Store new window position
+ LD (.wposy+1),A
+ LD A,H
+ LD (.wposy),A
+
+ ;; Y position
+ LD A,(.wposy) ; Check window position
+ LD H,#0x00 ; We must use 16 bit registers since the
+ LD L,A ; window is not less than 0x80 pixels
+ LD BC,#.MAXWINY
+ LD A,L ; Substract BC from HL
+ SUB C
+ LD A,H
+ SBC B
+ AND #0x80
+ JR NZ,4$ ; Maximum value ?
+ LD A,#.MAXWINY
+ LD (.wposy),A ; Correct window position
+ LD A,(.wspy+1) ; Load window speed into BC
+ LD C,A
+ LD A,(.wspy)
+ LD B,A
+ AND #0x80 ; Speed is already negative ?
+ JR NZ,6$
+ JR 5$
+4$:
+ LD A,(.wposy) ; Check window position
+ LD H,#0x00 ; We must use 16 bit registers since the
+ LD L,A ; window is not less than 0x80 pixels
+ LD BC,#.MINWINY+1
+ LD A,L ; Substract BC from HL
+ SUB C
+ LD A,H
+ SBC B
+ AND #0x80
+ JR Z,6$ ; Minimum value ?
+ LD A,#.MINWINY
+ LD (.wposy),A ; Correct window position
+ LD A,(.wspy+1) ; Load window speed into BC
+ LD C,A
+ LD A,(.wspy)
+ LD B,A
+ AND #0x80 ; Speed is already positive ?
+ JR Z,6$
+5$:
+ LD HL,#0x00 ; Invert speed
+ LD A,L ; Substract BC from HL
+ SUB C
+ LD (.wspy+1),A
+ LD A,H
+ SBC B
+ LD (.wspy),A ; Store new speed
+6$:
+ LD A,(.wposy)
+ LDH (.WY),A ; Update position
+
+ ;; Update sprite
+ LD A,(.sposx) ; Load sprite position into HL
+ LD H,A
+ LD A,(.sposx+1)
+ LD L,A
+ LD A,(.sspx) ; Load sprite speed into BC
+ LD B,A
+ LD A,(.sspx+1)
+ LD C,A
+ ADD HL,BC ; Add them
+ LD A,L ; Store new sprite position
+ LD (.sposx+1),A
+ LD A,H
+ LD (.sposx),A
+
+ LD A,(.sposy) ; Load sprite position into HL
+ LD H,A
+ LD A,(.sposy+1)
+ LD L,A
+ LD A,(.sspy) ; Load sprite speed into BC
+ LD B,A
+ LD A,(.sspy+1)
+ LD C,A
+ ADD HL,BC ; Add them
+ LD A,L ; Store new sprite position
+ LD (.sposy+1),A
+ LD A,H
+ LD (.sposy),A
+ CALL .place_sprite ; Update position
+
+ RET
+
+ ;; Open and close the door
+.door:
+ LD A,(.doorstate)
+ CP #.OPENING
+ JP Z,.open_door
+ CP #.CLOSING
+ JP Z,.close_door
+ RET
+
+.open_door:
+ LD A,(.doorpos)
+ LD HL,#.film+0x02
+ LD B,#0x00
+ LD C,A
+ ADD HL,BC
+ LD C,(HL)
+ INC HL
+ LD B,(HL)
+ LD DE,#0x1010/8 ; Place image at (0x10,0x10)
+ LD HL,#0x6030/8 ; Image size is 0x60 x 0x30
+ CALL .set_xy_wtt
+
+ LD A,(.doorpos)
+ ADD A,#0x02
+ LD (.doorpos),A
+ CP #.NBDFRAMES
+ RET NZ
+ LD A,#.OPENED
+ LD (.doorstate),A
+ RET
+
+.close_door:
+ LD A,(.doorpos)
+ LD HL,#.film-0x02
+ LD B,#0x00
+ LD C,A
+ ADD HL,BC
+ LD C,(HL)
+ INC HL
+ LD B,(HL)
+ LD DE,#0x1010/8 ; Place image at (0x10,0x10)
+ LD HL,#0x6030/8 ; Image size is 0x60 x 0x30
+ CALL .set_xy_wtt
+
+ LD A,(.doorpos)
+ SUB A,#0x02
+ LD (.doorpos),A
+ RET NZ
+ LD A,#.CLOSED
+ LD (.doorstate),A
+ RET
+
+ ;; Animate sprite
+.animate_sprite:
+ LD A,(.time)
+ AND #0x07
+ RET NZ
+
+ LD A,(.sframe)
+ INC A
+ CP #.NBSFRAMES
+ JR NZ,1$
+ XOR A
+1$:
+ LD (.sframe),A
+
+ CALL .tile_sprite
+ RET
+
+ ;; Set sprite tiles
+.tile_sprite:
+ LD A,(.sframe)
+ LD HL,#.earth_tiles
+ RLCA
+ LD B,#0x00
+ LD C,A
+ ADD HL,BC
+ LD C,#0x00 ; Sprite 0x00
+ LD A,(HL+)
+ LD D,A
+ PUSH HL
+ CALL .set_sprite_tile
+ POP HL
+
+ LD C,#0x01 ; Sprite 0x01
+ LD A,(HL+)
+ LD D,A
+ CALL .set_sprite_tile
+
+ RET
+
+ ;; Place sprite
+.place_sprite:
+ LD C,#0x00 ; Sprite 0x00
+ LD A,(.sposx)
+ LD D,A
+ LD A,(.sposy)
+ LD E,A
+ PUSH DE ; Store position
+ CALL .mv_sprite
+
+ LD C,#0x01 ; Sprite 0x01
+ POP DE ; Restore position
+ LD A,#0x08
+ ADD A,D
+ LD D,A
+ CALL .mv_sprite
+
+ RET
+
+ .area _LIT
+
+.tp0:
+
+.std_data:
+
+ ; Basic tiles (0xFC to 0xFF)
+
+ .byte 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF
+ .byte 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00
+ .byte 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF
+ .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+
+.endtp0:
+
+.tp1:
+
+.earth_data:
+
+ ; Tile 0x00
+ .byte 0x07,0x07,0x18,0x1F,0x32,0x2D,0x71,0x4E,0x70,0x4F,0xF8,0x87,0xF8,0x87,0xF8,0x87
+ .byte 0xFC,0x83,0xFE,0x81,0x7F,0x40,0x7F,0x40,0x3F,0x20,0x1F,0x18,0x07,0x07,0x00,0x00
+ .byte 0xC0,0xC0,0xF0,0x30,0x78,0x88,0x3C,0xC4,0x5C,0xA4,0x9E,0x62,0x3E,0xC2,0x3E,0xC2
+ .byte 0x5E,0xA2,0x7E,0x82,0x0C,0xF4,0x0C,0xF4,0x98,0x68,0xB0,0x70,0xC0,0xC0,0x00,0x00
+ .byte 0x07,0x07,0x1F,0x18,0x2F,0x30,0x4F,0x70,0x6F,0x50,0x9F,0xE0,0x9F,0xE0,0xBF,0xC0
+ .byte 0xFF,0x80,0xB7,0xC8,0x63,0x5C,0x43,0x7C,0x3F,0x20,0x1F,0x18,0x07,0x07,0x00,0x00
+ .byte 0xC0,0xC0,0xB0,0x70,0x18,0xE8,0x0C,0xF4,0x0C,0xF4,0x82,0x7E,0x82,0x7E,0x86,0x7A
+ .byte 0xC6,0x3A,0xE6,0x1A,0xF4,0x0C,0xFC,0x04,0xF8,0x08,0xF0,0x30,0xC0,0xC0,0x00,0x00
+
+ ; Tile 0x08
+ .byte 0x07,0x07,0x1E,0x19,0x20,0x3F,0x40,0x7F,0x42,0x7D,0x81,0xFE,0x81,0xFE,0x83,0xFC
+ .byte 0xD7,0xA8,0xBB,0xC4,0x6E,0x51,0x7C,0x43,0x3F,0x20,0x1F,0x18,0x07,0x07,0x00,0x00
+ .byte 0xC0,0xC0,0x70,0xB0,0xE8,0x18,0xF4,0x0C,0xF4,0x0C,0xFE,0x02,0xFE,0x02,0xFE,0x02
+ .byte 0xFE,0x02,0x7E,0x82,0x3C,0xC4,0x3C,0xC4,0xF8,0x08,0xF0,0x30,0xC0,0xC0,0x00,0x00
+ .byte 0x07,0x07,0x1B,0x1C,0x20,0x3F,0x40,0x7F,0x40,0x7F,0xE0,0x9F,0x90,0xEF,0x89,0xF6
+ .byte 0x8D,0xF2,0x9F,0xE0,0x5E,0x61,0x6F,0x50,0x3F,0x20,0x1F,0x18,0x07,0x07,0x00,0x00
+ .byte 0xC0,0xC0,0xB0,0x70,0x28,0xD8,0x04,0xFC,0x2C,0xD4,0x1E,0xE2,0x1E,0xE2,0x3E,0xC2
+ .byte 0x7E,0x82,0xB6,0x4A,0xE4,0x1C,0xC4,0x3C,0xF8,0x08,0xF0,0x30,0xC0,0xC0,0x00,0x00
+
+ ; Tile 0x10
+ .byte 0x07,0x07,0x18,0x1F,0x20,0x3F,0x40,0x7F,0x40,0x7F,0xEE,0x91,0xF1,0x8E,0xE0,0x9F
+ .byte 0xE0,0x9F,0xF1,0x8E,0x71,0x4E,0x72,0x4D,0x3F,0x20,0x1F,0x18,0x07,0x07,0x00,0x00
+ .byte 0xC0,0xC0,0xF0,0x30,0x08,0xF8,0x04,0xFC,0x04,0xFC,0x02,0xFE,0x02,0xFE,0x92,0x6E
+ .byte 0xD6,0x2A,0xFE,0x02,0xEC,0x14,0xFC,0x04,0xF8,0x08,0xF0,0x30,0xC0,0xC0,0x00,0x00
+ .byte 0x07,0x07,0x1D,0x1A,0x36,0x29,0x5C,0x63,0x6C,0x53,0xCE,0xB1,0x9F,0xE0,0x9E,0xE1
+ .byte 0xAE,0xD1,0xBF,0xC0,0x47,0x78,0x47,0x78,0x2F,0x30,0x1F,0x18,0x07,0x07,0x00,0x00
+ .byte 0xC0,0xC0,0x70,0xB0,0x08,0xF8,0x04,0xFC,0x04,0xFC,0xE2,0x1E,0x32,0xCE,0x0E,0xF2
+ .byte 0x0E,0xF2,0x1E,0xE2,0x1C,0xE4,0x2C,0xD4,0xF8,0x08,0xF0,0x30,0xC0,0xC0,0x00,0x00
+
+ ; Tile 0x18
+ .byte 0x07,0x07,0x1E,0x19,0x33,0x2C,0x49,0x76,0x42,0x7D,0xC4,0xBB,0xC1,0xBE,0xC1,0xBE
+ .byte 0xE2,0x9D,0xF3,0x8C,0x78,0x47,0x78,0x47,0x3C,0x23,0x1C,0x1B,0x07,0x07,0x00,0x00
+ .byte 0xC0,0xC0,0x70,0xB0,0x68,0x98,0xC4,0x3C,0xC4,0x3C,0xEE,0x12,0xF2,0x0E,0xE2,0x1E
+ .byte 0xE2,0x1E,0xF2,0x0E,0x7C,0x84,0x7C,0x84,0xF8,0x08,0xF0,0x30,0xC0,0xC0,0x00,0x00
+
+.endtp1:
+
+.tp2:
+
+.frame_data:
+
+ ; Tile 0x00
+ .byte 0xFF,0x00,0x80,0x7F,0x80,0x7F,0x80,0x7F,0x80,0x7F,0x80,0x7F,0x80,0x7F,0x80,0x7F
+ .byte 0xFF,0x00,0x01,0xFE,0x03,0xFC,0x07,0xF8,0x0F,0xF0,0x1F,0xE0,0x3F,0xC0,0x7F,0x80
+ .byte 0xFF,0x00,0xFE,0x01,0xFC,0x03,0xF8,0x07,0xF0,0x0F,0xE0,0x1F,0xC0,0x3F,0x80,0x7F
+ .byte 0xFF,0x00,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF
+ .byte 0xFF,0x00,0xFF,0x01,0xFD,0x03,0xF9,0x07,0xF1,0x0F,0xE1,0x1F,0xC1,0x3F,0x81,0x7F
+ .byte 0x80,0x7F,0x81,0x7E,0x83,0x7C,0x87,0x78,0x8F,0x70,0x9F,0x60,0xBF,0x40,0xFF,0x00
+ .byte 0xFF,0x70,0xFF,0x98,0xEF,0xB8,0xCF,0xF8,0xFF,0x70,0xFF,0x00,0xFF,0x00,0xFF,0x01
+ .byte 0xFF,0x00,0xFE,0x01,0xFC,0x03,0xF8,0x07,0xF0,0x0F,0xE0,0x1F,0xC0,0x3F,0xFF,0xFF
+
+ ; Tile 0x08
+ .byte 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0xFF
+ .byte 0x00,0xFF,0x01,0xFE,0x03,0xFC,0x07,0xF8,0x0F,0xF0,0x1F,0xE0,0x3F,0xC0,0xFF,0xFF
+ .byte 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF
+ .byte 0xFF,0x0E,0xFF,0x13,0xFD,0x17,0xF9,0x1F,0xFE,0x0F,0xE0,0x1F,0xC0,0x3F,0x80,0xFF
+ .byte 0x01,0xFF,0x01,0xFF,0x01,0xFF,0x01,0xFF,0x01,0xFF,0x01,0xFF,0x01,0xFF,0x01,0xFF
+ .byte 0xFF,0x01,0xFF,0x01,0xFD,0x03,0xF9,0x07,0xF1,0x0F,0xE1,0x1F,0xC1,0x3F,0x81,0x7F
+ .byte 0x80,0x7F,0x80,0x7F,0x80,0x7F,0x80,0x7F,0x80,0x7F,0x80,0x7F,0x80,0x7F,0x80,0x7F
+ .byte 0x01,0xFF,0x01,0xFF,0x03,0xFD,0x07,0xF9,0x0F,0xF1,0x1F,0xE1,0x3F,0xC1,0x7F,0x81
+
+ ; Tile 0x10
+ .byte 0xFF,0x01,0xFF,0x01,0xFF,0x01,0xFF,0x01,0xFF,0x01,0xFF,0x01,0xFF,0x01,0xFF,0x01
+ .byte 0x01,0xFF,0x01,0xFE,0x03,0xFC,0x77,0xF8,0xFF,0x98,0xEF,0xB8,0xCF,0xF8,0x7F,0xF0
+ .byte 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x0E,0xFF,0x13,0xFD,0x17,0xF9,0x1F,0xFF,0x0E
+ .byte 0x80,0x7F,0x81,0x7E,0x83,0x7C,0x87,0x78,0x8F,0x70,0x9F,0x60,0xBF,0x40,0xFF,0x7F
+ .byte 0x01,0xFF,0x01,0xFF,0x01,0xFF,0x01,0xFF,0x01,0xFF,0x01,0xFF,0x01,0xFF,0xFF,0xFF
+
+.door1_data:
+
+ ; Tile 0x15
+ .byte 0xFF,0x00,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0xFF
+ .byte 0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0xFF,0x00,0xFF,0x00,0xFF
+ .byte 0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0xFF
+
+.door2_data:
+
+ ; Tile 0x18
+ .byte 0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0xFF,0x00,0xFF,0x00,0xFF
+ .byte 0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0xFF
+ .byte 0xFF,0x00,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0xFF
+ .byte 0xFF,0x00,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF
+
+.door3_data:
+
+ ; Tile 0x1C
+ .byte 0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0xFF
+ .byte 0xFF,0x00,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0xFF
+ .byte 0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0xFF,0x00,0xFF,0x00,0xFF
+ .byte 0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF
+
+.door4_data:
+
+ ; Tile 0x20
+ .byte 0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0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0xFC,0xFC,0x04,0xFC
+ .byte 0x00,0x01,0x02,0x03,0xFC,0xFC,0x04,0xFC
+ .byte 0x00,0x01,0x02,0x03,0xFC,0xFC,0x04,0xFC
+ .byte 0x00,0x01,0x02,0x03,0xFC,0xFC,0x04,0xFC
+
+ .byte 0xFC,0x05,0x06,0xFC,0x07,0x08,0x09,0x0A
+ .byte 0xFC,0x05,0x06,0xFC,0x07,0x08,0x09,0x0A
+ .byte 0xFC,0x05,0x06,0xFC,0x07,0x08,0x09,0x0A
+ .byte 0xFC,0x05,0x06,0xFC,0x07,0x08,0x09,0x0A
+
+ .byte 0xFC,0xFC,0xFC,0x02,0x0B,0x0C,0x0D,0xFC
+ .byte 0xFC,0xFC,0xFC,0x02,0x0B,0x0C,0x0D,0xFC
+ .byte 0xFC,0xFC,0xFC,0x02,0x0B,0x0C,0x0D,0xFC
+ .byte 0xFC,0xFC,0xFC,0x02,0x0B,0x0C,0x0D,0xFC
+
+ .byte 0x0E,0x0F,0x10,0xFC,0x11,0x12,0x13,0x14
+ .byte 0x0E,0x0F,0x10,0xFC,0x11,0x12,0x13,0x14
+ .byte 0x0E,0x0F,0x10,0xFC,0x11,0x12,0x13,0x14
+ .byte 0x0E,0x0F,0x10,0xFC,0x11,0x12,0x13,0x14
+
+ .byte 0x15,0x16,0x17,0xFC,0x18,0x19,0x1A,0xFC
+ .byte 0x15,0x16,0x17,0xFC,0x18,0x19,0x1A,0xFC
+ .byte 0x15,0x16,0x17,0xFC,0x18,0x19,0x1A,0xFC
+ .byte 0x15,0x16,0x17,0xFC,0x18,0x19,0x1A,0xFC
+
+ .byte 0x1B,0x1C,0x1D,0xFC,0xFC,0x1E,0x1F,0x20
+ .byte 0x1B,0x1C,0x1D,0xFC,0xFC,0x1E,0x1F,0x20
+ .byte 0x1B,0x1C,0x1D,0xFC,0xFC,0x1E,0x1F,0x20
+ .byte 0x1B,0x1C,0x1D,0xFC,0xFC,0x1E,0x1F,0x20
+
+ .byte 0x21,0x22,0xFC,0x23,0x24,0x25,0xFC,0x26
+ .byte 0x21,0x22,0xFC,0x23,0x24,0x25,0xFC,0x26
+ .byte 0x21,0x22,0xFC,0x23,0x24,0x25,0xFC,0x26
+ .byte 0x21,0x22,0xFC,0x23,0x24,0x25,0xFC,0x26
+
+ .byte 0x27,0x13,0x28,0x29,0x2A,0x2B,0x2C,0x11
+ .byte 0x27,0x13,0x28,0x29,0x2A,0x2B,0x2C,0x11
+ .byte 0x27,0x13,0x28,0x29,0x2A,0x2B,0x2C,0x11
+ .byte 0x27,0x13,0x28,0x29,0x2A,0x2B,0x2C,0x11
+
+ .byte 0x00,0x01,0x02,0x03,0xFC,0xFC,0x04,0xFC
+ .byte 0x00,0x01,0x02,0x03,0xFC,0xFC,0x04,0xFC
+ .byte 0x00,0x01,0x02,0x03,0xFC,0xFC,0x04,0xFC
+ .byte 0x00,0x01,0x02,0x03,0xFC,0xFC,0x04,0xFC
+
+ .byte 0xFC,0x05,0x06,0xFC,0x07,0x08,0x09,0x0A
+ .byte 0xFC,0x05,0x06,0xFC,0x07,0x08,0x09,0x0A
+ .byte 0xFC,0x05,0x06,0xFC,0x07,0x08,0x09,0x0A
+ .byte 0xFC,0x05,0x06,0xFC,0x07,0x08,0x09,0x0A
+
+ .byte 0xFC,0xFC,0xFC,0x02,0x0B,0x0C,0x0D,0xFC
+ .byte 0xFC,0xFC,0xFC,0x02,0x0B,0x0C,0x0D,0xFC
+ .byte 0xFC,0xFC,0xFC,0x02,0x0B,0x0C,0x0D,0xFC
+ .byte 0xFC,0xFC,0xFC,0x02,0x0B,0x0C,0x0D,0xFC
+
+ .byte 0x0E,0x0F,0x10,0xFC,0x11,0x12,0x13,0x14
+ .byte 0x0E,0x0F,0x10,0xFC,0x11,0x12,0x13,0x14
+ .byte 0x0E,0x0F,0x10,0xFC,0x11,0x12,0x13,0x14
+ .byte 0x0E,0x0F,0x10,0xFC,0x11,0x12,0x13,0x14
+
+ .byte 0x15,0x16,0x17,0xFC,0x18,0x19,0x1A,0xFC
+ .byte 0x15,0x16,0x17,0xFC,0x18,0x19,0x1A,0xFC
+ .byte 0x15,0x16,0x17,0xFC,0x18,0x19,0x1A,0xFC
+ .byte 0x15,0x16,0x17,0xFC,0x18,0x19,0x1A,0xFC
+
+ .byte 0x1B,0x1C,0x1D,0xFC,0xFC,0x1E,0x1F,0x20
+ .byte 0x1B,0x1C,0x1D,0xFC,0xFC,0x1E,0x1F,0x20
+ .byte 0x1B,0x1C,0x1D,0xFC,0xFC,0x1E,0x1F,0x20
+ .byte 0x1B,0x1C,0x1D,0xFC,0xFC,0x1E,0x1F,0x20
+
+ .byte 0x21,0x22,0xFC,0x23,0x24,0x25,0xFC,0x26
+ .byte 0x21,0x22,0xFC,0x23,0x24,0x25,0xFC,0x26
+ .byte 0x21,0x22,0xFC,0x23,0x24,0x25,0xFC,0x26
+ .byte 0x21,0x22,0xFC,0x23,0x24,0x25,0xFC,0x26
+
+ .byte 0x27,0x13,0x28,0x29,0x2A,0x2B,0x2C,0x11
+ .byte 0x27,0x13,0x28,0x29,0x2A,0x2B,0x2C,0x11
+ .byte 0x27,0x13,0x28,0x29,0x2A,0x2B,0x2C,0x11
+ .byte 0x27,0x13,0x28,0x29,0x2A,0x2B,0x2C,0x11
+
+ .byte 0x00,0x01,0x02,0x03,0xFC,0xFC,0x04,0xFC
+ .byte 0x00,0x01,0x02,0x03,0xFC,0xFC,0x04,0xFC
+ .byte 0x00,0x01,0x02,0x03,0xFC,0xFC,0x04,0xFC
+ .byte 0x00,0x01,0x02,0x03,0xFC,0xFC,0x04,0xFC
+
+ .byte 0xFC,0x05,0x06,0xFC,0x07,0x08,0x09,0x0A
+ .byte 0xFC,0x05,0x06,0xFC,0x07,0x08,0x09,0x0A
+ .byte 0xFC,0x05,0x06,0xFC,0x07,0x08,0x09,0x0A
+ .byte 0xFC,0x05,0x06,0xFC,0x07,0x08,0x09,0x0A
+
+ .byte 0xFC,0xFC,0xFC,0x02,0x0B,0x0C,0x0D,0xFC
+ .byte 0xFC,0xFC,0xFC,0x02,0x0B,0x0C,0x0D,0xFC
+ .byte 0xFC,0xFC,0xFC,0x02,0x0B,0x0C,0x0D,0xFC
+ .byte 0xFC,0xFC,0xFC,0x02,0x0B,0x0C,0x0D,0xFC
+
+ .byte 0x0E,0x0F,0x10,0xFC,0x11,0x12,0x13,0x14
+ .byte 0x0E,0x0F,0x10,0xFC,0x11,0x12,0x13,0x14
+ .byte 0x0E,0x0F,0x10,0xFC,0x11,0x12,0x13,0x14
+ .byte 0x0E,0x0F,0x10,0xFC,0x11,0x12,0x13,0x14
+
+ .byte 0x15,0x16,0x17,0xFC,0x18,0x19,0x1A,0xFC
+ .byte 0x15,0x16,0x17,0xFC,0x18,0x19,0x1A,0xFC
+ .byte 0x15,0x16,0x17,0xFC,0x18,0x19,0x1A,0xFC
+ .byte 0x15,0x16,0x17,0xFC,0x18,0x19,0x1A,0xFC
+
+ .byte 0x1B,0x1C,0x1D,0xFC,0xFC,0x1E,0x1F,0x20
+ .byte 0x1B,0x1C,0x1D,0xFC,0xFC,0x1E,0x1F,0x20
+ .byte 0x1B,0x1C,0x1D,0xFC,0xFC,0x1E,0x1F,0x20
+ .byte 0x1B,0x1C,0x1D,0xFC,0xFC,0x1E,0x1F,0x20
+
+ .byte 0x21,0x22,0xFC,0x23,0x24,0x25,0xFC,0x26
+ .byte 0x21,0x22,0xFC,0x23,0x24,0x25,0xFC,0x26
+ .byte 0x21,0x22,0xFC,0x23,0x24,0x25,0xFC,0x26
+ .byte 0x21,0x22,0xFC,0x23,0x24,0x25,0xFC,0x26
+
+ .byte 0x27,0x13,0x28,0x29,0x2A,0x2B,0x2C,0x11
+ .byte 0x27,0x13,0x28,0x29,0x2A,0x2B,0x2C,0x11
+ .byte 0x27,0x13,0x28,0x29,0x2A,0x2B,0x2C,0x11
+ .byte 0x27,0x13,0x28,0x29,0x2A,0x2B,0x2C,0x11
+
+ .byte 0x00,0x01,0x02,0x03,0xFC,0xFC,0x04,0xFC
+ .byte 0x00,0x01,0x02,0x03,0xFC,0xFC,0x04,0xFC
+ .byte 0x00,0x01,0x02,0x03,0xFC,0xFC,0x04,0xFC
+ .byte 0x00,0x01,0x02,0x03,0xFC,0xFC,0x04,0xFC
+
+ .byte 0xFC,0x05,0x06,0xFC,0x07,0x08,0x09,0x0A
+ .byte 0xFC,0x05,0x06,0xFC,0x07,0x08,0x09,0x0A
+ .byte 0xFC,0x05,0x06,0xFC,0x07,0x08,0x09,0x0A
+ .byte 0xFC,0x05,0x06,0xFC,0x07,0x08,0x09,0x0A
+
+ .byte 0xFC,0xFC,0xFC,0x02,0x0B,0x0C,0x0D,0xFC
+ .byte 0xFC,0xFC,0xFC,0x02,0x0B,0x0C,0x0D,0xFC
+ .byte 0xFC,0xFC,0xFC,0x02,0x0B,0x0C,0x0D,0xFC
+ .byte 0xFC,0xFC,0xFC,0x02,0x0B,0x0C,0x0D,0xFC
+
+ .byte 0x0E,0x0F,0x10,0xFC,0x11,0x12,0x13,0x14
+ .byte 0x0E,0x0F,0x10,0xFC,0x11,0x12,0x13,0x14
+ .byte 0x0E,0x0F,0x10,0xFC,0x11,0x12,0x13,0x14
+ .byte 0x0E,0x0F,0x10,0xFC,0x11,0x12,0x13,0x14
+
+ .byte 0x15,0x16,0x17,0xFC,0x18,0x19,0x1A,0xFC
+ .byte 0x15,0x16,0x17,0xFC,0x18,0x19,0x1A,0xFC
+ .byte 0x15,0x16,0x17,0xFC,0x18,0x19,0x1A,0xFC
+ .byte 0x15,0x16,0x17,0xFC,0x18,0x19,0x1A,0xFC
+
+ .byte 0x1B,0x1C,0x1D,0xFC,0xFC,0x1E,0x1F,0x20
+ .byte 0x1B,0x1C,0x1D,0xFC,0xFC,0x1E,0x1F,0x20
+ .byte 0x1B,0x1C,0x1D,0xFC,0xFC,0x1E,0x1F,0x20
+ .byte 0x1B,0x1C,0x1D,0xFC,0xFC,0x1E,0x1F,0x20
+
+ .byte 0x21,0x22,0xFC,0x23,0x24,0x25,0xFC,0x26
+ .byte 0x21,0x22,0xFC,0x23,0x24,0x25,0xFC,0x26
+ .byte 0x21,0x22,0xFC,0x23,0x24,0x25,0xFC,0x26
+ .byte 0x21,0x22,0xFC,0x23,0x24,0x25,0xFC,0x26
+
+ .byte 0x27,0x13,0x28,0x29,0x2A,0x2B,0x2C,0x11
+ .byte 0x27,0x13,0x28,0x29,0x2A,0x2B,0x2C,0x11
+ .byte 0x27,0x13,0x28,0x29,0x2A,0x2B,0x2C,0x11
+ .byte 0x27,0x13,0x28,0x29,0x2A,0x2B,0x2C,0x11
+
+ ; Image size: 0x10 x 0x70
+ ; Number of tiles (total - unique): 0x1C - 0x1C
+
+.earth_tiles:
+
+ .byte 0x00,0x02
+ .byte 0x04,0x06
+ .byte 0x08,0x0A
+ .byte 0x0C,0x0E
+ .byte 0x10,0x12
+ .byte 0x14,0x16
+ .byte 0x18,0x1A
+
+ ; Image size: 0x80 x 0x50
+ ; Number of tiles (total - unique): 0xA0 - 0x15
+
+.frame_tiles:
+
+ .byte 0x80,0x81,0xFD,0x82,0x83,0x81,0xFD,0x82,0x83,0x81,0xFD,0x82,0x83,0x81,0xFD,0x84
+ .byte 0x85,0x86,0x87,0x88,0x89,0x8A,0x87,0x88,0x89,0x8A,0x87,0x88,0x89,0x8A,0x8B,0x8C
+ .byte 0xFD,0x8D,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x8E,0x8F
+ .byte 0x82,0x8C,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x85,0x90
+ .byte 0x8E,0x8F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFD,0x8D
+ .byte 0x85,0x90,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x82,0x8C
+ .byte 0xFD,0x8D,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x8E,0x8F
+ .byte 0x82,0x8C,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x85,0x90
+ .byte 0x8E,0x91,0xFD,0x82,0x83,0x81,0xFD,0x82,0x83,0x81,0xFD,0x82,0x83,0x81,0x92,0x8D
+ .byte 0x93,0x8A,0x87,0x88,0x89,0x8A,0x87,0x88,0x89,0x8A,0x87,0x88,0x89,0x8A,0x87,0x94
+
+ ; Image size: 0x60 x 0x30
+ ; Number of tiles (total - unique): 0x48 - 0x03
+
+.door1_tiles:
+
+ .byte 0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95
+ .byte 0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96
+ .byte 0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97
+ .byte 0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95
+ .byte 0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96
+ .byte 0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97
+
+ .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC
+ .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC
+ .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC
+ .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC
+ .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC
+ .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC
+
+ ; Image size: 0x60 x 0x30
+ ; Number of tiles (total - unique): 0x48 - 0x04
+
+.door2_tiles:
+
+ .byte 0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98
+ .byte 0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99
+ .byte 0x9A,0x9A,0x9A,0x9A,0x9A,0x9A,0x9A,0x9A,0x9A,0x9A,0x9A,0x9A
+ .byte 0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98
+ .byte 0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99
+ .byte 0x9B,0x9B,0x9B,0x9B,0x9B,0x9B,0x9B,0x9B,0x9B,0x9B,0x9B,0x9B
+
+ .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC
+ .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC
+ .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC
+ .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC
+ .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC
+
+ ; Image size: 0x60 x 0x30
+ ; Number of tiles (total - unique): 0x48 - 0x04
+
+.door3_tiles:
+
+ .byte 0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C
+ .byte 0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D
+ .byte 0x9E,0x9E,0x9E,0x9E,0x9E,0x9E,0x9E,0x9E,0x9E,0x9E,0x9E,0x9E
+ .byte 0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C
+ .byte 0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D
+ .byte 0x9F,0x9F,0x9F,0x9F,0x9F,0x9F,0x9F,0x9F,0x9F,0x9F,0x9F,0x9F
+
+ .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC
+ .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC
+ .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC
+ .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC
+ .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC
+
+ ; Image size: 0x60 x 0x30
+ ; Number of tiles (total - unique): 0x48 - 0x01
+
+.door4_tiles:
+
+ .byte 0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95
+ .byte 0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96
+ .byte 0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97
+ .byte 0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95
+ .byte 0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96
+ .byte 0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0
+
+ .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC
+ .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC
+ .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC
+ .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC
+ .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC
+
+.film:
+ .word .door1_tiles+0x0C*0
+ .word .door2_tiles+0x0C*0
+ .word .door3_tiles+0x0C*0
+ .word .door4_tiles+0x0C*0
+ .word .door1_tiles+0x0C*1
+ .word .door2_tiles+0x0C*1
+ .word .door3_tiles+0x0C*1
+ .word .door4_tiles+0x0C*1
+ .word .door1_tiles+0x0C*2
+ .word .door2_tiles+0x0C*2
+ .word .door3_tiles+0x0C*2
+ .word .door4_tiles+0x0C*2
+ .word .door1_tiles+0x0C*3
+ .word .door2_tiles+0x0C*3
+ .word .door3_tiles+0x0C*3
+ .word .door4_tiles+0x0C*3
+ .word .door1_tiles+0x0C*4
+ .word .door2_tiles+0x0C*4
+ .word .door3_tiles+0x0C*4
+ .word .door4_tiles+0x0C*4
+ .word .door1_tiles+0x0C*5
+ .word .door2_tiles+0x0C*5
+ .word .door3_tiles+0x0C*5
+ .word .door4_tiles+0x0C*5
+.endfilm:
+ .word .door1_tiles+0x0C*6
diff --git a/gbdk/gbdk-lib/examples/ap/template_minimal/Makefile b/gbdk/gbdk-lib/examples/ap/template_minimal/Makefile
new file mode 100644
index 00000000..58926ec3
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/template_minimal/Makefile
@@ -0,0 +1,33 @@
+#
+# Simple Makefile that compiles all .c and .s files in the same folder
+#
+
+# If you move this project you can change the directory
+# to match your GBDK root directory (ex: GBDK_HOME = "C:/GBDK/"
+GBDK_HOME = ../../../
+
+LCC = $(GBDK_HOME)bin/lcc -msm83:ap
+
+# You can uncomment the line below to turn on debug output
+# LCC = $(LCC) -debug
+
+# You can set the name of the .pocket ROM file here
+PROJECTNAME = Example
+
+BINS = $(PROJECTNAME).pocket
+CSOURCES := $(wildcard *.c)
+ASMSOURCES := $(wildcard *.s)
+
+all: $(BINS)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+# Compile and link all source files in a single call to LCC
+$(BINS): $(CSOURCES) $(ASMSOURCES)
+ $(LCC) -o $@ $(CSOURCES) $(ASMSOURCES)
+
+clean:
+ rm -f *.o *.lst *.map *.pocket *.ihx *.sym *.cdb *.adb *.asm
+
diff --git a/gbdk/gbdk-lib/examples/ap/template_minimal/Readme.md b/gbdk/gbdk-lib/examples/ap/template_minimal/Readme.md
new file mode 100644
index 00000000..c7ffc4c5
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/template_minimal/Readme.md
@@ -0,0 +1,7 @@
+
+An minimal template project with a Makefile that only compiles files in the same directory
+
+The Makefile will automatically detect and compile new source files as long
+as they are placed in the same directory as the Makefile
+
+
diff --git a/gbdk/gbdk-lib/examples/ap/template_minimal/main.c b/gbdk/gbdk-lib/examples/ap/template_minimal/main.c
new file mode 100644
index 00000000..a01e9dd0
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/template_minimal/main.c
@@ -0,0 +1,17 @@
+#include <gb/gb.h>
+#include <stdint.h>
+
+
+void main(void)
+{
+ // Loop forever
+ while(1) {
+
+
+ // Game main loop processing goes here
+
+
+ // Done processing, yield CPU and wait for start of next frame
+ wait_vbl_done();
+ }
+}
diff --git a/gbdk/gbdk-lib/examples/ap/template_subfolders/Makefile b/gbdk/gbdk-lib/examples/ap/template_subfolders/Makefile
new file mode 100644
index 00000000..f77538bd
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/template_subfolders/Makefile
@@ -0,0 +1,61 @@
+#
+# A Makefile that compiles all .c and .s files in "src" and "res"
+# subdirectories and places the output in a "obj" subdirectory
+#
+
+# If you move this project you can change the directory
+# to match your GBDK root directory (ex: GBDK_HOME = "C:/GBDK/"
+GBDK_HOME = ../../../
+
+LCC = $(GBDK_HOME)bin/lcc
+
+LCCFLAGS = -msm83:ap
+# You can set flags for LCC here
+# For example, you can uncomment the line below to turn on debug output
+# LCCFLAGS += -debug
+
+# You can set the name of the .pocket ROM file here
+PROJECTNAME = Example
+
+SRCDIR = src
+OBJDIR = obj
+RESDIR = res
+BINS = $(OBJDIR)/$(PROJECTNAME).pocket
+CSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.c))) $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.c)))
+ASMSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.s)))
+OBJS = $(CSOURCES:%.c=$(OBJDIR)/%.o) $(ASMSOURCES:%.s=$(OBJDIR)/%.o)
+
+all: prepare $(BINS)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+# Compile .c files in "src/" to .o object files
+$(OBJDIR)/%.o: $(SRCDIR)/%.c
+ $(LCC) $(LCCFLAGS) -c -o $@ $<
+
+# Compile .c files in "res/" to .o object files
+$(OBJDIR)/%.o: $(RESDIR)/%.c
+ $(LCC) $(LCCFLAGS) -c -o $@ $<
+
+# Compile .s assembly files in "src/" to .o object files
+$(OBJDIR)/%.o: $(SRCDIR)/%.s
+ $(LCC) $(LCCFLAGS) -c -o $@ $<
+
+# If needed, compile .c files i n"src/" to .s assembly files
+# (not required if .c is compiled directly to .o)
+$(OBJDIR)/%.s: $(SRCDIR)/%.c
+ $(LCC) $(LCCFLAGS) -S -o $@ $<
+
+# Link the compiled object files into a .pocket ROM file
+$(BINS): $(OBJS)
+ $(LCC) $(LCCFLAGS) -o $(BINS) $(OBJS)
+
+prepare:
+ mkdir -p $(OBJDIR)
+
+clean:
+# rm -f *.pocket *.ihx *.cdb *.adb *.noi *.map
+ rm -f $(OBJDIR)/*.*
+
diff --git a/gbdk/gbdk-lib/examples/ap/template_subfolders/Readme.md b/gbdk/gbdk-lib/examples/ap/template_subfolders/Readme.md
new file mode 100644
index 00000000..92830df2
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/template_subfolders/Readme.md
@@ -0,0 +1,18 @@
+
+A template project with a Makefile that supports sub-directories.
+
+The Makefile will automatically detect and compile new source files
+when they are added to the "src" and "res" directories.
+
+Project directories
+ - src: Main program source files (.c, .h, .s) can go here
+ - res: Program graphics and audio source files (.c, .h, .s) can go here
+ - obj: Compiled ROM (.gb) and debug files go in this directory
+
+
+== Sprite and Background tiles from: ==
+
+https://sondanielson.itch.io/gameboy-simple-rpg-tileset
+"Licence is under CCA so you can use these assets both privately and commercially"
+"You are free to use them as is or modify them to your liking. All i ask is you credit me if you do use them please :)"
+
diff --git a/gbdk/gbdk-lib/examples/ap/template_subfolders/res/dungeon_32x32.gbm b/gbdk/gbdk-lib/examples/ap/template_subfolders/res/dungeon_32x32.gbm
new file mode 100644
index 00000000..7418854b
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/template_subfolders/res/dungeon_32x32.gbm
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/ap/template_subfolders/res/dungeon_32x32.gbr b/gbdk/gbdk-lib/examples/ap/template_subfolders/res/dungeon_32x32.gbr
new file mode 100644
index 00000000..ba5ca530
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/template_subfolders/res/dungeon_32x32.gbr
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/ap/template_subfolders/res/dungeon_map.c b/gbdk/gbdk-lib/examples/ap/template_subfolders/res/dungeon_map.c
new file mode 100644
index 00000000..b1617ee5
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/template_subfolders/res/dungeon_map.c
@@ -0,0 +1,133 @@
+/*
+
+ DUNGEON_MAP.C
+
+ Map Source File.
+
+ Info:
+ Section :
+ Bank : 0
+ Map size : 32 x 32
+ Tile set : dungeon_32x32.gbr
+ Plane count : 1 plane (8 bits)
+ Plane order : Planes are continues
+ Tile offset : 0
+ Split data : No
+
+ This file was generated by GBMB v1.8
+
+*/
+
+#define dungeon_mapWidth 32
+#define dungeon_mapHeight 32
+#define dungeon_mapBank 0
+
+#define dungeon_map dungeon_mapPLN0
+const unsigned char dungeon_mapPLN0[] =
+{
+ 0x0A,0x0B,0x07,0x05,0x06,0x04,0x07,0x03,0x04,0x07,
+ 0x03,0x04,0x07,0x08,0x09,0x01,0x0A,0x0B,0x07,0x07,
+ 0x03,0x04,0x07,0x03,0x04,0x07,0x03,0x04,0x03,0x0C,
+ 0x08,0x09,0x0D,0x0E,0x0F,0x12,0x13,0x11,0x0F,0x10,
+ 0x11,0x0F,0x10,0x11,0x0F,0x14,0x15,0x01,0x0D,0x0E,
+ 0x0F,0x0F,0x10,0x11,0x0F,0x10,0x11,0x0F,0x10,0x11,
+ 0x10,0x16,0x14,0x15,0x17,0x18,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x19,0x1A,0x01,
+ 0x1B,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x1D,0x1E,0x1F,0x1C,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x19,
+ 0x1A,0x01,0x1F,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x19,0x1A,0x1B,0x20,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x21,0x22,0x01,0x1F,0x1C,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x21,0x22,
+ 0x1F,0x1C,0x00,0x00,0x00,0x23,0x24,0x25,0x24,0x26,
+ 0x00,0x00,0x00,0x27,0x28,0x01,0x17,0x18,0x00,0x00,
+ 0x00,0x23,0x24,0x25,0x24,0x26,0x00,0x00,0x00,0x00,
+ 0x27,0x28,0x17,0x18,0x00,0x00,0x00,0x19,0x2B,0x2C,
+ 0x2D,0x20,0x00,0x00,0x00,0x19,0x1A,0x01,0x1F,0x1C,
+ 0x00,0x00,0x00,0x19,0x2B,0x2C,0x2D,0x20,0x00,0x00,
+ 0x00,0x00,0x19,0x1A,0x1F,0x1C,0x00,0x00,0x00,0x21,
+ 0x22,0x01,0x1F,0x1C,0x00,0x00,0x00,0x21,0x15,0x01,
+ 0x0D,0x1C,0x00,0x00,0x00,0x21,0x22,0x01,0x1F,0x1C,
+ 0x00,0x00,0x00,0x00,0x21,0x22,0x1B,0x20,0x00,0x00,
+ 0x00,0x27,0x28,0x01,0x17,0x18,0x00,0x00,0x00,0x30,
+ 0x31,0x32,0x33,0x20,0x00,0x00,0x00,0x21,0x22,0x01,
+ 0x1F,0x1C,0x00,0x00,0x00,0x00,0x19,0x1A,0x1F,0x1C,
+ 0x00,0x00,0x00,0x19,0x1A,0x01,0x1F,0x1C,0x00,0x00,
+ 0x00,0x34,0x35,0x0F,0x10,0x36,0x00,0x00,0x00,0x27,
+ 0x28,0x01,0x17,0x18,0x00,0x00,0x00,0x00,0x21,0x22,
+ 0x1F,0x1C,0x00,0x00,0x00,0x21,0x22,0x01,0x1B,0x20,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x19,0x1A,0x01,0x1F,0x1C,0x00,0x00,0x00,0x00,
+ 0x19,0x1A,0x1F,0x1C,0x00,0x00,0x00,0x19,0x1A,0x01,
+ 0x1F,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x21,0x22,0x01,0x1B,0x20,0x00,0x00,
+ 0x00,0x00,0x21,0x22,0x1B,0x20,0x00,0x00,0x00,0x21,
+ 0x22,0x01,0x1F,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x19,0x1A,0x01,0x1F,0x1C,
+ 0x00,0x00,0x00,0x00,0x27,0x28,0x1F,0x1C,0x00,0x00,
+ 0x00,0x19,0x1A,0x01,0x37,0x38,0x24,0x26,0x00,0x00,
+ 0x00,0x23,0x24,0x24,0x25,0x24,0x39,0x3A,0x3B,0x01,
+ 0x1F,0x1C,0x00,0x00,0x00,0x00,0x19,0x1A,0x1B,0x20,
+ 0x00,0x00,0x00,0x21,0x22,0x01,0x3C,0x3D,0x2D,0x20,
+ 0x00,0x00,0x00,0x19,0x2B,0x3E,0x3F,0x3E,0x40,0x41,
+ 0x42,0x01,0x1B,0x20,0x00,0x00,0x00,0x00,0x21,0x22,
+ 0x1F,0x1C,0x00,0x00,0x00,0x27,0x15,0x01,0x01,0x01,
+ 0x1F,0x1C,0x00,0x00,0x00,0x21,0x22,0x01,0x01,0x01,
+ 0x01,0x01,0x01,0x01,0x0D,0x20,0x00,0x00,0x00,0x00,
+ 0x19,0x1A,0x1F,0x1C,0x00,0x00,0x00,0x30,0x31,0x0B,
+ 0x03,0x07,0x33,0x20,0x00,0x00,0x00,0x30,0x31,0x08,
+ 0x09,0x01,0x0A,0x0B,0x07,0x0B,0x33,0x20,0x00,0x00,
+ 0x00,0x00,0x21,0x22,0x1F,0x1C,0x00,0x00,0x00,0x34,
+ 0x35,0x0F,0x10,0x0F,0x10,0x36,0x00,0x00,0x00,0x34,
+ 0x35,0x14,0x15,0x01,0x0D,0x0E,0x0F,0x0F,0x10,0x36,
+ 0x00,0x00,0x00,0x00,0x19,0x22,0x29,0x2A,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x19,0x1A,0x01,0x1F,0x1C,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x43,0x44,0x2E,0x2F,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x19,0x1A,0x01,0x1F,0x1C,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x45,0x46,
+ 0x1B,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x31,0x32,
+ 0x33,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x21,0x22,0x37,0x38,0x24,0x24,0x24,0x24,0x24,0x25,
+ 0x24,0x39,0x24,0x25,0x24,0x26,0x00,0x00,0x00,0x34,
+ 0x35,0x0F,0x10,0x36,0x00,0x00,0x00,0x23,0x24,0x24,
+ 0x24,0x24,0x3A,0x3B,0x3C,0x3D,0x3E,0x3E,0x3E,0x3E,
+ 0x3E,0x3F,0x3E,0x40,0x3E,0x2C,0x2D,0x20,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x19,
+ 0x2B,0x41,0x3E,0x3E,0x41,0x42,0x01,0x01,0x01,0x01,
+ 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x1F,0x1C,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x21,0x22,0x01,0x01,0x01,0x01,0x01,0x0A,0x0B,
+ 0x07,0x03,0x07,0x03,0x04,0x07,0x03,0x04,0x0B,0x0B,
+ 0x33,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x30,0x31,0x0B,0x07,0x03,0x08,0x09,
+ 0x0D,0x0E,0x0F,0x10,0x0F,0x10,0x11,0x0F,0x10,0x11,
+ 0x10,0x0F,0x10,0x36,0x00,0x00,0x00,0x23,0x24,0x25,
+ 0x24,0x26,0x00,0x00,0x00,0x34,0x35,0x10,0x0F,0x10,
+ 0x14,0x15,0x1F,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x19,
+ 0x2B,0x2C,0x2D,0x20,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x27,0x28,0x1F,0x1C,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x27,0x28,0x01,0x17,0x18,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x19,0x1A,0x1B,0x20,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x19,0x1A,0x01,0x1F,0x1C,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x21,0x22,0x47,0x48,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x21,0x22,0x01,0x1B,0x20,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x21,0x22,
+ 0x37,0x38,0x49,0x4A,0x4B,0x24,0x39,0x24,0x24,0x24,
+ 0x25,0x24,0x39,0x24,0x24,0x39,0x25,0x3A,0x3B,0x01,
+ 0x37,0x38,0x24,0x25,0x24,0x39,0x24,0x25,0x24,0x39,
+ 0x3A,0x3B,0x3C,0x3D,0x4C,0x4D,0x4E,0x3E,0x40,0x3E,
+ 0x3E,0x3E,0x3F,0x3E,0x40,0x3E,0x3E,0x40,0x3F,0x41,
+ 0x42,0x01,0x3C,0x3D,0x3E,0x3F,0x3E,0x40,0x3E,0x3F,
+ 0x3E,0x40,0x41,0x42
+};
+
+/* End of DUNGEON_MAP.C */
diff --git a/gbdk/gbdk-lib/examples/ap/template_subfolders/res/dungeon_map.h b/gbdk/gbdk-lib/examples/ap/template_subfolders/res/dungeon_map.h
new file mode 100644
index 00000000..ac548240
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/template_subfolders/res/dungeon_map.h
@@ -0,0 +1,28 @@
+/*
+
+ DUNGEON_MAP.H
+
+ Map Include File.
+
+ Info:
+ Section :
+ Bank : 0
+ Map size : 32 x 32
+ Tile set : dungeon_32x32.gbr
+ Plane count : 1 plane (8 bits)
+ Plane order : Planes are continues
+ Tile offset : 0
+ Split data : No
+
+ This file was generated by GBMB v1.8
+
+*/
+
+#define dungeon_mapWidth 32
+#define dungeon_mapHeight 32
+#define dungeon_mapBank 0
+
+#define dungeon_map dungeon_mapPLN0
+extern const unsigned char dungeon_mapPLN0[];
+
+/* End of DUNGEON_MAP.H */
diff --git a/gbdk/gbdk-lib/examples/ap/template_subfolders/res/dungeon_tiles.c b/gbdk/gbdk-lib/examples/ap/template_subfolders/res/dungeon_tiles.c
new file mode 100644
index 00000000..06201969
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/template_subfolders/res/dungeon_tiles.c
@@ -0,0 +1,188 @@
+/*
+
+ DUNGEON_TILES.C
+
+ Tile Source File.
+
+ Info:
+ Form : All tiles as one unit.
+ Format : Gameboy 4 color.
+ Compression : None.
+ Counter : None.
+ Tile size : 8 x 8
+ Tiles : 0 to 78
+
+ Palette colors : Included.
+ SGB Palette : None.
+ CGB Palette : None.
+
+ Convert to metatiles : No.
+
+ This file was generated by GBTD v2.2
+
+*/
+
+/* Start of tile array. */
+const unsigned char dungeon_tiles[] =
+{
+ 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,
+ 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
+ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
+ 0xFF,0xFF,0x08,0x08,0x08,0x08,0xEB,0x1C,
+ 0xFF,0xFF,0x80,0x80,0xFF,0x80,0xFF,0x80,
+ 0xFF,0xFF,0x10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,0xFE,0xFB,0xFE,0xF2,0xFE,0xF3,0xFF,
+ 0xE6,0xFB,0xCF,0xF6,0x1E,0xEC,0xFF,0xFF
+};
+
+/* End of DUNGEON_TILES.C */
diff --git a/gbdk/gbdk-lib/examples/ap/template_subfolders/res/dungeon_tiles.h b/gbdk/gbdk-lib/examples/ap/template_subfolders/res/dungeon_tiles.h
new file mode 100644
index 00000000..f93486f0
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/template_subfolders/res/dungeon_tiles.h
@@ -0,0 +1,103 @@
+/*
+
+ DUNGEON_TILES.H
+
+ Include File.
+
+ Info:
+ Form : All tiles as one unit.
+ Format : Gameboy 4 color.
+ Compression : None.
+ Counter : None.
+ Tile size : 8 x 8
+ Tiles : 0 to 78
+
+ Palette colors : Included.
+ SGB Palette : None.
+ CGB Palette : None.
+
+ Convert to metatiles : No.
+
+ This file was generated by GBTD v2.2
+
+*/
+
+
+/* Bank of tiles. */
+#define dungeon_tilesBank 0
+
+/* Super Gameboy palette 0 */
+#define dungeon_tilesSGBPal0c0 0
+#define dungeon_tilesSGBPal0c1 0
+#define dungeon_tilesSGBPal0c2 22528
+#define dungeon_tilesSGBPal0c3 44
+
+/* Super Gameboy palette 1 */
+#define dungeon_tilesSGBPal1c0 6076
+#define dungeon_tilesSGBPal1c1 8935
+#define dungeon_tilesSGBPal1c2 6596
+#define dungeon_tilesSGBPal1c3 5344
+
+/* Super Gameboy palette 2 */
+#define dungeon_tilesSGBPal2c0 6076
+#define dungeon_tilesSGBPal2c1 8935
+#define dungeon_tilesSGBPal2c2 6596
+#define dungeon_tilesSGBPal2c3 5344
+
+/* Super Gameboy palette 3 */
+#define dungeon_tilesSGBPal3c0 6076
+#define dungeon_tilesSGBPal3c1 8935
+#define dungeon_tilesSGBPal3c2 6596
+#define dungeon_tilesSGBPal3c3 5344
+
+/* Gameboy Color palette 0 */
+#define dungeon_tilesCGBPal0c0 26620
+#define dungeon_tilesCGBPal0c1 14096
+#define dungeon_tilesCGBPal0c2 10662
+#define dungeon_tilesCGBPal0c3 2112
+
+/* Gameboy Color palette 1 */
+#define dungeon_tilesCGBPal1c0 6076
+#define dungeon_tilesCGBPal1c1 8935
+#define dungeon_tilesCGBPal1c2 6596
+#define dungeon_tilesCGBPal1c3 5344
+
+/* Gameboy Color palette 2 */
+#define dungeon_tilesCGBPal2c0 6076
+#define dungeon_tilesCGBPal2c1 8935
+#define dungeon_tilesCGBPal2c2 6596
+#define dungeon_tilesCGBPal2c3 5344
+
+/* Gameboy Color palette 3 */
+#define dungeon_tilesCGBPal3c0 6076
+#define dungeon_tilesCGBPal3c1 8935
+#define dungeon_tilesCGBPal3c2 6596
+#define dungeon_tilesCGBPal3c3 5344
+
+/* Gameboy Color palette 4 */
+#define dungeon_tilesCGBPal4c0 6076
+#define dungeon_tilesCGBPal4c1 8935
+#define dungeon_tilesCGBPal4c2 6596
+#define dungeon_tilesCGBPal4c3 5344
+
+/* Gameboy Color palette 5 */
+#define dungeon_tilesCGBPal5c0 6076
+#define dungeon_tilesCGBPal5c1 8935
+#define dungeon_tilesCGBPal5c2 6596
+#define dungeon_tilesCGBPal5c3 5344
+
+/* Gameboy Color palette 6 */
+#define dungeon_tilesCGBPal6c0 6076
+#define dungeon_tilesCGBPal6c1 8935
+#define dungeon_tilesCGBPal6c2 6596
+#define dungeon_tilesCGBPal6c3 5344
+
+/* Gameboy Color palette 7 */
+#define dungeon_tilesCGBPal7c0 6076
+#define dungeon_tilesCGBPal7c1 8935
+#define dungeon_tilesCGBPal7c2 6596
+#define dungeon_tilesCGBPal7c3 5344
+/* Start of tile array. */
+extern const const unsigned char dungeon_tiles[];
+
+/* End of DUNGEON_TILES.H */
diff --git a/gbdk/gbdk-lib/examples/ap/template_subfolders/src/main.c b/gbdk/gbdk-lib/examples/ap/template_subfolders/src/main.c
new file mode 100644
index 00000000..abc06cf2
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/ap/template_subfolders/src/main.c
@@ -0,0 +1,31 @@
+#include <gb/gb.h>
+#include <stdint.h>
+#include "../res/dungeon_map.h"
+#include "../res/dungeon_tiles.h"
+
+
+void init_gfx() {
+ // Load Background tiles and then map
+ set_bkg_data(0, 79u, dungeon_tiles);
+ set_bkg_tiles(0, 0, 32u, 32u, dungeon_mapPLN0);
+
+ // Turn the background map on to make it visible
+ SHOW_BKG;
+}
+
+
+void main(void)
+{
+ init_gfx();
+
+ // Loop forever
+ while(1) {
+
+
+ // Game main loop processing goes here
+
+
+ // Done processing, yield CPU and wait for start of next frame
+ wait_vbl_done();
+ }
+}
diff --git a/gbdk/gbdk-lib/examples/cross-platform/Makefile b/gbdk/gbdk-lib/examples/cross-platform/Makefile
new file mode 100644
index 00000000..f891d672
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/Makefile
@@ -0,0 +1,17 @@
+# Register all subdirectories in the project's root directory.
+SUBDIRS := $(wildcard */.)
+
+# Top-level phony targets.
+all clean compile.bat: $(SUBDIRS) FORCE
+# Similar to:
+# .PHONY: all clean
+# all clean: $(SUBDIRS)
+# GNU's .PHONY target is more efficient in that it explicitly declares non-files.
+
+# Recurse `make` into each subdirectory
+# Pass along targets specified at command-line (if any).
+$(SUBDIRS): FORCE
+ $(MAKE) -C $@ $(MAKECMDGOALS)
+
+# Force targets.
+FORCE: \ No newline at end of file
diff --git a/gbdk/gbdk-lib/examples/cross-platform/banks/Makefile b/gbdk/gbdk-lib/examples/cross-platform/banks/Makefile
new file mode 100644
index 00000000..9dc70c15
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/banks/Makefile
@@ -0,0 +1,82 @@
+SHELL := /bin/bash
+
+# If you move this project you can change the directory
+# to match your GBDK root directory (ex: GBDK_HOME = "C:/GBDK/"
+GBDK_HOME = ../../../
+LCC = $(GBDK_HOME)bin/lcc
+
+# Set platforms to build here, spaced separated. (These are in the separate Makefile.targets)
+# They can also be built/cleaned individually: "make gg" and "make gg-clean"
+# Possible are: gb gbc pocket megaduck sms gg
+TARGETS=gb pocket megaduck sms gg
+
+# Configure platform specific LCC flags here:
+LCCFLAGS_gb = -Wl-yt0x1B # Set an MBC for banking (1B-ROM+MBC5+RAM+BATT)
+LCCFLAGS_pocket = -Wl-yt0x1B # Usually the same as required for .gb
+LCCFLAGS_duck = -Wl-yt0x1B # Usually the same as required for .gb
+LCCFLAGS_gbc = -Wl-yt0x1B -Wm-yc # Same as .gb with: -Wm-yc (gb & gbc) or Wm-yC (gbc exclusive)
+LCCFLAGS_sms =
+LCCFLAGS_gg =
+
+LCCFLAGS += $(LCCFLAGS_$(EXT)) # This adds the current platform specific LCC Flags
+
+LCCFLAGS += -Wl-j -Wm-yoA -Wm-ya4 -autobank -Wb-ext=.rel -Wb-v # MBC + Autobanking related flags
+# LCCFLAGS += -debug # Uncomment to enable debug output
+# LCCFLAGS += -v # Uncomment for lcc verbose output
+
+# You can set the name of the ROM file here
+PROJECTNAME = banks
+
+# EXT?=gb # Only sets extension to default (game boy .gb) if not populated
+SRCDIR = src
+OBJDIR = obj/$(EXT)
+RESDIR = res
+BINDIR = build/$(EXT)
+MKDIRS = $(OBJDIR) $(BINDIR) # See bottom of Makefile for directory auto-creation
+
+BINS = $(OBJDIR)/$(PROJECTNAME).$(EXT)
+CSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.c))) $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.c)))
+ASMSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.s)))
+OBJS = $(CSOURCES:%.c=$(OBJDIR)/%.o) $(ASMSOURCES:%.s=$(OBJDIR)/%.o)
+
+# Builds all targets sequentially
+all: $(TARGETS)
+
+# Compile .c files in "src/" to .o object files
+$(OBJDIR)/%.o: $(SRCDIR)/%.c
+ $(eval BOFLAG = $(shell echo "$<" | sed -n 's/.*\.bo\([0-9]\+\).*/\-Wf-bo\1/p'))
+ $(eval BAFLAG = $(shell echo "$<" | sed -n 's/.*\.ba\([0-9]\+\).*/\-Wf-ba\1/p'))
+ $(LCC) -v $(CFLAGS) $(BOFLAG) $(BAFLAG) -c -o $@ $<
+
+# Compile .c files in "res/" to .o object files
+$(OBJDIR)/%.o: $(RESDIR)/%.c
+ $(LCC) $(CFLAGS) -c -o $@ $<
+
+# Compile .s assembly files in "src/" to .o object files
+$(OBJDIR)/%.o: $(SRCDIR)/%.s
+ $(LCC) $(CFLAGS) -c -o $@ $<
+
+# If needed, compile .c files i n"src/" to .s assembly files
+# (not required if .c is compiled directly to .o)
+$(OBJDIR)/%.s: $(SRCDIR)/%.c
+ $(LCC) $(CFLAGS) -S -o $@ $<
+
+# Link the compiled object files into a .gb ROM file
+$(BINS): $(OBJS)
+ $(LCC) $(LCCFLAGS) $(CFLAGS) -o $(BINDIR)/$(PROJECTNAME).$(EXT) $(OBJS)
+
+clean:
+ @echo Cleaning
+ @for target in $(TARGETS); do \
+ $(MAKE) $$target-clean; \
+ done
+
+# Include available build targets
+include Makefile.targets
+
+
+# create necessary directories after Makefile is parsed but before build
+# info prevents the command from being pasted into the makefile
+ifneq ($(strip $(EXT)),) # Only make the directories if EXT has been set by a target
+$(info $(shell mkdir -p $(MKDIRS)))
+endif
diff --git a/gbdk/gbdk-lib/examples/cross-platform/banks/Makefile.targets b/gbdk/gbdk-lib/examples/cross-platform/banks/Makefile.targets
new file mode 100644
index 00000000..c502f12f
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/banks/Makefile.targets
@@ -0,0 +1,50 @@
+
+# Platform specific flags for compiling (only populate if they're both present)
+ifneq ($(strip $(PORT)),)
+ifneq ($(strip $(PLAT)),)
+CFLAGS += -m$(PORT):$(PLAT)
+endif
+endif
+
+# Called by the individual targets below to build a ROM
+build-target: $(BINS)
+
+clean-target:
+ rm -rf $(OBJDIR)
+ rm -rf $(BINDIR)
+
+gb-clean:
+ ${MAKE} clean-target EXT=gb
+gb:
+ ${MAKE} build-target PORT=sm83 PLAT=gb EXT=gb
+
+
+gbc-clean:
+ ${MAKE} clean-target EXT=gbc
+gbc:
+ ${MAKE} build-target PORT=sm83 PLAT=gb EXT=gbc
+
+
+pocket-clean:
+ ${MAKE} clean-target EXT=pocket
+pocket:
+ ${MAKE} build-target PORT=sm83 PLAT=ap EXT=pocket
+
+
+megaduck-clean:
+ ${MAKE} clean-target EXT=duck
+megaduck:
+ ${MAKE} build-target PORT=sm83 PLAT=duck EXT=duck
+
+
+sms-clean:
+ ${MAKE} clean-target EXT=sms
+sms:
+ ${MAKE} build-target PORT=z80 PLAT=sms EXT=sms
+
+
+gg-clean:
+ ${MAKE} clean-target EXT=gg
+gg:
+ ${MAKE} build-target PORT=z80 PLAT=gg EXT=gg
+
diff --git a/gbdk/gbdk-lib/examples/cross-platform/banks/src/bank.ba0.bo0.c b/gbdk/gbdk-lib/examples/cross-platform/banks/src/bank.ba0.bo0.c
new file mode 100644
index 00000000..4d8f7cba
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/banks/src/bank.ba0.bo0.c
@@ -0,0 +1,4 @@
+#include <gbdk/platform.h>
+#include <stdint.h>
+
+int var_0; /* In external RAM bank 0 */
diff --git a/gbdk/gbdk-lib/examples/cross-platform/banks/src/bank.ba0.bo2.c b/gbdk/gbdk-lib/examples/cross-platform/banks/src/bank.ba0.bo2.c
new file mode 100644
index 00000000..cc434a0f
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/banks/src/bank.ba0.bo2.c
@@ -0,0 +1,10 @@
+#include <gbdk/platform.h>
+#include <stdint.h>
+#include <stdio.h>
+
+int var_2; /* In external RAM bank 0 */
+
+void bank_2() BANKED /* In ROM bank 2 */
+{
+ puts("I'm in ROM bank 2");
+}
diff --git a/gbdk/gbdk-lib/examples/cross-platform/banks/src/bank.ba1.bo1.c b/gbdk/gbdk-lib/examples/cross-platform/banks/src/bank.ba1.bo1.c
new file mode 100644
index 00000000..1d74e0e3
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/banks/src/bank.ba1.bo1.c
@@ -0,0 +1,10 @@
+#include <gbdk/platform.h>
+#include <stdint.h>
+#include <stdio.h>
+
+int var_1; /* In external RAM bank 1 */
+
+void bank_1() BANKED /* In ROM bank 1 */
+{
+ puts("I'm in ROM bank 1");
+}
diff --git a/gbdk/gbdk-lib/examples/cross-platform/banks/src/bank.ba1.bo3.c b/gbdk/gbdk-lib/examples/cross-platform/banks/src/bank.ba1.bo3.c
new file mode 100644
index 00000000..6182d3fd
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/banks/src/bank.ba1.bo3.c
@@ -0,0 +1,10 @@
+#include <gbdk/platform.h>
+#include <stdint.h>
+#include <stdio.h>
+
+int var_3; /* In external RAM bank 1 */
+
+void bank_3() BANKED /* In ROM bank 3 */
+{
+ puts("I'm in ROM bank 3");
+}
diff --git a/gbdk/gbdk-lib/examples/cross-platform/banks/src/banks.c b/gbdk/gbdk-lib/examples/cross-platform/banks/src/banks.c
new file mode 100644
index 00000000..6cd2b11d
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/banks/src/banks.c
@@ -0,0 +1,61 @@
+/** Note that this example is a bit old. Try BANKED and NONBANKED
+ as in banked/
+ */
+#include <gbdk/platform.h>
+#include <stdint.h>
+#include <stdio.h>
+
+int var_internal; /* In internal RAM */
+extern int var_0; /* In external RAM bank 0 */
+extern int var_1; /* In external RAM bank 1 */
+extern int var_2; /* In external RAM bank 2 */
+extern int var_3; /* In external RAM bank 3 */
+
+void bank_1() BANKED;
+void bank_2() BANKED;
+void bank_3() BANKED;
+
+void bank_fixed(void) NONBANKED
+{
+ puts("I'm in fixed ROM");
+}
+
+void print_var(uint8_t bank)
+{
+ SWITCH_RAM(bank);
+ printf("Var_%u is %u\n");
+}
+
+void main(void)
+{
+ puts("Program Start...");
+
+ ENABLE_RAM;
+
+ var_internal = 1;
+ SWITCH_RAM(0);
+ var_0 = 2;
+ SWITCH_RAM(1);
+ var_1 = 3;
+ SWITCH_RAM(0);
+ var_2 = 4;
+ SWITCH_RAM(1);
+ var_3 = 5;
+
+ bank_fixed();
+ bank_1();
+ bank_2();
+ bank_3();
+
+ printf("Var is %u\n", var_internal);
+ SWITCH_RAM(0);
+ printf("Var_0 is %u\n", var_0);
+ SWITCH_RAM(1);
+ printf("Var_1 is %u\n", var_1);
+ SWITCH_RAM(0);
+ printf("Var_2 is %u\n", var_2);
+ SWITCH_RAM(1);
+ printf("Var_3 is %u\n", var_3);
+
+ puts("The End...");
+}
diff --git a/gbdk/gbdk-lib/examples/cross-platform/banks_autobank/Makefile b/gbdk/gbdk-lib/examples/cross-platform/banks_autobank/Makefile
new file mode 100644
index 00000000..bbe3dd87
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/banks_autobank/Makefile
@@ -0,0 +1,82 @@
+# If you move this project you can change the directory
+# to match your GBDK root directory (ex: GBDK_HOME = "C:/GBDK/"
+GBDK_HOME = ../../../
+LCC = $(GBDK_HOME)bin/lcc
+
+# Set platforms to build here, spaced separated. (These are in the separate Makefile.targets)
+# They can also be built/cleaned individually: "make gg" and "make gg-clean"
+# Possible are: gb gbc pocket megaduck sms gg
+TARGETS = gb pocket megaduck sms gg msxdos
+
+# Configure platform specific LCC flags here:
+LCCFLAGS_gb = -Wl-yt0x1B # Set an MBC for banking (1B-ROM+MBC5+RAM+BATT)
+LCCFLAGS_pocket = -Wl-yt0x1B # Usually the same as required for .gb
+LCCFLAGS_duck = -Wl-yt0x1B # Usually the same as required for .gb
+LCCFLAGS_gbc = -Wl-yt0x1B -Wm-yc # Same as .gb with: -Wm-yc (gb & gbc) or Wm-yC (gbc exclusive)
+LCCFLAGS_sms =
+LCCFLAGS_gg =
+LCCFLAGS_msxdos =
+
+LCCFLAGS += $(LCCFLAGS_$(EXT)) # This adds the current platform specific LCC Flags
+
+LCCFLAGS += -Wl-j -Wm-yoA -Wm-ya4 -autobank -Wb-ext=.rel -Wb-v # MBC + Autobanking related flags
+# LCCFLAGS += -debug # Uncomment to enable debug output
+# LCCFLAGS += -v # Uncomment for lcc verbose output
+
+CFLAGS = -Iinclude
+
+# You can set the name of the ROM file here
+PROJECTNAME = test
+
+# EXT?=gb # Only sets extension to default (game boy .gb) if not populated
+SRCDIR = src
+OBJDIR = obj/$(EXT)
+RESDIR = res
+BINDIR = build/$(EXT)
+MKDIRS = $(OBJDIR) $(BINDIR) # See bottom of Makefile for directory auto-creation
+
+BINS = $(OBJDIR)/$(PROJECTNAME).$(EXT)
+CSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.c))) $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.c)))
+ASMSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.s)))
+OBJS = $(CSOURCES:%.c=$(OBJDIR)/%.o) $(ASMSOURCES:%.s=$(OBJDIR)/%.o)
+
+# Builds all targets sequentially
+all: $(TARGETS)
+
+# Compile .c files in "src/" to .o object files
+$(OBJDIR)/%.o: $(SRCDIR)/%.c
+ $(LCC) $(CFLAGS) -c -o $@ $<
+
+# Compile .c files in "res/" to .o object files
+$(OBJDIR)/%.o: $(RESDIR)/%.c
+ $(LCC) $(CFLAGS) -c -o $@ $<
+
+# Compile .s assembly files in "src/" to .o object files
+$(OBJDIR)/%.o: $(SRCDIR)/%.s
+ $(LCC) $(CFLAGS) -c -o $@ $<
+
+# If needed, compile .c files i n"src/" to .s assembly files
+# (not required if .c is compiled directly to .o)
+$(OBJDIR)/%.s: $(SRCDIR)/%.c
+ $(LCC) $(CFLAGS) -S -o $@ $<
+
+# Link the compiled object files into a .gb ROM file
+$(BINS): $(OBJS)
+ $(LCC) $(LCCFLAGS) $(CFLAGS) -o $(BINDIR)/$(PROJECTNAME).$(EXT) $(OBJS)
+ rm -f $(BINDIR)/*.map $(BINDIR)/*.ihx $(BINDIR)/*.bin
+
+clean:
+ @echo Cleaning
+ @for target in $(TARGETS); do \
+ $(MAKE) $$target-clean; \
+ done
+
+# Include available build targets
+include Makefile.targets
+
+
+# create necessary directories after Makefile is parsed but before build
+# info prevents the command from being pasted into the makefile
+ifneq ($(strip $(EXT)),) # Only make the directories if EXT has been set by a target
+$(info $(shell mkdir -p $(MKDIRS)))
+endif
diff --git a/gbdk/gbdk-lib/examples/cross-platform/banks_autobank/Makefile.targets b/gbdk/gbdk-lib/examples/cross-platform/banks_autobank/Makefile.targets
new file mode 100644
index 00000000..69da1a52
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/banks_autobank/Makefile.targets
@@ -0,0 +1,55 @@
+
+# Platform specific flags for compiling (only populate if they're both present)
+ifneq ($(strip $(PORT)),)
+ifneq ($(strip $(PLAT)),)
+CFLAGS += -m$(PORT):$(PLAT)
+endif
+endif
+
+# Called by the individual targets below to build a ROM
+build-target: $(BINS)
+
+clean-target:
+ rm -rf $(OBJDIR)
+ rm -rf $(BINDIR)
+
+gb-clean:
+ ${MAKE} clean-target EXT=gb
+gb:
+ ${MAKE} build-target PORT=sm83 PLAT=gb EXT=gb
+
+
+gbc-clean:
+ ${MAKE} clean-target EXT=gbc
+gbc:
+ ${MAKE} build-target PORT=sm83 PLAT=gb EXT=gbc
+
+
+pocket-clean:
+ ${MAKE} clean-target EXT=pocket
+pocket:
+ ${MAKE} build-target PORT=sm83 PLAT=ap EXT=pocket
+
+
+megaduck-clean:
+ ${MAKE} clean-target EXT=duck
+megaduck:
+ ${MAKE} build-target PORT=sm83 PLAT=duck EXT=duck
+
+
+sms-clean:
+ ${MAKE} clean-target EXT=sms
+sms:
+ ${MAKE} build-target PORT=z80 PLAT=sms EXT=sms
+
+
+gg-clean:
+ ${MAKE} clean-target EXT=gg
+gg:
+ ${MAKE} build-target PORT=z80 PLAT=gg EXT=gg
+
+msxdos-clean:
+ ${MAKE} clean-target EXT=com
+msxdos:
+ ${MAKE} build-target PORT=z80 PLAT=msxdos EXT=com
+
diff --git a/gbdk/gbdk-lib/examples/cross-platform/banks_autobank/src/banks.c b/gbdk/gbdk-lib/examples/cross-platform/banks_autobank/src/banks.c
new file mode 100644
index 00000000..54e9be0c
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/banks_autobank/src/banks.c
@@ -0,0 +1,76 @@
+#include <gbdk/platform.h>
+#include <stdint.h>
+#include <stdio.h>
+
+// The header files below include provide bank references for the
+// banked const vars and functions in the other source files
+#include "srcfile_1.h"
+#include "srcfile_2.h"
+#include "srcfile_3.h"
+#include "srcfile_4_not-autobanked.h"
+
+
+// Non-banked const
+const uint8_t some_const_var_0 = 0;
+
+// Non-banked function
+void bank_fixed(void) NONBANKED
+{
+ puts("I'm in fixed ROM");
+}
+
+void main(void)
+{
+ uint8_t _saved_bank;
+
+ #ifndef MSXDOS // TODO
+ set_default_palette();
+ #endif
+ printf("Program Start...\n\n");
+
+ // Call the functions, unbanked first then the banked ones
+ bank_fixed();
+
+ func_1();
+ func_2();
+ func_3();
+ func_4();
+
+ printf("\n");
+
+
+ // Print the const vars, unbanked first then the banked ones
+ printf("Const0= %u nonbanked\n", some_const_var_0);
+
+ SWITCH_ROM(BANK(some_const_var_1));
+ printf("Const1= %u in bank %hu\n", some_const_var_1, BANK(some_const_var_1));
+ SWITCH_ROM(BANK(some_const_var_2));
+ printf("Const2= %u in bank %hu\n", some_const_var_2, BANK(some_const_var_2));
+ SWITCH_ROM(BANK(some_const_var_3));
+ printf("Const3= %u in bank %hu\n", some_const_var_3, BANK(some_const_var_3));
+
+ // If you want to temporarily save and then restore the previous active bank:
+ //
+
+ // Save the currently active bank
+ _saved_bank = _current_bank;
+
+ // Switch to the desired one
+ SWITCH_ROM(BANK(some_const_var_4));
+ printf("Const4= %u in bank %hu\n", some_const_var_4, BANK(some_const_var_4));
+
+ // Then restore the previous bank
+ SWITCH_ROM(_saved_bank);
+
+
+
+ printf("\n");
+ puts("The End...");
+
+ // Loop forever
+ while(1) {
+
+ // Yield CPU till the end of each frame
+ wait_vbl_done();
+ }
+}
diff --git a/gbdk/gbdk-lib/examples/cross-platform/banks_autobank/src/srcfile_1.c b/gbdk/gbdk-lib/examples/cross-platform/banks_autobank/src/srcfile_1.c
new file mode 100644
index 00000000..de1d1abb
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/banks_autobank/src/srcfile_1.c
@@ -0,0 +1,62 @@
+#include <gbdk/platform.h>
+#include <stdint.h>
+#include <stdio.h>
+
+// These two entries are needed to enable auto-banking in the source file
+#pragma bank 255
+
+
+BANKREF(some_const_var_1)
+const uint8_t some_const_var_1 = 1;
+
+
+BANKREF(func_1)
+void func_1() BANKED
+{
+ printf("Func1 in ROM bank %u\n", _current_bank);
+}
+
+// A big constant array to take up space
+static const unsigned char local_const_1[] = {
+
+ // 512
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,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,1,1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+
+};
diff --git a/gbdk/gbdk-lib/examples/cross-platform/banks_autobank/src/srcfile_1.h b/gbdk/gbdk-lib/examples/cross-platform/banks_autobank/src/srcfile_1.h
new file mode 100644
index 00000000..ccba45d9
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/banks_autobank/src/srcfile_1.h
@@ -0,0 +1,15 @@
+#include <gbdk/platform.h>
+
+#ifndef _srcfile_1_h
+#define _srcfile_1_h
+
+// "BANKREF_EXTERN()" makes a "BANKREF()" reference
+// from another source file accessible for use with "BANK()"
+extern const uint8_t some_const_var_1;
+BANKREF_EXTERN(some_const_var_1)
+
+// Reference for a banked function
+void func_1() BANKED;
+BANKREF_EXTERN(func_1)
+
+#endif \ No newline at end of file
diff --git a/gbdk/gbdk-lib/examples/cross-platform/banks_autobank/src/srcfile_2.c b/gbdk/gbdk-lib/examples/cross-platform/banks_autobank/src/srcfile_2.c
new file mode 100644
index 00000000..f8879eaf
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/banks_autobank/src/srcfile_2.c
@@ -0,0 +1,302 @@
+#include <gbdk/platform.h>
+#include <stdint.h>
+#include <stdio.h>
+
+// These two entries are needed to enable auto-banking in the source file
+#pragma bank 255
+
+
+BANKREF(some_const_var_2)
+const uint8_t some_const_var_2 = 2;
+
+
+BANKREF(func_2)
+void func_2() BANKED
+{
+ printf("Func2 in ROM bank %u\n", _current_bank);
+}
+
+// A big constant array to take up space
+static const unsigned char local_const_2[] = {
+
+ // 512
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1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1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+};
+
diff --git a/gbdk/gbdk-lib/examples/cross-platform/banks_autobank/src/srcfile_2.h b/gbdk/gbdk-lib/examples/cross-platform/banks_autobank/src/srcfile_2.h
new file mode 100644
index 00000000..553a53c7
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/banks_autobank/src/srcfile_2.h
@@ -0,0 +1,15 @@
+#include <gbdk/platform.h>
+
+#ifndef _srcfile_2_h
+#define _srcfile_2_h
+
+// "BANKREF_EXTERN()" makes a "BANKREF()" reference
+// from another source file accessible for use with "BANK()"
+extern const uint8_t some_const_var_2;
+BANKREF_EXTERN(some_const_var_2)
+
+// Reference for a banked function
+void func_2() BANKED;
+BANKREF_EXTERN(func_2)
+
+#endif \ No newline at end of file
diff --git a/gbdk/gbdk-lib/examples/cross-platform/banks_autobank/src/srcfile_3.c b/gbdk/gbdk-lib/examples/cross-platform/banks_autobank/src/srcfile_3.c
new file mode 100644
index 00000000..a0a3d0af
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/banks_autobank/src/srcfile_3.c
@@ -0,0 +1,26 @@
+#include <gbdk/platform.h>
+#include <stdint.h>
+#include <stdio.h>
+
+// These two entries are needed to enable auto-banking in the source file
+#pragma bank 255
+
+BANKREF(some_const_var_3)
+const uint8_t some_const_var_3 = 3;
+
+
+BANKREF(func_3)
+void func_3() BANKED
+{
+ printf("Func3 in ROM bank %u\n", _current_bank);
+}
+
+// A big constant array to take up space
+static const unsigned char local_const_3[] = {
+
+ // 256
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+};
diff --git a/gbdk/gbdk-lib/examples/cross-platform/banks_autobank/src/srcfile_3.h b/gbdk/gbdk-lib/examples/cross-platform/banks_autobank/src/srcfile_3.h
new file mode 100644
index 00000000..a2e177a2
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/banks_autobank/src/srcfile_3.h
@@ -0,0 +1,15 @@
+#include <gbdk/platform.h>
+
+#ifndef _srcfile_3_h
+#define _srcfile_3_h
+
+// "BANKREF_EXTERN()" makes a "BANKREF()" reference
+// from another source file accessible for use with "BANK()"
+extern const uint8_t some_const_var_3;
+BANKREF_EXTERN(some_const_var_3)
+
+// Reference for a banked function
+void func_3() BANKED;
+BANKREF_EXTERN(func_3)
+
+#endif \ No newline at end of file
diff --git a/gbdk/gbdk-lib/examples/cross-platform/banks_autobank/src/srcfile_4_not-autobanked.c b/gbdk/gbdk-lib/examples/cross-platform/banks_autobank/src/srcfile_4_not-autobanked.c
new file mode 100644
index 00000000..8e449685
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/banks_autobank/src/srcfile_4_not-autobanked.c
@@ -0,0 +1,343 @@
+#include <gbdk/platform.h>
+#include <stdint.h>
+#include <stdio.h>
+
+// In this source file a non-auto bank (2) is used (no auto-banking)
+#pragma bank 2
+
+
+const uint8_t some_const_var_4 = 4;
+BANKREF(some_const_var_4)
+
+void func_4() BANKED
+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1,1,1,1,1,1,1,1,1,1,1,1,1,
+
+
+};
diff --git a/gbdk/gbdk-lib/examples/cross-platform/banks_autobank/src/srcfile_4_not-autobanked.h b/gbdk/gbdk-lib/examples/cross-platform/banks_autobank/src/srcfile_4_not-autobanked.h
new file mode 100644
index 00000000..db344fc7
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/banks_autobank/src/srcfile_4_not-autobanked.h
@@ -0,0 +1,15 @@
+#include <gbdk/platform.h>
+
+#ifndef _srcfile_4_h
+#define _srcfile_4_h
+
+// "BANKREF_EXTERN()" makes a "BANKREF()" reference
+// from another source file accessible for use with "BANK()"
+extern const uint8_t some_const_var_4;
+BANKREF_EXTERN(some_const_var_4)
+
+// Reference for a banked function
+void func_4() BANKED;
+BANKREF_EXTERN(func_4)
+
+#endif \ No newline at end of file
diff --git a/gbdk/gbdk-lib/examples/cross-platform/banks_farptr/Makefile b/gbdk/gbdk-lib/examples/cross-platform/banks_farptr/Makefile
new file mode 100644
index 00000000..e15e7c31
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/banks_farptr/Makefile
@@ -0,0 +1,78 @@
+# If you move this project you can change the directory
+# to match your GBDK root directory (ex: GBDK_HOME = "C:/GBDK/"
+GBDK_HOME = ../../../
+LCC = $(GBDK_HOME)bin/lcc
+
+# Set platforms to build here, spaced separated. (These are in the separate Makefile.targets)
+# They can also be built/cleaned individually: "make gg" and "make gg-clean"
+# Possible are: gb gbc pocket megaduck sms gg
+TARGETS=gb pocket megaduck sms gg
+
+# Configure platform specific LCC flags here:
+LCCFLAGS_gb = -Wl-yt0x1B # Set an MBC for banking (1B-ROM+MBC5+RAM+BATT)
+LCCFLAGS_pocket = -Wl-yt0x1B # Usually the same as required for .gb
+LCCFLAGS_duck = -Wl-yt0x1B # Usually the same as required for .gb
+LCCFLAGS_gbc = -Wl-yt0x1B -Wm-yc # Same as .gb with: -Wm-yc (gb & gbc) or Wm-yC (gbc exclusive)
+LCCFLAGS_sms =
+LCCFLAGS_gg =
+
+LCCFLAGS += $(LCCFLAGS_$(EXT)) # This adds the current platform specific LCC Flags
+
+LCCFLAGS += -Wl-j -Wm-yoA -Wm-ya4 -autobank -Wb-ext=.rel -Wb-v # MBC + Autobanking related flags
+# LCCFLAGS += -debug # Uncomment to enable debug output
+# LCCFLAGS += -v # Uncomment for lcc verbose output
+
+# You can set the name of the ROM file here
+PROJECTNAME = banks_farptr
+
+# EXT?=gb # Only sets extension to default (game boy .gb) if not populated
+SRCDIR = src
+OBJDIR = obj/$(EXT)
+RESDIR = res
+BINDIR = build/$(EXT)
+MKDIRS = $(OBJDIR) $(BINDIR) # See bottom of Makefile for directory auto-creation
+
+BINS = $(OBJDIR)/$(PROJECTNAME).$(EXT)
+CSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.c))) $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.c)))
+ASMSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.s)))
+OBJS = $(CSOURCES:%.c=$(OBJDIR)/%.o) $(ASMSOURCES:%.s=$(OBJDIR)/%.o)
+
+# Builds all targets sequentially
+all: $(TARGETS)
+
+# Compile .c files in "src/" to .o object files
+$(OBJDIR)/%.o: $(SRCDIR)/%.c
+ $(LCC) $(CFLAGS) -c -o $@ $<
+
+# Compile .c files in "res/" to .o object files
+$(OBJDIR)/%.o: $(RESDIR)/%.c
+ $(LCC) $(CFLAGS) -c -o $@ $<
+
+# Compile .s assembly files in "src/" to .o object files
+$(OBJDIR)/%.o: $(SRCDIR)/%.s
+ $(LCC) $(CFLAGS) -c -o $@ $<
+
+# If needed, compile .c files i n"src/" to .s assembly files
+# (not required if .c is compiled directly to .o)
+$(OBJDIR)/%.s: $(SRCDIR)/%.c
+ $(LCC) $(CFLAGS) -S -o $@ $<
+
+# Link the compiled object files into a .gb ROM file
+$(BINS): $(OBJS)
+ $(LCC) $(LCCFLAGS) $(CFLAGS) -o $(BINDIR)/$(PROJECTNAME).$(EXT) $(OBJS)
+
+clean:
+ @echo Cleaning
+ @for target in $(TARGETS); do \
+ $(MAKE) $$target-clean; \
+ done
+
+# Include available build targets
+include Makefile.targets
+
+
+# create necessary directories after Makefile is parsed but before build
+# info prevents the command from being pasted into the makefile
+ifneq ($(strip $(EXT)),) # Only make the directories if EXT has been set by a target
+$(info $(shell mkdir -p $(MKDIRS)))
+endif
diff --git a/gbdk/gbdk-lib/examples/cross-platform/banks_farptr/Makefile.targets b/gbdk/gbdk-lib/examples/cross-platform/banks_farptr/Makefile.targets
new file mode 100644
index 00000000..c502f12f
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/banks_farptr/Makefile.targets
@@ -0,0 +1,50 @@
+
+# Platform specific flags for compiling (only populate if they're both present)
+ifneq ($(strip $(PORT)),)
+ifneq ($(strip $(PLAT)),)
+CFLAGS += -m$(PORT):$(PLAT)
+endif
+endif
+
+# Called by the individual targets below to build a ROM
+build-target: $(BINS)
+
+clean-target:
+ rm -rf $(OBJDIR)
+ rm -rf $(BINDIR)
+
+gb-clean:
+ ${MAKE} clean-target EXT=gb
+gb:
+ ${MAKE} build-target PORT=sm83 PLAT=gb EXT=gb
+
+
+gbc-clean:
+ ${MAKE} clean-target EXT=gbc
+gbc:
+ ${MAKE} build-target PORT=sm83 PLAT=gb EXT=gbc
+
+
+pocket-clean:
+ ${MAKE} clean-target EXT=pocket
+pocket:
+ ${MAKE} build-target PORT=sm83 PLAT=ap EXT=pocket
+
+
+megaduck-clean:
+ ${MAKE} clean-target EXT=duck
+megaduck:
+ ${MAKE} build-target PORT=sm83 PLAT=duck EXT=duck
+
+
+sms-clean:
+ ${MAKE} clean-target EXT=sms
+sms:
+ ${MAKE} build-target PORT=z80 PLAT=sms EXT=sms
+
+
+gg-clean:
+ ${MAKE} clean-target EXT=gg
+gg:
+ ${MAKE} build-target PORT=z80 PLAT=gg EXT=gg
+
diff --git a/gbdk/gbdk-lib/examples/cross-platform/banks_farptr/src/bank2code.c b/gbdk/gbdk-lib/examples/cross-platform/banks_farptr/src/bank2code.c
new file mode 100644
index 00000000..a07d1a3b
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/banks_farptr/src/bank2code.c
@@ -0,0 +1,21 @@
+#pragma bank 2
+
+#include <gbdk/platform.h>
+#include <stdint.h>
+#include <stdio.h>
+
+static int local_bank2_proc(int param1, int param2) {
+ printf(" sum: %d (bank=%d)\n", param1 + param2, (int)CURRENT_BANK);
+ return (param1 + param2) << 1;
+}
+
+BANKREF(some_bank2_proc0)
+void some_bank2_proc0() __banked {
+ printf("some_bank2_proc0\n");
+}
+
+BANKREF(some_bank2_proc1)
+int some_bank2_proc1(int param1, int param2) __banked {
+ printf("some_bank2_proc1\n");
+ return local_bank2_proc(param1, param2);
+}
diff --git a/gbdk/gbdk-lib/examples/cross-platform/banks_farptr/src/banks_farptr.c b/gbdk/gbdk-lib/examples/cross-platform/banks_farptr/src/banks_farptr.c
new file mode 100644
index 00000000..afcbbd20
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/banks_farptr/src/banks_farptr.c
@@ -0,0 +1,48 @@
+#include <stdint.h>
+#include <stdio.h>
+#include <gbdk/platform.h>
+#include <gbdk/far_ptr.h>
+
+// functions from bank2code.c
+BANKREF_EXTERN(some_bank2_proc0)
+extern void some_bank2_proc0() __banked;
+
+BANKREF_EXTERN(some_bank2_proc1)
+extern int some_bank2_proc1(int param1, int param2) __banked;
+typedef int (*some_bank2_proc_t)(int, int) __banked; // define type for some_bank2_proc1() function
+
+// far pointers
+FAR_PTR farptr_var0, farptr_var1, farptr_var2;
+
+// result of a function call
+int res;
+
+void run() {
+ // compose far pointer at runtime
+ farptr_var0 = to_far_ptr(some_bank2_proc1, BANK(some_bank2_proc1));
+ farptr_var1 = to_far_ptr(some_bank2_proc1, BANK(some_bank2_proc1));
+ farptr_var2 = to_far_ptr(some_bank2_proc0, BANK(some_bank2_proc0));
+
+ // output far pointers (must be identical)
+ printf("FAR PTR0: %x:%x\n", (int)FAR_SEG(farptr_var0), (int)FAR_OFS(farptr_var0));
+ printf("FAR PTR1: %x:%x\n", (int)FAR_SEG(farptr_var1), (int)FAR_OFS(farptr_var1));
+
+ // try calling far function by far pointer without params
+ FAR_CALL(farptr_var2, void (*)(void));
+
+ // try calling far function directly
+ res = some_bank2_proc1(100, 50);
+ printf("CALL DIR: %d\n", res);
+
+ // try calling far function by far pointer
+ res = FAR_CALL(farptr_var1, some_bank2_proc_t, 100, 50);
+
+ printf("CALL IND: %d\n", res);
+}
+
+void main() {
+ ENABLE_RAM;
+ printf("START (bank=%d)\n", (int)CURRENT_BANK);
+ run();
+ printf("DONE! (bank=%d)\n", (int)CURRENT_BANK);
+} \ No newline at end of file
diff --git a/gbdk/gbdk-lib/examples/cross-platform/banks_nonintrinsic/Makefile b/gbdk/gbdk-lib/examples/cross-platform/banks_nonintrinsic/Makefile
new file mode 100644
index 00000000..eb07d221
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/banks_nonintrinsic/Makefile
@@ -0,0 +1,78 @@
+# If you move this project you can change the directory
+# to match your GBDK root directory (ex: GBDK_HOME = "C:/GBDK/"
+GBDK_HOME = ../../../
+LCC = $(GBDK_HOME)bin/lcc
+
+# Set platforms to build here, spaced separated. (These are in the separate Makefile.targets)
+# They can also be built/cleaned individually: "make gg" and "make gg-clean"
+# Possible are: gb gbc pocket megaduck sms gg
+TARGETS=gb pocket megaduck sms gg
+
+# Configure platform specific LCC flags here:
+LCCFLAGS_gb = -Wl-yt0x1B # Set an MBC for banking (1B-ROM+MBC5+RAM+BATT)
+LCCFLAGS_pocket = -Wl-yt0x1B # Usually the same as required for .gb
+LCCFLAGS_duck = -Wl-yt0x1B # Usually the same as required for .gb
+LCCFLAGS_gbc = -Wl-yt0x1B -Wm-yc # Same as .gb with: -Wm-yc (gb & gbc) or Wm-yC (gbc exclusive)
+LCCFLAGS_sms =
+LCCFLAGS_gg =
+
+LCCFLAGS += $(LCCFLAGS_$(EXT)) # This adds the current platform specific LCC Flags
+
+LCCFLAGS += -Wl-j -Wm-yoA -Wm-ya4 -autobank -Wb-ext=.rel -Wb-v # MBC + Autobanking related flags
+# LCCFLAGS += -debug # Uncomment to enable debug output
+# LCCFLAGS += -v # Uncomment for lcc verbose output
+
+# You can set the name of the ROM file here
+PROJECTNAME = banks_nonintrinsic
+
+# EXT?=gb # Only sets extension to default (game boy .gb) if not populated
+SRCDIR = src
+OBJDIR = obj/$(EXT)
+RESDIR = res
+BINDIR = build/$(EXT)
+MKDIRS = $(OBJDIR) $(BINDIR) # See bottom of Makefile for directory auto-creation
+
+BINS = $(OBJDIR)/$(PROJECTNAME).$(EXT)
+CSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.c))) $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.c)))
+ASMSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.s)))
+OBJS = $(CSOURCES:%.c=$(OBJDIR)/%.o) $(ASMSOURCES:%.s=$(OBJDIR)/%.o)
+
+# Builds all targets sequentially
+all: $(TARGETS)
+
+# Compile .c files in "src/" to .o object files
+$(OBJDIR)/%.o: $(SRCDIR)/%.c
+ $(LCC) $(CFLAGS) -c -o $@ $<
+
+# Compile .c files in "res/" to .o object files
+$(OBJDIR)/%.o: $(RESDIR)/%.c
+ $(LCC) $(CFLAGS) -c -o $@ $<
+
+# Compile .s assembly files in "src/" to .o object files
+$(OBJDIR)/%.o: $(SRCDIR)/%.s
+ $(LCC) $(CFLAGS) -c -o $@ $<
+
+# If needed, compile .c files i n"src/" to .s assembly files
+# (not required if .c is compiled directly to .o)
+$(OBJDIR)/%.s: $(SRCDIR)/%.c
+ $(LCC) $(CFLAGS) -S -o $@ $<
+
+# Link the compiled object files into a .gb ROM file
+$(BINS): $(OBJS)
+ $(LCC) $(LCCFLAGS) $(CFLAGS) -o $(BINDIR)/$(PROJECTNAME).$(EXT) $(OBJS)
+
+clean:
+ @echo Cleaning
+ @for target in $(TARGETS); do \
+ $(MAKE) $$target-clean; \
+ done
+
+# Include available build targets
+include Makefile.targets
+
+
+# create necessary directories after Makefile is parsed but before build
+# info prevents the command from being pasted into the makefile
+ifneq ($(strip $(EXT)),) # Only make the directories if EXT has been set by a target
+$(info $(shell mkdir -p $(MKDIRS)))
+endif
diff --git a/gbdk/gbdk-lib/examples/cross-platform/banks_nonintrinsic/Makefile.targets b/gbdk/gbdk-lib/examples/cross-platform/banks_nonintrinsic/Makefile.targets
new file mode 100644
index 00000000..c502f12f
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/banks_nonintrinsic/Makefile.targets
@@ -0,0 +1,50 @@
+
+# Platform specific flags for compiling (only populate if they're both present)
+ifneq ($(strip $(PORT)),)
+ifneq ($(strip $(PLAT)),)
+CFLAGS += -m$(PORT):$(PLAT)
+endif
+endif
+
+# Called by the individual targets below to build a ROM
+build-target: $(BINS)
+
+clean-target:
+ rm -rf $(OBJDIR)
+ rm -rf $(BINDIR)
+
+gb-clean:
+ ${MAKE} clean-target EXT=gb
+gb:
+ ${MAKE} build-target PORT=sm83 PLAT=gb EXT=gb
+
+
+gbc-clean:
+ ${MAKE} clean-target EXT=gbc
+gbc:
+ ${MAKE} build-target PORT=sm83 PLAT=gb EXT=gbc
+
+
+pocket-clean:
+ ${MAKE} clean-target EXT=pocket
+pocket:
+ ${MAKE} build-target PORT=sm83 PLAT=ap EXT=pocket
+
+
+megaduck-clean:
+ ${MAKE} clean-target EXT=duck
+megaduck:
+ ${MAKE} build-target PORT=sm83 PLAT=duck EXT=duck
+
+
+sms-clean:
+ ${MAKE} clean-target EXT=sms
+sms:
+ ${MAKE} build-target PORT=z80 PLAT=sms EXT=sms
+
+
+gg-clean:
+ ${MAKE} clean-target EXT=gg
+gg:
+ ${MAKE} build-target PORT=z80 PLAT=gg EXT=gg
+
diff --git a/gbdk/gbdk-lib/examples/cross-platform/banks_nonintrinsic/src/banks_nonintrinsic.c b/gbdk/gbdk-lib/examples/cross-platform/banks_nonintrinsic/src/banks_nonintrinsic.c
new file mode 100644
index 00000000..593bb5ee
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/banks_nonintrinsic/src/banks_nonintrinsic.c
@@ -0,0 +1,90 @@
+#include <gbdk/platform.h>
+#include <stdint.h>
+#include <stdio.h>
+
+// force bank switching macro
+uint8_t __dummy_variable;
+#define switch_to(x) (__dummy_variable = (char)((x)[0]), (void *)(x))
+
+uint8_t _current_ram_bank = 0;
+#define SWITCH_RAM_BANK(x) (_current_ram_bank = (SWITCH_RAM(x), (x)))
+
+// constant in base ROM
+const char const hello0[] = "hello from CODE\n";
+// variable in base RAM
+char data[20] = "DATA";
+int addendum0 = 1;
+
+// constants in ROM banks
+
+void set_ROM_bank1(void) NONBANKED { SWITCH_ROM(1); }
+void set_ROM_bank2(void) NONBANKED { SWITCH_ROM(2); }
+
+__addressmod set_ROM_bank1 const CODE_1;
+__addressmod set_ROM_bank2 const CODE_2;
+
+CODE_1 const char hello1[] = "hello from CODE_1\n";
+CODE_2 const char hello2[] = "hello from CODE_2\n";
+
+// variables in RAM banks
+
+void set_RAM_bank1(void) NONBANKED { SWITCH_RAM_BANK(0); }
+void set_RAM_bank2(void) NONBANKED { SWITCH_RAM_BANK(1); }
+
+__addressmod set_RAM_bank1 DATA_0;
+__addressmod set_RAM_bank2 DATA_1;
+
+DATA_0 char hello1_ram[20];
+DATA_0 int addendum1_ram;
+DATA_1 char hello2_ram[20];
+DATA_1 int addendum2_ram;
+DATA_1 int addendum3_ram;
+
+// define array of pointers in RAM2 to the variables that are RAM2
+// there is a flaw in compiler that disallows pointers into banks to be in the other banks
+// details: https://sourceforge.net/p/sdcc/bugs/2995/
+DATA_0 int * const CODE_1 addendum_ptr[2] = {&addendum2_ram, &addendum3_ram};
+
+void main() {
+ ENABLE_RAM;
+
+ addendum1_ram = 2;
+ addendum2_ram = 4;
+ addendum3_ram = 8;
+
+ // say hello
+ for (int8_t i = 0; (hello0[i]); i++) putchar(hello0[i]);
+ for (int8_t i = 0; (hello1[i]); i++) putchar(hello1[i]);
+ for (int8_t i = 0; (hello2[i]); i++) putchar(hello2[i]);
+
+ // prepare and say hello from rom bank1 to ram bank0
+ for (int8_t i = 0; (i < sizeof(hello1)); i++) hello1_ram[i] = hello1[i];
+ for (int8_t i = 0; (i < 4); i++) hello1_ram[i + 11] = data[i];
+ for (int8_t i = 0; (hello1_ram[i]); i++) putchar(hello1_ram[i]);
+
+ // prepare and say hello from rom bank1 to ram bank1
+ for (int8_t i = 0; (i < sizeof(hello2)); i++) hello2_ram[i] = hello2[i];
+ for (int8_t i = 0; (i < 4); i++) hello2_ram[i + 11] = data[i];
+ for (int8_t i = 0; (hello2_ram[i]); i++) putchar(hello2_ram[i]);
+
+ printf("once more...\n");
+ // hello again; if we access we just access, don't care
+ for (int8_t i = 0; (hello0[i]); i++) putchar(hello0[i]);
+ for (int8_t i = 0; (hello1[i]); i++) putchar(hello1[i]);
+ for (int8_t i = 0; (hello2[i]); i++) putchar(hello2[i]);
+ for (int8_t i = 0; (hello1_ram[i]); i++) putchar(hello1_ram[i]);
+ for (int8_t i = 0; (hello2_ram[i]); i++) putchar(hello2_ram[i]);
+
+ printf("once more...\n");
+ // if we need an address, then we use a macro switch_to()
+ printf("%s", hello0);
+ printf("%s", switch_to(hello1));
+ printf("%s", switch_to(hello2));
+ printf("%s", switch_to(hello1_ram));
+ printf("%s", switch_to(hello2_ram));
+
+ printf("1+2+4+8=0x%x", (int)(addendum0 + addendum1_ram + (*addendum_ptr[0]) + (*addendum_ptr[1])));
+
+ // stop
+ while(1);
+}
diff --git a/gbdk/gbdk-lib/examples/cross-platform/emu_debug/Makefile b/gbdk/gbdk-lib/examples/cross-platform/emu_debug/Makefile
new file mode 100644
index 00000000..873fc97e
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/emu_debug/Makefile
@@ -0,0 +1,78 @@
+# If you move this project you can change the directory
+# to match your GBDK root directory (ex: GBDK_HOME = "C:/GBDK/"
+GBDK_HOME = ../../../
+LCC = $(GBDK_HOME)bin/lcc
+
+# Set platforms to build here, spaced separated. (These are in the separate Makefile.targets)
+# They can also be built/cleaned individually: "make gg" and "make gg-clean"
+# Possible are: gb gbc pocket megaduck sms gg
+TARGETS=gg gbc
+
+# Configure platform specific LCC flags here:
+LCCFLAGS_gb = -Wl-yt0x1B # Set an MBC for banking (1B-ROM+MBC5+RAM+BATT)
+LCCFLAGS_pocket = -Wl-yt0x1B # Usually the same as required for .gb
+LCCFLAGS_duck = -Wl-yt0x1B # Usually the same as required for .gb
+LCCFLAGS_gbc = -Wl-yt0x1B -Wm-yc # Same as .gb with: -Wm-yc (gb & gbc) or Wm-yC (gbc exclusive)
+LCCFLAGS_sms =
+LCCFLAGS_gg =
+
+LCCFLAGS += $(LCCFLAGS_$(EXT)) # This adds the current platform specific LCC Flags
+
+LCCFLAGS += -Wl-j -Wm-yoA -Wm-ya4 -autobank -Wb-ext=.rel -Wb-v # MBC + Autobanking related flags
+LCCFLAGS += -debug # Uncomment to enable debug output
+# LCCFLAGS += -v # Uncomment for lcc verbose output
+
+# You can set the name of the ROM file here
+PROJECTNAME = emu_debug
+
+# EXT?=gb # Only sets extension to default (game boy .gb) if not populated
+SRCDIR = src
+OBJDIR = obj/$(EXT)
+RESDIR = res
+BINDIR = build/$(EXT)
+MKDIRS = $(OBJDIR) $(BINDIR) # See bottom of Makefile for directory auto-creation
+
+BINS = $(OBJDIR)/$(PROJECTNAME).$(EXT)
+CSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.c))) $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.c)))
+ASMSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.s)))
+OBJS = $(CSOURCES:%.c=$(OBJDIR)/%.o) $(ASMSOURCES:%.s=$(OBJDIR)/%.o)
+
+# Builds all targets sequentially
+all: $(TARGETS)
+
+# Compile .c files in "src/" to .o object files
+$(OBJDIR)/%.o: $(SRCDIR)/%.c
+ $(LCC) $(CFLAGS) -c -o $@ $<
+
+# Compile .c files in "res/" to .o object files
+$(OBJDIR)/%.o: $(RESDIR)/%.c
+ $(LCC) $(CFLAGS) -c -o $@ $<
+
+# Compile .s assembly files in "src/" to .o object files
+$(OBJDIR)/%.o: $(SRCDIR)/%.s
+ $(LCC) $(CFLAGS) -c -o $@ $<
+
+# If needed, compile .c files i n"src/" to .s assembly files
+# (not required if .c is compiled directly to .o)
+$(OBJDIR)/%.s: $(SRCDIR)/%.c
+ $(LCC) $(CFLAGS) -S -o $@ $<
+
+# Link the compiled object files into a .gb ROM file
+$(BINS): $(OBJS)
+ $(LCC) $(LCCFLAGS) $(CFLAGS) -o $(BINDIR)/$(PROJECTNAME).$(EXT) $(OBJS)
+
+clean:
+ @echo Cleaning
+ @for target in $(TARGETS); do \
+ $(MAKE) $$target-clean; \
+ done
+
+# Include available build targets
+include Makefile.targets
+
+
+# create necessary directories after Makefile is parsed but before build
+# info prevents the command from being pasted into the makefile
+ifneq ($(strip $(EXT)),) # Only make the directories if EXT has been set by a target
+$(info $(shell mkdir -p $(MKDIRS)))
+endif
diff --git a/gbdk/gbdk-lib/examples/cross-platform/emu_debug/Makefile.targets b/gbdk/gbdk-lib/examples/cross-platform/emu_debug/Makefile.targets
new file mode 100644
index 00000000..c502f12f
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/emu_debug/Makefile.targets
@@ -0,0 +1,50 @@
+
+# Platform specific flags for compiling (only populate if they're both present)
+ifneq ($(strip $(PORT)),)
+ifneq ($(strip $(PLAT)),)
+CFLAGS += -m$(PORT):$(PLAT)
+endif
+endif
+
+# Called by the individual targets below to build a ROM
+build-target: $(BINS)
+
+clean-target:
+ rm -rf $(OBJDIR)
+ rm -rf $(BINDIR)
+
+gb-clean:
+ ${MAKE} clean-target EXT=gb
+gb:
+ ${MAKE} build-target PORT=sm83 PLAT=gb EXT=gb
+
+
+gbc-clean:
+ ${MAKE} clean-target EXT=gbc
+gbc:
+ ${MAKE} build-target PORT=sm83 PLAT=gb EXT=gbc
+
+
+pocket-clean:
+ ${MAKE} clean-target EXT=pocket
+pocket:
+ ${MAKE} build-target PORT=sm83 PLAT=ap EXT=pocket
+
+
+megaduck-clean:
+ ${MAKE} clean-target EXT=duck
+megaduck:
+ ${MAKE} build-target PORT=sm83 PLAT=duck EXT=duck
+
+
+sms-clean:
+ ${MAKE} clean-target EXT=sms
+sms:
+ ${MAKE} build-target PORT=z80 PLAT=sms EXT=sms
+
+
+gg-clean:
+ ${MAKE} clean-target EXT=gg
+gg:
+ ${MAKE} build-target PORT=z80 PLAT=gg EXT=gg
+
diff --git a/gbdk/gbdk-lib/examples/cross-platform/emu_debug/src/emu_debug.c b/gbdk/gbdk-lib/examples/cross-platform/emu_debug/src/emu_debug.c
new file mode 100644
index 00000000..2ad023d8
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/emu_debug/src/emu_debug.c
@@ -0,0 +1,164 @@
+#include <gbdk/platform.h>
+#include <stdint.h>
+#include <stdio.h> // Just for printf()
+
+#include <gbdk/emu_debug.h> // Use this include to add the Emu debug functions
+
+
+// This example shows how to use support for profiling
+// and logging to the debug window in the emulator (BGB or Emulicious).
+//
+// 1. Build this ROM (emu_debug.gb) then load it in the emulator (BGB or Emulicious)
+// 2. Open the internal debugger by pressing the "ESC" or "F1" key
+// 3. From the debugger menu choose "debug messages" to open the debug messages window
+// 4. Reset the gameboy (you may need to press F9 in the debugger to resume running)
+// 5. The debug window will show the debug messages
+//
+// See the BGB Manual for more information
+// ("expressions, breakpoint conditions, and debug messages")
+// https://bgb.bircd.org/manual.html#expressions
+
+// If you see a message like the following, it is safe to ignore. It is a known
+// issue with SDCC and should not cause problems.
+//
+// " src/emu_debug.c:156: info 218: z80instructionSize() failed to parse line node, assuming 999 bytes ' llbl:'
+
+int main(void)
+{
+ SHOW_BKG;
+ DISPLAY_ON;
+
+ // Display a message on the screen
+ printf("Message to the\nScreen\n");
+
+ // Log a message to the Emulator debug message window
+ EMU_MESSAGE(""); // new line
+ EMU_MESSAGE("Message to the EMU console");
+
+ // ==== Normal Speed Mode ====
+ // Profile code: a single NOP instruction
+ //
+ // The clock units are "1 nop in [CGB] doublespeed mode".
+ // So when *not* running in CGB doublespeed mode you
+ // have to divide by 2 to get the correct cycle count.
+ //
+ // You should see the message "NOP TIME: 2".
+ //
+ // So in this case, divide the printed value by 2 = The NOP took "1" cycle
+
+ __critical { // Temporarily turn off interrupts for more accurate measurements
+ EMU_PROFILE_BEGIN("Profile a single NOP instruction at Normal Speed");
+ __asm__("nop");
+ EMU_PROFILE_END("NOP TIME:");
+ }
+
+
+ #ifdef NINTENDO
+ // ==== Color Game Boy in Double Speed Mode ====
+ // Profile code: a single NOP instruction
+ //
+ // The EMU_PROFILE_BEGIN/END macros don't support the
+ // Color Game Boy (CGB) in double speed mode (cpu_fast()).
+ // The example below shows what to use instead (and how to
+ // check for a CGB and turn on Double Speed mode).
+ //
+ // Check and only run this test if on CGB hardware
+ if (DEVICE_SUPPORTS_COLOR) {
+
+ // Set CGB into double speed mode
+ // (Requires passing -Wm-yc or -Wm-yC with Lcc during build time)
+ cpu_fast();
+ // Set some default DMG styled colors in the CGB Palette
+ set_default_palette();
+
+ // In CGB Double Speed mode, you don't have to
+ // divide by 2 to get the cycle count.
+ //
+ // You should see the message "NOP TIME: 1".
+
+ __critical { // Temporarily turn off interrupts for more accurate measurements
+ EMU_PROFILE_BEGIN("Profile a single NOP instruction at CGB Double Speed");
+ __asm__("nop");
+ // The "-4+" subtracts 4 clocks to compensate for the ones
+ // used by the debug message itself (Normal speed uses -8)
+ EMU_MESSAGE("NOP TIME:%-4+LASTCLKS%");
+ }
+
+ // Return the CGB to normal speed
+ cpu_slow();
+ }
+ #endif // NINTENDO
+
+
+ __critical { // Temporarily turn off interrupts for more accurate measurements
+
+ int c;
+
+ // Profile code in a loop
+ EMU_PROFILE_BEGIN("Profile code in a loop");
+ for(c=0; c<5; c++) {
+ // Do something
+ printf("%d\n", c);
+ }
+ // Elapsed cycle count output is in hex.
+ // Remember to divide by 2 for the result (Normal Speed)
+ EMU_PROFILE_END("LOOP TIME:");
+ }
+
+ // ==== Some other things you can print ====
+
+ // - For Game Boy TOTALCLKS shows the clocks counter ("internal divider")
+ // - For SMS/GG TOTALCLKS is relative to CLKS2VBLANK (so at most it can be the max clocks to vblank)
+ EMU_MESSAGE("Total Clocks: %TOTALCLKS%");
+
+ // CLKS2VBLANK
+ EMU_MESSAGE("Clocks until VBLANK: %CLKS2VBLANK%");
+
+ // Which Banks are currently active (for MBC based cartridges)
+ EMU_MESSAGE("Current ROM bank: %ROMBANK%");
+ EMU_MESSAGE("Current SRAM bank: %SRAMBANK%");
+ // These are not banked on DMG/MGB Game Boys
+ EMU_MESSAGE("Current VRAM bank: %VRAMBANK%");
+ EMU_MESSAGE("Current WRAM bank: %WRAMBANK%");
+
+ // Registers (All in this case, or individual ones)
+ EMU_MESSAGE("All Registers: %ALLREGS%");
+
+ // Simple addition with a register
+ EMU_MESSAGE("Register A + 1: %(A+1)%");
+
+ // Note: %SCANLINE% is available in Emulicious (for SMS/GG/GB/GBC) but not BGB
+ EMU_MESSAGE("Current Scanline: %SCANLINE%");
+
+ #if defined(NINTENDO)
+ // Read the LY Register a couple times
+ // (Current Y coordinate being rendered to the LCD)
+ EMU_MESSAGE("LY Register (0xFF44): %($ff44)%");
+ EMU_MESSAGE("LY Register (0xFF44): %($ff44)%");
+ // Now print a conditional debug message using it
+ EMU_MESSAGE("Is LY Register > Line 67: %($ff44)>67%Yes;No;");
+ #endif
+
+
+ #if defined(NINTENDO)
+ // Print some profile info using a built-in function.
+ EMU_MESSAGE("The following lines contain: PROFILE,(SP+$0),(SP+$1),A,TOTALCLKS,ROMBANK,WRAMBANK");
+
+ EMU_profiler_message();
+
+ // It's equivalent to:
+ EMU_MESSAGE("PROFILE,%(SP+$0)%,%(SP+$1)%,%A%,%TOTALCLKS%,%ROMBANK%,%WRAMBANK%");
+
+ #elif defined(SEGA)
+ EMU_MESSAGE("PROFILE,%(SP+$0)%,%(SP+$1)%,%A%,%TOTALCLKS%,%ROMBANK%,%WRAMBANK%");
+ #endif
+
+ uint8_t var0 = 16;
+ int16_t var1 = -10;
+ EMU_printf("var0: %hd; var1: %d; var0*var1=%d", (uint8_t)var0, var1, var0 * var1);
+
+ // The EMU_TEXT() macro will accept a non-quoted string
+ EMU_TEXT("The End");
+
+ return 0;
+}
diff --git a/gbdk/gbdk-lib/examples/cross-platform/fonts/Makefile b/gbdk/gbdk-lib/examples/cross-platform/fonts/Makefile
new file mode 100644
index 00000000..a0e47e22
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/fonts/Makefile
@@ -0,0 +1,78 @@
+# If you move this project you can change the directory
+# to match your GBDK root directory (ex: GBDK_HOME = "C:/GBDK/"
+GBDK_HOME = ../../../
+LCC = $(GBDK_HOME)bin/lcc
+
+# Set platforms to build here, spaced separated. (These are in the separate Makefile.targets)
+# They can also be built/cleaned individually: "make gg" and "make gg-clean"
+# Possible are: gb gbc pocket megaduck sms gg
+TARGETS=gb pocket megaduck sms gg
+
+# Configure platform specific LCC flags here:
+LCCFLAGS_gb = -Wl-yt0x1B # Set an MBC for banking (1B-ROM+MBC5+RAM+BATT)
+LCCFLAGS_pocket = -Wl-yt0x1B # Usually the same as required for .gb
+LCCFLAGS_duck = -Wl-yt0x1B # Usually the same as required for .gb
+LCCFLAGS_gbc = -Wl-yt0x1B -Wm-yc # Same as .gb with: -Wm-yc (gb & gbc) or Wm-yC (gbc exclusive)
+LCCFLAGS_sms =
+LCCFLAGS_gg =
+
+LCCFLAGS += $(LCCFLAGS_$(EXT)) # This adds the current platform specific LCC Flags
+
+LCCFLAGS += -Wl-j -Wm-yoA -Wm-ya4 -autobank -Wb-ext=.rel -Wb-v # MBC + Autobanking related flags
+# LCCFLAGS += -debug # Uncomment to enable debug output
+# LCCFLAGS += -v # Uncomment for lcc verbose output
+
+# You can set the name of the ROM file here
+PROJECTNAME = fonts
+
+# EXT?=gb # Only sets extension to default (game boy .gb) if not populated
+SRCDIR = src
+OBJDIR = obj/$(EXT)
+RESDIR = res
+BINDIR = build/$(EXT)
+MKDIRS = $(OBJDIR) $(BINDIR) # See bottom of Makefile for directory auto-creation
+
+BINS = $(OBJDIR)/$(PROJECTNAME).$(EXT)
+CSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.c))) $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.c)))
+ASMSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.s)))
+OBJS = $(CSOURCES:%.c=$(OBJDIR)/%.o) $(ASMSOURCES:%.s=$(OBJDIR)/%.o)
+
+# Builds all targets sequentially
+all: $(TARGETS)
+
+# Compile .c files in "src/" to .o object files
+$(OBJDIR)/%.o: $(SRCDIR)/%.c
+ $(LCC) $(CFLAGS) -c -o $@ $<
+
+# Compile .c files in "res/" to .o object files
+$(OBJDIR)/%.o: $(RESDIR)/%.c
+ $(LCC) $(CFLAGS) -c -o $@ $<
+
+# Compile .s assembly files in "src/" to .o object files
+$(OBJDIR)/%.o: $(SRCDIR)/%.s
+ $(LCC) $(CFLAGS) -c -o $@ $<
+
+# If needed, compile .c files i n"src/" to .s assembly files
+# (not required if .c is compiled directly to .o)
+$(OBJDIR)/%.s: $(SRCDIR)/%.c
+ $(LCC) $(CFLAGS) -S -o $@ $<
+
+# Link the compiled object files into a .gb ROM file
+$(BINS): $(OBJS)
+ $(LCC) $(LCCFLAGS) $(CFLAGS) -o $(BINDIR)/$(PROJECTNAME).$(EXT) $(OBJS)
+
+clean:
+ @echo Cleaning
+ @for target in $(TARGETS); do \
+ $(MAKE) $$target-clean; \
+ done
+
+# Include available build targets
+include Makefile.targets
+
+
+# create necessary directories after Makefile is parsed but before build
+# info prevents the command from being pasted into the makefile
+ifneq ($(strip $(EXT)),) # Only make the directories if EXT has been set by a target
+$(info $(shell mkdir -p $(MKDIRS)))
+endif
diff --git a/gbdk/gbdk-lib/examples/cross-platform/fonts/Makefile.targets b/gbdk/gbdk-lib/examples/cross-platform/fonts/Makefile.targets
new file mode 100644
index 00000000..c502f12f
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/fonts/Makefile.targets
@@ -0,0 +1,50 @@
+
+# Platform specific flags for compiling (only populate if they're both present)
+ifneq ($(strip $(PORT)),)
+ifneq ($(strip $(PLAT)),)
+CFLAGS += -m$(PORT):$(PLAT)
+endif
+endif
+
+# Called by the individual targets below to build a ROM
+build-target: $(BINS)
+
+clean-target:
+ rm -rf $(OBJDIR)
+ rm -rf $(BINDIR)
+
+gb-clean:
+ ${MAKE} clean-target EXT=gb
+gb:
+ ${MAKE} build-target PORT=sm83 PLAT=gb EXT=gb
+
+
+gbc-clean:
+ ${MAKE} clean-target EXT=gbc
+gbc:
+ ${MAKE} build-target PORT=sm83 PLAT=gb EXT=gbc
+
+
+pocket-clean:
+ ${MAKE} clean-target EXT=pocket
+pocket:
+ ${MAKE} build-target PORT=sm83 PLAT=ap EXT=pocket
+
+
+megaduck-clean:
+ ${MAKE} clean-target EXT=duck
+megaduck:
+ ${MAKE} build-target PORT=sm83 PLAT=duck EXT=duck
+
+
+sms-clean:
+ ${MAKE} clean-target EXT=sms
+sms:
+ ${MAKE} build-target PORT=z80 PLAT=sms EXT=sms
+
+
+gg-clean:
+ ${MAKE} clean-target EXT=gg
+gg:
+ ${MAKE} build-target PORT=z80 PLAT=gg EXT=gg
+
diff --git a/gbdk/gbdk-lib/examples/cross-platform/fonts/src/fonts.c b/gbdk/gbdk-lib/examples/cross-platform/fonts/src/fonts.c
new file mode 100644
index 00000000..23655163
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/fonts/src/fonts.c
@@ -0,0 +1,61 @@
+/*
+ fonts.c
+ Simple example of how to use multiple fonts on the GB
+ Michael Hope, 1999.
+*/
+
+#include <stdio.h>
+
+#include <gbdk/platform.h>
+#include <gbdk/font.h>
+
+#include <gbdk/console.h>
+
+#define WHITE 3
+#define DKGREY 1
+
+void main(void)
+{
+ font_t ibm_font, italic_font, min_font;
+ int i;
+
+ /* First, init the font system */
+ font_init();
+
+ /* Load all the fonts that we can */
+ ibm_font = font_load(font_ibm); /* 96 tiles */
+ italic_font = font_load(font_italic); /* 93 tiles */
+
+ /* Load this one with dk grey background and white foreground */
+ font_color(WHITE, DKGREY);
+
+ min_font = font_load(font_min);
+
+ /* Turn scrolling off (why not?) */
+ mode(get_mode() | M_NO_SCROLL);
+
+ /* Print some text! */
+
+ /* IBM font */
+ font_set(ibm_font);
+ printf("Font demo.\n\n");
+
+ printf("IBM Font #!?123\n");
+
+ /* In italic */
+ font_set(italic_font);
+ for (i=1; i!=5; i++) {
+ printf("In italics, line %u\n", i);
+ }
+
+ /* With a minimal, colour changed font */
+ font_set(min_font);
+ printf("Minimal 36 tile font\n");
+
+ /* Done */
+ font_set(ibm_font);
+ printf("\nDone!");
+}
+
+
+
diff --git a/gbdk/gbdk-lib/examples/cross-platform/gbdecompress/Makefile b/gbdk/gbdk-lib/examples/cross-platform/gbdecompress/Makefile
new file mode 100644
index 00000000..6d4c421a
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/gbdecompress/Makefile
@@ -0,0 +1,105 @@
+# If you move this project you can change the directory
+# to match your GBDK root directory (ex: GBDK_HOME = "C:/GBDK/"
+GBDK_HOME = ../../../
+LCC = $(GBDK_HOME)bin/lcc
+PNG2ASSET = $(GBDK_HOME)/bin/png2asset
+
+# Set platforms to build here, spaced separated. (These are in the separate Makefile.targets)
+# They can also be built/cleaned individually: "make gg" and "make gg-clean"
+# Possible are: gb gbc pocket megaduck sms gg
+TARGETS=gb pocket megaduck sms gg
+
+# Configure platform specific LCC flags here:
+LCCFLAGS_gb = -Wl-yt0x1B # Set an MBC for banking (1B-ROM+MBC5+RAM+BATT)
+LCCFLAGS_pocket = -Wl-yt0x1B # Usually the same as required for .gb
+LCCFLAGS_duck = -Wl-yt0x1B # Usually the same as required for .gb
+LCCFLAGS_gbc = -Wl-yt0x1B -Wm-yc # Same as .gb with: -Wm-yc (gb & gbc) or Wm-yC (gbc exclusive)
+LCCFLAGS_sms =
+LCCFLAGS_gg =
+
+LCCFLAGS += $(LCCFLAGS_$(EXT)) # This adds the current platform specific LCC Flags
+
+LCCFLAGS += -Wl-j -Wm-yoA -Wm-ya4 -autobank -Wb-ext=.rel -Wb-v # MBC + Autobanking related flags
+# LCCFLAGS += -debug # Uncomment to enable debug output
+# LCCFLAGS += -v # Uncomment for lcc verbose output
+
+# Add directory where platform specific meta tile sprites get converted into (obj/<platform ext>/src)
+# So they can be included with "#include <res/somefile.h>"
+CFLAGS += -I$(OBJDIR)
+
+# You can set the name of the ROM file here
+PROJECTNAME = gbdecompress
+
+SRCDIR = src
+OBJDIR = obj/$(EXT)
+RESOBJSRC = obj/$(EXT)/res
+RESDIR = res
+BINDIR = build/$(EXT)
+MKDIRS = $(OBJDIR) $(BINDIR) $(RESOBJSRC) # See bottom of Makefile for directory auto-creation
+
+BINS = $(OBJDIR)/$(PROJECTNAME).$(EXT)
+# For png2asset: converting metasprite source pngs -> .c -> .o
+METAPNGS = $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.png)))
+METASRCS = $(METAPNGS:%.png=$(RESOBJSRC)/%.c)
+METAOBJS = $(METASRCS:$(RESOBJSRC)/%.c=$(OBJDIR)/%.o)
+
+CSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.c))) $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.c)))
+ASMSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.s)))
+OBJS = $(CSOURCES:%.c=$(OBJDIR)/%.o) $(ASMSOURCES:%.s=$(OBJDIR)/%.o)
+
+
+# Builds all targets sequentially
+all: $(TARGETS)
+
+# Use png2asset to convert the png into C formatted metasprite data
+# -sh 48 : Sets sprite height to 48 (width remains automatic)
+# -spr8x16 : Use 8x16 hardware sprites
+# -c ... : Set C output file
+# Convert metasprite .pngs in res/ -> .c files in obj/<platform ext>/src/
+$(RESOBJSRC)/%.c: $(RESDIR)/%.png
+ $(PNG2ASSET) $< -sh 48 -spr8x16 -noflip -c $@
+
+# Compile the Metasprite pngs that were converted to .c files
+# .c files in obj/<platform ext>/src/ -> .o files in obj/
+$(OBJDIR)/%.o: $(RESOBJSRC)/%.c
+ $(LCC) $(CFLAGS) -c -o $@ $<
+
+# Compile .c files in "src/" to .o object files
+$(OBJDIR)/%.o: $(SRCDIR)/%.c
+ $(LCC) $(CFLAGS) -c -o $@ $<
+
+# Compile .c files in "res/" to .o object files
+$(OBJDIR)/%.o: $(RESDIR)/%.c
+ $(LCC) $(CFLAGS) -c -o $@ $<
+
+# Compile .s assembly files in "src/" to .o object files
+$(OBJDIR)/%.o: $(SRCDIR)/%.s
+ $(LCC) $(CFLAGS) -c -o $@ $<
+
+# If needed, compile .c files i n"src/" to .s assembly files
+# (not required if .c is compiled directly to .o)
+$(OBJDIR)/%.s: $(SRCDIR)/%.c
+ $(LCC) $(CFLAGS) -S -o $@ $<
+
+# Convert and build MetaSprites first so they're available when compiling the main sources
+$(OBJS): $(METAOBJS)
+
+# Link the compiled object files into a .gb ROM file
+$(BINS): $(OBJS)
+ $(LCC) $(LCCFLAGS) $(CFLAGS) -o $(BINDIR)/$(PROJECTNAME).$(EXT) $(METAOBJS) $(OBJS)
+
+clean:
+ @echo Cleaning
+ @for target in $(TARGETS); do \
+ $(MAKE) $$target-clean; \
+ done
+
+# Include available build targets
+include Makefile.targets
+
+
+# create necessary directories after Makefile is parsed but before build
+# info prevents the command from being pasted into the makefile
+ifneq ($(strip $(EXT)),) # Only make the directories if EXT has been set by a target
+$(info $(shell mkdir -p $(MKDIRS)))
+endif
diff --git a/gbdk/gbdk-lib/examples/cross-platform/gbdecompress/Makefile.targets b/gbdk/gbdk-lib/examples/cross-platform/gbdecompress/Makefile.targets
new file mode 100644
index 00000000..c502f12f
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/gbdecompress/Makefile.targets
@@ -0,0 +1,50 @@
+
+# Platform specific flags for compiling (only populate if they're both present)
+ifneq ($(strip $(PORT)),)
+ifneq ($(strip $(PLAT)),)
+CFLAGS += -m$(PORT):$(PLAT)
+endif
+endif
+
+# Called by the individual targets below to build a ROM
+build-target: $(BINS)
+
+clean-target:
+ rm -rf $(OBJDIR)
+ rm -rf $(BINDIR)
+
+gb-clean:
+ ${MAKE} clean-target EXT=gb
+gb:
+ ${MAKE} build-target PORT=sm83 PLAT=gb EXT=gb
+
+
+gbc-clean:
+ ${MAKE} clean-target EXT=gbc
+gbc:
+ ${MAKE} build-target PORT=sm83 PLAT=gb EXT=gbc
+
+
+pocket-clean:
+ ${MAKE} clean-target EXT=pocket
+pocket:
+ ${MAKE} build-target PORT=sm83 PLAT=ap EXT=pocket
+
+
+megaduck-clean:
+ ${MAKE} clean-target EXT=duck
+megaduck:
+ ${MAKE} build-target PORT=sm83 PLAT=duck EXT=duck
+
+
+sms-clean:
+ ${MAKE} clean-target EXT=sms
+sms:
+ ${MAKE} build-target PORT=z80 PLAT=sms EXT=sms
+
+
+gg-clean:
+ ${MAKE} clean-target EXT=gg
+gg:
+ ${MAKE} build-target PORT=z80 PLAT=gg EXT=gg
+
diff --git a/gbdk/gbdk-lib/examples/cross-platform/gbdecompress/Readme.md b/gbdk/gbdk-lib/examples/cross-platform/gbdecompress/Readme.md
new file mode 100644
index 00000000..7f21a65e
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/gbdecompress/Readme.md
@@ -0,0 +1,8 @@
+
+GBDecompress
+============
+
+Demonstrates using gbdecompress to load a compressed tile set into vram.
+
+The tileset was compressed during export from GBTD by checking the
+GB-compress checkbox in the export settings panel.
diff --git a/gbdk/gbdk-lib/examples/cross-platform/gbdecompress/res/monalisa.gbm b/gbdk/gbdk-lib/examples/cross-platform/gbdecompress/res/monalisa.gbm
new file mode 100644
index 00000000..a21dfeeb
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/gbdecompress/res/monalisa.gbm
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/cross-platform/gbdecompress/res/monalisa_tiles.gbr b/gbdk/gbdk-lib/examples/cross-platform/gbdecompress/res/monalisa_tiles.gbr
new file mode 100644
index 00000000..821f2928
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/gbdecompress/res/monalisa_tiles.gbr
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/cross-platform/gbdecompress/src/main.c b/gbdk/gbdk-lib/examples/cross-platform/gbdecompress/src/main.c
new file mode 100644
index 00000000..16e35f54
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/gbdecompress/src/main.c
@@ -0,0 +1,43 @@
+#include <gbdk/platform.h>
+#include <gbdk/gbdecompress.h>
+
+#include <stdint.h>
+
+// Include graphics data
+#include "monalisa_tiles_comp.h"
+#include "monalisa_map.h"
+
+// The map tiles were exported from GBTD with compression enabled
+// using this updated version of GBTD: https://github.com/untoxa/GBTD_GBMB
+// Size was 4096 bytes -> 3493 bytes
+
+uint8_t buffer[4096];
+
+void main(void)
+{
+ // Decompress the map tiles into the background tile vram.
+ //
+ // Notice that the number of tiles isn't specified. The amount
+ // of data to decompress is embedded in the compressed data.
+ //
+ // Note: For non-compressed data the equivalent would be: set_bkg_data(0, 253u, monalisa_tiles)
+ //
+ set_bkg_data(0, gb_decompress(monalisa_tiles_comp, buffer) >> 4, buffer);
+
+ // Now set the map and turn the background on
+ set_bkg_tiles(0,0, monalisa_mapWidth, monalisa_mapHeight, monalisa_mapPLN0);
+ SHOW_BKG;
+
+ // Loop forever
+ while(1) {
+
+ // Main loop processing goes here
+
+ // Done processing, yield CPU and wait for start of next frame
+ wait_vbl_done();
+ }
+}
+
+
+
+
diff --git a/gbdk/gbdk-lib/examples/cross-platform/gbdecompress/src/monalisa_map.c b/gbdk/gbdk-lib/examples/cross-platform/gbdecompress/src/monalisa_map.c
new file mode 100644
index 00000000..c110ae15
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/gbdecompress/src/monalisa_map.c
@@ -0,0 +1,66 @@
+/*
+
+ MONALISA_MAP.C
+
+ Map Source File.
+
+ Info:
+ Section :
+ Bank : 0
+ Map size : 20 x 18
+ Tile set : monalisa_tiles.gbr
+ Plane count : 1 plane (8 bits)
+ Plane order : Planes are continues
+ Tile offset : 0
+ Split data : No
+
+ This file was generated by GBMB v1.8
+
+*/
+
+#define monalisa_mapWidth 20
+#define monalisa_mapHeight 18
+#define monalisa_mapBank 0
+
+#define monalisa_map monalisa_mapPLN0
+const unsigned char monalisa_mapPLN0[] =
+{
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02,
+ 0x03,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x06,0x07,
+ 0x08,0x09,0x0A,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x0B,0x0C,0x0D,0x0E,
+ 0x0F,0x10,0x11,0x12,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x13,0x14,0x00,0x00,0x00,0x00,0x15,0x16,0x00,0x17,
+ 0x18,0x19,0x1A,0x1B,0x1C,0x13,0x00,0x00,0x00,0x00,
+ 0x1D,0x1E,0x1F,0x20,0x21,0x00,0x22,0x23,0x24,0x25,
+ 0x26,0x27,0x1A,0x28,0x29,0x2A,0x2B,0x00,0x00,0x00,
+ 0x2C,0x2D,0x2E,0x2F,0x30,0x31,0x32,0x33,0x34,0x35,
+ 0x36,0x37,0x1A,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,
+ 0x3F,0x40,0x41,0x41,0x42,0x43,0x44,0x45,0x46,0x47,
+ 0x48,0x49,0x1A,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F,0x50,
+ 0x51,0x52,0x41,0x53,0x54,0x55,0x56,0x57,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A,0x1A,0x1A,0x1A,
+ 0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0xFC
+};
+
+/* End of MONALISA_MAP.C */
diff --git a/gbdk/gbdk-lib/examples/cross-platform/gbdecompress/src/monalisa_map.h b/gbdk/gbdk-lib/examples/cross-platform/gbdecompress/src/monalisa_map.h
new file mode 100644
index 00000000..f094a2d3
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/gbdecompress/src/monalisa_map.h
@@ -0,0 +1,32 @@
+/*
+
+ MONALISA_MAP.H
+
+ Map Include File.
+
+ Info:
+ Section :
+ Bank : 0
+ Map size : 20 x 18
+ Tile set : monalisa_tiles.gbr
+ Plane count : 1 plane (8 bits)
+ Plane order : Planes are continues
+ Tile offset : 0
+ Split data : No
+
+ This file was generated by GBMB v1.8
+
+*/
+#ifndef __monalisa_map_h_INCLUDE
+#define __monalisa_map_h_INCLUDE
+
+#define monalisa_mapWidth 20
+#define monalisa_mapHeight 18
+#define monalisa_mapBank 0
+
+#define monalisa_map monalisa_mapPLN0
+extern const unsigned char monalisa_mapPLN0[];
+
+#endif
+
+/* End of MONALISA_MAP.H */
diff --git a/gbdk/gbdk-lib/examples/cross-platform/gbdecompress/src/monalisa_tiles_comp.c b/gbdk/gbdk-lib/examples/cross-platform/gbdecompress/src/monalisa_tiles_comp.c
new file mode 100644
index 00000000..37aae936
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/gbdecompress/src/monalisa_tiles_comp.c
@@ -0,0 +1,467 @@
+/*
+
+ MONALISA_TILES_COMP.C
+
+ Tile Source File.
+
+ Info:
+ Form : All tiles as one unit.
+ Format : Gameboy 4 color.
+ Compression : GB-Compress.
+ Counter : None.
+ Tile size : 8 x 8
+ Tiles : 0 to 252
+
+ Palette colors : Included.
+ SGB Palette : None.
+ CGB Palette : None.
+
+ Convert to metatiles : No.
+
+ This file was generated by GBTD v2.2
+
+*/
+
+/* Start of tile array. */
+const unsigned char monalisa_tiles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F,0x84,0x20,0xFE,0x85,0x4C,
+ 0xF1,0xC4,0xE0,0xFF,0xC8,0xF7,0xE0,0x84,
+ 0x2C,0xF3,0xC0,0xF4,0x84,0x28,0xFC,0x83,
+ 0xD4,0xF4,0x83,0xD0,0xF8,0xC1,0x14,0xEB,
+ 0x83,0x98,0xF8,0xC4,0x01,0xFF,0x3E,0xFF,
+ 0x0C,0x84,0x48,0xFE,0x85,0x90,0xF7,0xC1,
+ 0x80,0x7F,0x85,0x34,0xF5,0xC6,0x08,0xF7,
+ 0xA2,0xFF,0x01,0xFF,0x2F,0x84,0x28,0xF7,
+ 0xC4,0x0D,0xFF,0xBF,0xFF,0x15,0x8A,0x28,
+ 0xF7,0x85,0xF8,0xFD,0xC6,0xFF,0xFF,0xED,
+ 0xFF,0xFF,0xFF,0x50,0x86,0x88,0xFF,0x83,
+ 0x64,0xF5,0xC6,0x81,0xFF,0xFE,0xFF,0x01,
+ 0xFF,0xA2,0x84,0x4C,0xF8,0xC2,0x50,0xFF,
+ 0xEA,0x83,0xFC,0xFF,0xC2,0xFF,0xD0,0xFF,
+ 0x00
+};
+
+/* End of MONALISA_TILES_COMP.C */
diff --git a/gbdk/gbdk-lib/examples/cross-platform/gbdecompress/src/monalisa_tiles_comp.h b/gbdk/gbdk-lib/examples/cross-platform/gbdecompress/src/monalisa_tiles_comp.h
new file mode 100644
index 00000000..747d28ca
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/gbdecompress/src/monalisa_tiles_comp.h
@@ -0,0 +1,107 @@
+/*
+
+ MONALISA_TILES_COMP.H
+
+ Include File.
+
+ Info:
+ Form : All tiles as one unit.
+ Format : Gameboy 4 color.
+ Compression : GB-Compress.
+ Counter : None.
+ Tile size : 8 x 8
+ Tiles : 0 to 252
+
+ Palette colors : Included.
+ SGB Palette : None.
+ CGB Palette : None.
+
+ Convert to metatiles : No.
+
+ This file was generated by GBTD v2.2
+
+*/
+
+#ifndef __monalisa_tiles_comp_h_INCLUDE
+#define __monalisa_tiles_comp_h_INCLUDE
+
+/* Bank of tiles. */
+#define monalisa_tiles_compBank 0
+
+/* Super Gameboy palette 0 */
+#define monalisa_tiles_compSGBPal0c0 0
+#define monalisa_tiles_compSGBPal0c1 0
+#define monalisa_tiles_compSGBPal0c2 18432
+#define monalisa_tiles_compSGBPal0c3 749
+
+/* Super Gameboy palette 1 */
+#define monalisa_tiles_compSGBPal1c0 6076
+#define monalisa_tiles_compSGBPal1c1 8935
+#define monalisa_tiles_compSGBPal1c2 6596
+#define monalisa_tiles_compSGBPal1c3 5344
+
+/* Super Gameboy palette 2 */
+#define monalisa_tiles_compSGBPal2c0 6076
+#define monalisa_tiles_compSGBPal2c1 8935
+#define monalisa_tiles_compSGBPal2c2 6596
+#define monalisa_tiles_compSGBPal2c3 5344
+
+/* Super Gameboy palette 3 */
+#define monalisa_tiles_compSGBPal3c0 6076
+#define monalisa_tiles_compSGBPal3c1 8935
+#define monalisa_tiles_compSGBPal3c2 6596
+#define monalisa_tiles_compSGBPal3c3 5344
+
+/* Gameboy Color palette 0 */
+#define monalisa_tiles_compCGBPal0c0 4228
+#define monalisa_tiles_compCGBPal0c1 11627
+#define monalisa_tiles_compCGBPal0c2 20083
+#define monalisa_tiles_compCGBPal0c3 30653
+
+/* Gameboy Color palette 1 */
+#define monalisa_tiles_compCGBPal1c0 6076
+#define monalisa_tiles_compCGBPal1c1 8935
+#define monalisa_tiles_compCGBPal1c2 6596
+#define monalisa_tiles_compCGBPal1c3 5344
+
+/* Gameboy Color palette 2 */
+#define monalisa_tiles_compCGBPal2c0 6076
+#define monalisa_tiles_compCGBPal2c1 8935
+#define monalisa_tiles_compCGBPal2c2 6596
+#define monalisa_tiles_compCGBPal2c3 5344
+
+/* Gameboy Color palette 3 */
+#define monalisa_tiles_compCGBPal3c0 6076
+#define monalisa_tiles_compCGBPal3c1 8935
+#define monalisa_tiles_compCGBPal3c2 6596
+#define monalisa_tiles_compCGBPal3c3 5344
+
+/* Gameboy Color palette 4 */
+#define monalisa_tiles_compCGBPal4c0 6076
+#define monalisa_tiles_compCGBPal4c1 8935
+#define monalisa_tiles_compCGBPal4c2 6596
+#define monalisa_tiles_compCGBPal4c3 5344
+
+/* Gameboy Color palette 5 */
+#define monalisa_tiles_compCGBPal5c0 6076
+#define monalisa_tiles_compCGBPal5c1 8935
+#define monalisa_tiles_compCGBPal5c2 6596
+#define monalisa_tiles_compCGBPal5c3 5344
+
+/* Gameboy Color palette 6 */
+#define monalisa_tiles_compCGBPal6c0 6076
+#define monalisa_tiles_compCGBPal6c1 8935
+#define monalisa_tiles_compCGBPal6c2 6596
+#define monalisa_tiles_compCGBPal6c3 5344
+
+/* Gameboy Color palette 7 */
+#define monalisa_tiles_compCGBPal7c0 6076
+#define monalisa_tiles_compCGBPal7c1 8935
+#define monalisa_tiles_compCGBPal7c2 6596
+#define monalisa_tiles_compCGBPal7c3 5344
+/* Start of tile array. */
+extern const unsigned char monalisa_tiles_comp[];
+
+#endif
+
+/* End of MONALISA_TILES_COMP.H */
diff --git a/gbdk/gbdk-lib/examples/cross-platform/incbin/Makefile b/gbdk/gbdk-lib/examples/cross-platform/incbin/Makefile
new file mode 100644
index 00000000..c5ae7dfe
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/incbin/Makefile
@@ -0,0 +1,78 @@
+# If you move this project you can change the directory
+# to match your GBDK root directory (ex: GBDK_HOME = "C:/GBDK/"
+GBDK_HOME = ../../../
+LCC = $(GBDK_HOME)bin/lcc
+
+# Set platforms to build here, spaced separated. (These are in the separate Makefile.targets)
+# They can also be built/cleaned individually: "make gg" and "make gg-clean"
+# Possible are: gb gbc pocket megaduck sms gg
+TARGETS=gb pocket megaduck sms gg
+
+# Configure platform specific LCC flags here:
+LCCFLAGS_gb = -Wl-yt0x1B # Set an MBC for banking (1B-ROM+MBC5+RAM+BATT)
+LCCFLAGS_pocket = -Wl-yt0x1B # Usually the same as required for .gb
+LCCFLAGS_duck = -Wl-yt0x1B # Usually the same as required for .gb
+LCCFLAGS_gbc = -Wl-yt0x1B -Wm-yc # Same as .gb with: -Wm-yc (gb & gbc) or Wm-yC (gbc exclusive)
+LCCFLAGS_sms =
+LCCFLAGS_gg =
+
+LCCFLAGS += $(LCCFLAGS_$(EXT)) # This adds the current platform specific LCC Flags
+
+LCCFLAGS += -Wl-j -Wm-yoA -Wm-ya4 -autobank -Wb-ext=.rel -Wb-v # MBC + Autobanking related flags
+# LCCFLAGS += -debug # Uncomment to enable debug output
+# LCCFLAGS += -v # Uncomment for lcc verbose output
+
+# You can set the name of the ROM file here
+PROJECTNAME = incbin
+
+# EXT?=gb # Only sets extension to default (game boy .gb) if not populated
+SRCDIR = src
+OBJDIR = obj/$(EXT)
+RESDIR = res
+BINDIR = build/$(EXT)
+MKDIRS = $(OBJDIR) $(BINDIR) # See bottom of Makefile for directory auto-creation
+
+BINS = $(OBJDIR)/$(PROJECTNAME).$(EXT)
+CSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.c))) $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.c)))
+ASMSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.s)))
+OBJS = $(CSOURCES:%.c=$(OBJDIR)/%.o) $(ASMSOURCES:%.s=$(OBJDIR)/%.o)
+
+# Builds all targets sequentially
+all: $(TARGETS)
+
+# Compile .c files in "src/" to .o object files
+$(OBJDIR)/%.o: $(SRCDIR)/%.c
+ $(LCC) $(CFLAGS) -c -o $@ $<
+
+# Compile .c files in "res/" to .o object files
+$(OBJDIR)/%.o: $(RESDIR)/%.c
+ $(LCC) $(CFLAGS) -c -o $@ $<
+
+# Compile .s assembly files in "src/" to .o object files
+$(OBJDIR)/%.o: $(SRCDIR)/%.s
+ $(LCC) $(CFLAGS) -c -o $@ $<
+
+# If needed, compile .c files i n"src/" to .s assembly files
+# (not required if .c is compiled directly to .o)
+$(OBJDIR)/%.s: $(SRCDIR)/%.c
+ $(LCC) $(CFLAGS) -S -o $@ $<
+
+# Link the compiled object files into a .gb ROM file
+$(BINS): $(OBJS)
+ $(LCC) $(LCCFLAGS) $(CFLAGS) -o $(BINDIR)/$(PROJECTNAME).$(EXT) $(OBJS)
+
+clean:
+ @echo Cleaning
+ @for target in $(TARGETS); do \
+ $(MAKE) $$target-clean; \
+ done
+
+# Include available build targets
+include Makefile.targets
+
+
+# create necessary directories after Makefile is parsed but before build
+# info prevents the command from being pasted into the makefile
+ifneq ($(strip $(EXT)),) # Only make the directories if EXT has been set by a target
+$(info $(shell mkdir -p $(MKDIRS)))
+endif
diff --git a/gbdk/gbdk-lib/examples/cross-platform/incbin/Makefile.targets b/gbdk/gbdk-lib/examples/cross-platform/incbin/Makefile.targets
new file mode 100644
index 00000000..c502f12f
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/incbin/Makefile.targets
@@ -0,0 +1,50 @@
+
+# Platform specific flags for compiling (only populate if they're both present)
+ifneq ($(strip $(PORT)),)
+ifneq ($(strip $(PLAT)),)
+CFLAGS += -m$(PORT):$(PLAT)
+endif
+endif
+
+# Called by the individual targets below to build a ROM
+build-target: $(BINS)
+
+clean-target:
+ rm -rf $(OBJDIR)
+ rm -rf $(BINDIR)
+
+gb-clean:
+ ${MAKE} clean-target EXT=gb
+gb:
+ ${MAKE} build-target PORT=sm83 PLAT=gb EXT=gb
+
+
+gbc-clean:
+ ${MAKE} clean-target EXT=gbc
+gbc:
+ ${MAKE} build-target PORT=sm83 PLAT=gb EXT=gbc
+
+
+pocket-clean:
+ ${MAKE} clean-target EXT=pocket
+pocket:
+ ${MAKE} build-target PORT=sm83 PLAT=ap EXT=pocket
+
+
+megaduck-clean:
+ ${MAKE} clean-target EXT=duck
+megaduck:
+ ${MAKE} build-target PORT=sm83 PLAT=duck EXT=duck
+
+
+sms-clean:
+ ${MAKE} clean-target EXT=sms
+sms:
+ ${MAKE} build-target PORT=z80 PLAT=sms EXT=sms
+
+
+gg-clean:
+ ${MAKE} clean-target EXT=gg
+gg:
+ ${MAKE} build-target PORT=z80 PLAT=gg EXT=gg
+
diff --git a/gbdk/gbdk-lib/examples/cross-platform/incbin/res/blanktile.bin b/gbdk/gbdk-lib/examples/cross-platform/incbin/res/blanktile.bin
new file mode 100644
index 00000000..01d633b2
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/incbin/res/blanktile.bin
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/cross-platform/incbin/res/blanktile.png b/gbdk/gbdk-lib/examples/cross-platform/incbin/res/blanktile.png
new file mode 100644
index 00000000..e364f322
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/incbin/res/blanktile.png
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/cross-platform/incbin/res/gbdk2020.bin b/gbdk/gbdk-lib/examples/cross-platform/incbin/res/gbdk2020.bin
new file mode 100644
index 00000000..84a52fcb
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/incbin/res/gbdk2020.bin
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/cross-platform/incbin/res/gbdk2020.png b/gbdk/gbdk-lib/examples/cross-platform/incbin/res/gbdk2020.png
new file mode 100644
index 00000000..6e13e499
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/incbin/res/gbdk2020.png
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/cross-platform/incbin/res/gbdk2020_map.bin b/gbdk/gbdk-lib/examples/cross-platform/incbin/res/gbdk2020_map.bin
new file mode 100644
index 00000000..36c4ca51
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/incbin/res/gbdk2020_map.bin
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/cross-platform/incbin/src/main.c b/gbdk/gbdk-lib/examples/cross-platform/incbin/src/main.c
new file mode 100644
index 00000000..6757ce29
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/incbin/src/main.c
@@ -0,0 +1,58 @@
+#include <gbdk/platform.h>
+#include <stdint.h>
+
+#include <gbdk/incbin.h>
+
+INCBIN(logo_tiles_data, "res/gbdk2020.bin") // Variable name to use, Path to file
+INCBIN_EXTERN(logo_tiles_data) // Extern declarations for binary data
+
+INCBIN(logo_map, "res/gbdk2020_map.bin")
+INCBIN_EXTERN(logo_map)
+
+INCBIN(blank_tile_data, "res/blanktile.bin")
+INCBIN_EXTERN(blank_tile_data)
+
+
+#define TILE_BYTES 16 // 16 bytes per background tile
+
+
+// Since incbin just includes a binary file (the logo tiles)
+// a map needs to be created for them. For this example
+// the tiles are non-deduplciated, so a array of incrementing
+// values can be used. There are 84 tiles.
+#define LOGO_MAP_WIDTH 7u
+#define LOGO_MAP_HEIGHT 12u
+#define LOGO_MAP_X (20u - LOGO_MAP_WIDTH) / 2u // Center on X axis
+#define LOGO_MAP_Y (18u - LOGO_MAP_HEIGHT) / 2u // Center on Y axis
+
+void init_gfx() {
+ // Load a single clear background tile at location 0x80 and clear/fill the map with it
+ set_bkg_data(0x80u, 1u, blank_tile_data); // The first 0x80u here is the tile ID
+ fill_bkg_rect(0u, 0u, DEVICE_SCREEN_WIDTH, DEVICE_SCREEN_HEIGHT, 0x80u); // The last 0x80u here is the tile ID
+
+ // Load logo background tiles and map
+ // They start at 0u
+ set_bkg_data(0u, INCBIN_SIZE(logo_tiles_data) / TILE_BYTES, logo_tiles_data);
+ set_bkg_tiles(LOGO_MAP_X, LOGO_MAP_Y,
+ LOGO_MAP_WIDTH, LOGO_MAP_HEIGHT,
+ logo_map);
+
+ // Turn the background map on to make it visible
+ SHOW_BKG;
+}
+
+
+
+void main(void)
+{
+ init_gfx();
+
+ // Loop forever
+ while(1) {
+
+ // Game main loop processing goes here
+
+ // Done processing, yield CPU and wait for start of next frame
+ wait_vbl_done();
+ }
+}
diff --git a/gbdk/gbdk-lib/examples/cross-platform/large_map/Makefile b/gbdk/gbdk-lib/examples/cross-platform/large_map/Makefile
new file mode 100644
index 00000000..9c9f6937
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/large_map/Makefile
@@ -0,0 +1,85 @@
+# If you move this project you can change the directory
+# to match your GBDK root directory (ex: GBDK_HOME = "C:/GBDK/"
+GBDK_HOME = ../../../
+LCC = $(GBDK_HOME)bin/lcc
+
+# Set platforms to build here, spaced separated. (These are in the separate Makefile.targets)
+# They can also be built/cleaned individually: "make gg" and "make gg-clean"
+# Possible are: gb gbc pocket megaduck sms gg
+TARGETS=gb gg
+
+# Configure platform specific LCC flags here:
+LCCFLAGS_gb = -Wl-yt0x1B # Set an MBC for banking (1B-ROM+MBC5+RAM+BATT)
+LCCFLAGS_pocket = -Wl-yt0x1B # Usually the same as required for .gb
+LCCFLAGS_duck = -Wl-yt0x1B # Usually the same as required for .gb
+LCCFLAGS_gbc = -Wl-yt0x1B -Wm-yc # Same as .gb with: -Wm-yc (gb & gbc) or Wm-yC (gbc exclusive)
+LCCFLAGS_sms =
+LCCFLAGS_gg =
+
+LCCFLAGS += $(LCCFLAGS_$(EXT)) # This adds the current platform specific LCC Flags
+
+LCCFLAGS += -Wl-j -Wm-yoA -Wm-ya4 -autobank -Wb-ext=.rel -Wb-v # MBC + Autobanking related flags
+# LCCFLAGS += -debug # Uncomment to enable debug output
+# LCCFLAGS += -v # Uncomment for lcc verbose output
+
+# You can set the name of the ROM file here
+PROJECTNAME = large-map
+
+CFLAGS = -Wf-MMD
+
+# EXT?=gb # Only sets extension to default (game boy .gb) if not populated
+SRCDIR = src
+OBJDIR = obj/$(EXT)
+RESDIR = res
+BINDIR = build/$(EXT)
+MKDIRS = $(OBJDIR) $(BINDIR) # See bottom of Makefile for directory auto-creation
+
+BINS = $(OBJDIR)/$(PROJECTNAME).$(EXT)
+CSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.c))) $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.c)))
+ASMSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.s)))
+OBJS = $(CSOURCES:%.c=$(OBJDIR)/%.o) $(ASMSOURCES:%.s=$(OBJDIR)/%.o)
+
+# Builds all targets sequentially
+all: $(TARGETS)
+
+# Dependencies
+DEPS = $(OBJS:%.o=%.d)
+
+-include $(DEPS)
+
+# Compile .c files in "src/" to .o object files
+$(OBJDIR)/%.o: $(SRCDIR)/%.c
+ $(LCC) $(CFLAGS) -c -o $@ $<
+
+# Compile .c files in "res/" to .o object files
+$(OBJDIR)/%.o: $(RESDIR)/%.c
+ $(LCC) $(CFLAGS) -c -o $@ $<
+
+# Compile .s assembly files in "src/" to .o object files
+$(OBJDIR)/%.o: $(SRCDIR)/%.s
+ $(LCC) $(CFLAGS) -c -o $@ $<
+
+# If needed, compile .c files i n"src/" to .s assembly files
+# (not required if .c is compiled directly to .o)
+$(OBJDIR)/%.s: $(SRCDIR)/%.c
+ $(LCC) $(CFLAGS) -S -o $@ $<
+
+# Link the compiled object files into a .gb ROM file
+$(BINS): $(OBJS)
+ $(LCC) $(LCCFLAGS) $(CFLAGS) -o $(BINDIR)/$(PROJECTNAME).$(EXT) $(OBJS)
+
+clean:
+ @echo Cleaning
+ @for target in $(TARGETS); do \
+ $(MAKE) $$target-clean; \
+ done
+
+# Include available build targets
+include Makefile.targets
+
+
+# create necessary directories after Makefile is parsed but before build
+# info prevents the command from being pasted into the makefile
+ifneq ($(strip $(EXT)),) # Only make the directories if EXT has been set by a target
+$(info $(shell mkdir -p $(MKDIRS)))
+endif
diff --git a/gbdk/gbdk-lib/examples/cross-platform/large_map/Makefile.targets b/gbdk/gbdk-lib/examples/cross-platform/large_map/Makefile.targets
new file mode 100644
index 00000000..c502f12f
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/large_map/Makefile.targets
@@ -0,0 +1,50 @@
+
+# Platform specific flags for compiling (only populate if they're both present)
+ifneq ($(strip $(PORT)),)
+ifneq ($(strip $(PLAT)),)
+CFLAGS += -m$(PORT):$(PLAT)
+endif
+endif
+
+# Called by the individual targets below to build a ROM
+build-target: $(BINS)
+
+clean-target:
+ rm -rf $(OBJDIR)
+ rm -rf $(BINDIR)
+
+gb-clean:
+ ${MAKE} clean-target EXT=gb
+gb:
+ ${MAKE} build-target PORT=sm83 PLAT=gb EXT=gb
+
+
+gbc-clean:
+ ${MAKE} clean-target EXT=gbc
+gbc:
+ ${MAKE} build-target PORT=sm83 PLAT=gb EXT=gbc
+
+
+pocket-clean:
+ ${MAKE} clean-target EXT=pocket
+pocket:
+ ${MAKE} build-target PORT=sm83 PLAT=ap EXT=pocket
+
+
+megaduck-clean:
+ ${MAKE} clean-target EXT=duck
+megaduck:
+ ${MAKE} build-target PORT=sm83 PLAT=duck EXT=duck
+
+
+sms-clean:
+ ${MAKE} clean-target EXT=sms
+sms:
+ ${MAKE} build-target PORT=z80 PLAT=sms EXT=sms
+
+
+gg-clean:
+ ${MAKE} clean-target EXT=gg
+gg:
+ ${MAKE} build-target PORT=z80 PLAT=gg EXT=gg
+
diff --git a/gbdk/gbdk-lib/examples/cross-platform/large_map/Readme.md b/gbdk/gbdk-lib/examples/cross-platform/large_map/Readme.md
new file mode 100644
index 00000000..5a88c78e
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/large_map/Readme.md
@@ -0,0 +1,14 @@
+
+Large Map
+=========
+
+Shows how to scroll with maps larger than 32 x 32 tiles using set_bkg_submap().
+
+It fills rows and columns at the edges of the visible viewport (of the hardware
+Background Map) with the desired sub-region of the large map as it scrolls.
+
+
+Overworld Map and Tiles are by ArMM1998:
+https://opengameart.org/content/gameboy-tileset
+License(s): CC0
+
diff --git a/gbdk/gbdk-lib/examples/cross-platform/large_map/src/bigmap_map.c b/gbdk/gbdk-lib/examples/cross-platform/large_map/src/bigmap_map.c
new file mode 100644
index 00000000..b433c25e
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/large_map/src/bigmap_map.c
@@ -0,0 +1,1661 @@
+/*
+
+ BIGMAP_MAP.C
+
+ Map Source File.
+
+ Info:
+ Section :
+ Bank : 0
+ Map size : 247 x 66
+ Tile set : bigmap_tiles.gbr
+ Plane count : 1 plane (8 bits)
+ Plane order : Planes are continues
+ Tile offset : 0
+ Split data : No
+
+ This file was generated by GBMB v1.8
+
+*/
+
+#define bigmap_mapWidth 247
+#define bigmap_mapHeight 66
+#define bigmap_mapBank 0
+
+#define bigmap_map bigmap_mapPLN0
+const unsigned char bigmap_mapPLN0[] =
+{
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x03,
+ 0x00,0x01,0x00,0x01,0x04,0x05,0x04,0x05,0x04,0x05,
+ 0x04,0x05,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x06,0x06,0x06,0x06,0x07,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x09,0x06,0x04,0x05,0x06,0x06,0x06,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x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0x06,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x30,0x3F,0x40,0x41,0x42,0x9B,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x17,0x18,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x0C,
+ 0x0D,0x0C,0x0D,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x02,0x03,0x06,0x06,0x06,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x01,0x02,0x03,0x00,0x01,0x12,0x13,0x00,0x01,
+ 0x02,0x03,0x06,0x06,0x02,0x03,0x00,0x01,0x1B,0x1C,
+ 0x1D,0x1E,0x1D,0x1E,0x1D,0x1E,0x1F,0x1F,0x1F,0x1F,
+ 0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x20,0x0B,0x0A,0x0B,
+ 0x06,0x04,0x05,0x06,0x06,0x06,0x06,0x06,0x14,0x15,
+ 0x21,0x22,0x16,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x23,0x21,0x22,0x24,0x25,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x02,0x03,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x02,0x03,0x06,0x06,0x00,0x01,0x02,0x03,
+ 0x00,0x01,0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x12,0x13,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x39,0x14,0x15,
+ 0x24,0x25,0x9B,0x03,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0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 0x0B,0x0A,0x0B,0x06,0x3C,0xA5,0xA5,0xA5,0xA5,0xA6,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x00,0x01,0x10,0x11,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x12,0x13,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x1A,0x06,0x06,0x06,0x02,0x03,
+ 0x02,0x03,0x02,0x03,0x00,0x01,0x06,0x2B,0x06,0x06,
+ 0x06,0x06,0x2B,0x06,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x02,0x03,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x02,0x03,0x2C,0x06,0x06,0x06,0x12,0x13,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x2D,0x04,0x05,0x04,0x04,0x04,0x04,0x05,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x14,0x15,0x21,0x22,
+ 0x21,0x22,0x21,0x22,0x21,0x22,0x21,0x22,0x24,0x25,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,
+ 0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x02,0x03,0x02,0x03,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,0x06,0x06,
+ 0x00,0x01,0x12,0x13,0x00,0x01,0x12,0x13,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x03,
+ 0x06,0xD8,0xDB,0xDB,0xDB,0xDB,0xDC,0x06,0x02,0x03,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x0A,
+ 0x0B,0x17,0x18,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x27,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x0A,0x0B,0x06,0x06,0x2E,0x2F,0x2E,0x2F,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x30,
+ 0x06,0x06,0x06,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x31,0x32,0x0C,0x0D,
+ 0x0C,0x0C,0x0C,0x0C,0x0D,0x06,0x06,0x06,0x06,0x06,
+ 0x05,0x04,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x04,
+ 0x05,0x06,0x06,0x04,0x05,0x06,0x06,0x06,0x06,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,0xD8,0xE1,
+ 0xE1,0xE1,0xE1,0xE2,0x06,0x06,0x06,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x00,0x01,0x06,0x06,
+ 0x10,0x11,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x02,0x03,0x02,0x03,0x33,0x19,
+ 0x34,0x06,0x06,0x06,0x06,0x06,0x12,0x13,0x00,0x01,
+ 0x06,0x35,0x36,0x36,0x36,0x36,0x2E,0x06,0x02,0x03,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x1B,0x1C,0x37,0x38,
+ 0x1D,0x1E,0x1D,0x1E,0x1D,0x1E,0x39,0x06,0x06,0x06,
+ 0x02,0x03,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x31,0x06,0x06,0x2D,0x12,0x13,0x04,0x05,0x04,
+ 0x05,0x06,0x06,0x06,0x06,0x05,0x05,0x0D,0x0C,0x05,
+ 0x04,0x06,0x06,0x06,0x06,0x06,0x04,0x05,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x0C,0x0D,0x04,0x05,
+ 0x0C,0x0D,0x04,0x05,0x06,0x06,0x02,0x03,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x02,0x03,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x02,0x03,0x02,0x03,0x06,0x31,
+ 0x06,0x06,0x02,0x03,0x02,0x03,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x12,0x13,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x02,0x03,0x44,0x45,0x06,0xD8,0x80,0x80,0x80,0x80,
+ 0xB6,0x06,0x06,0x06,0x02,0x03,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x0A,0x0B,0x06,0x06,0x17,0x18,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x06,0x06,0x06,0x06,0x3A,0x26,0x3B,0x06,0x06,
+ 0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x06,0x2F,0x36,
+ 0x36,0x36,0x36,0x2E,0x2F,0x06,0x06,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x29,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x3C,0x3D,0x3E,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x31,
+ 0x06,0x32,0x0A,0x0B,0x0C,0x0D,0x0C,0x0D,0x06,0x06,
+ 0x06,0x06,0x0D,0x0D,0x05,0x04,0x0D,0x0C,0x06,0x06,
+ 0x06,0x04,0x05,0x0C,0x0D,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x0C,0x0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x06,0x06,0x2D,0x02,
+ 0x03,0x04,0x05,0x04,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x0D,0x0C,0x06,0x06,0x06,0x06,0x06,0x0C,0x0D,
+ 0x06,0x06,0x06,0x06,0x48,0x49,0x4A,0x4B,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x04,0x05,0x04,0x05,
+ 0x06,0x06,0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x02,0x03,0x06,0x06,0x06,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,
+ 0x02,0x03,0x00,0x01,0x00,0x01,0x02,0x03,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x06,
+ 0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,
+ 0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x06,0x44,0x45,0x06,0x06,0x46,
+ 0x80,0x80,0x80,0x80,0xB6,0x06,0x06,0x06,0x44,0x45,
+ 0x02,0x03,0x00,0x01,0x02,0x03,0x00,0x0A,0x0B,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x4C,
+ 0x4D,0x4E,0x4F,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,
+ 0x06,0x06,0x2F,0x36,0x36,0x36,0x36,0x36,0x36,0x29,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x50,0x51,0x06,0x06,0x52,0x53,0x30,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x32,0x06,0x06,0x0C,0x0D,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x3F,0x40,0x54,0x55,0x54,0x55,0x54,0x55,
+ 0x55,0x56,0x57,0x58,0x59,0x55,0x55,0x54,0x55,0x54,
+ 0x55,0x41,0x42,0x0C,0x0D,0x0C,0x0D,0x04,0x05,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x06,0x06,0x06,0x06,0x06,0x12,0x13,0x02,0x03,
+ 0x02,0x03,0x02,0x03,0x12,0x13,0x06,0x06,0x06,0x0A,
+ 0x0B,0x0A,0x0B,0x06,0x31,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x06,0x50,0x51,0x06,0x06,0xDD,0xE1,0xE1,0xE1,
+ 0xE1,0xE2,0x06,0x06,0x31,0x50,0x51,0x06,0x06,0x0A,
+ 0x0B,0x06,0x06,0x0A,0x00,0x01,0x12,0x13,0x06,0x06,
+ 0x06,0x06,0x06,0x5A,0x19,0x19,0x19,0x19,0x1A,0x06,
+ 0x06,0x06,0x3F,0x40,0x54,0x55,0x5B,0x08,0x08,0x5C,
+ 0x02,0x03,0x02,0x03,0x02,0x03,0x06,0x06,0x06,0x35,
+ 0x36,0x36,0x36,0x36,0x36,0x36,0x2C,0x06,0x3F,0x40,
+ 0x54,0x55,0x41,0x42,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x2C,0x06,0x06,0x06,
+ 0x06,0x06,0x5D,0x5E,0x5F,0x60,0x61,0x62,0x06,0x06,
+ 0x06,0x06,0x2D,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x05,0x04,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x4C,
+ 0x4D,0x63,0x64,0x63,0x64,0x63,0x64,0x64,0x65,0x66,
+ 0x67,0x68,0x64,0x64,0x63,0x64,0x63,0x64,0x4E,0x09,
+ 0x06,0x06,0x04,0x05,0x0C,0x0D,0x06,0x06,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x03,0x06,0x31,
+ 0x06,0x06,0x06,0x0A,0x0B,0x06,0xA1,0xA2,0x06,0x06,
+ 0x06,0x0A,0x0B,0x06,0x06,0x06,0x02,0x03,0x02,0x03,
+ 0x06,0x06,0x06,0x06,0x12,0x13,0x12,0x13,0x12,0x13,
+ 0x12,0x13,0x12,0x13,0x06,0x06,0x31,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x02,0x03,0x02,0x03,
+ 0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,0x00,0x01,
+ 0x00,0x01,0x02,0x03,0x02,0x03,0x02,0x03,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x02,0x03,0x00,0x01,0x12,0x13,
+ 0x06,0x06,0x06,0x46,0x81,0x82,0x83,0x80,0xB6,0x06,
+ 0x06,0x06,0x06,0x06,0x44,0x45,0x00,0x01,0x06,0x06,
+ 0x02,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,
+ 0x69,0x26,0x26,0x26,0x26,0x27,0x06,0x06,0x06,0x4C,
+ 0x4D,0x63,0x64,0x6A,0x08,0x08,0x09,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x2F,0x36,0x36,0x36,
+ 0x36,0x36,0x36,0x30,0x06,0x4C,0x4D,0x63,0x64,0x4E,
+ 0x4F,0x06,0x06,0x06,0x6B,0x6C,0x6D,0x6C,0x6D,0x6C,
+ 0x6D,0x6C,0x6D,0x30,0x06,0x06,0x31,0x06,0x06,0x6E,
+ 0x6F,0x70,0x71,0x72,0x73,0x06,0x06,0x06,0x06,0x32,
+ 0x05,0x04,0x06,0x06,0x06,0x05,0x04,0x0D,0x0C,0x05,
+ 0x06,0x06,0x06,0x3F,0x40,0x55,0x5B,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x75,0x76,0x77,0x78,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x79,0x41,0x42,0x0C,
+ 0x0D,0x06,0x04,0x05,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x02,0x03,0x06,0xAF,0xB0,0x06,0x06,0x06,0x02,0x03,
+ 0x06,0x31,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x31,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,
+ 0x52,0x90,0x91,0x92,0x8F,0xC0,0x06,0x06,0x06,0x06,
+ 0x06,0x50,0x51,0x0A,0x0B,0x06,0x06,0x06,0x00,0x01,
+ 0x00,0x01,0x06,0x31,0x06,0x06,0x06,0x7A,0x06,0x06,
+ 0x5D,0x5E,0x5F,0x60,0x7B,0x7C,0x74,0x08,0x08,0x08,
+ 0x7D,0x7E,0x08,0x5C,0x5D,0x5E,0x5F,0x60,0x61,0x62,
+ 0x06,0x06,0x06,0x2F,0x7F,0x36,0x36,0x36,0x1B,0x1C,
+ 0x43,0x06,0x0E,0x08,0x08,0x08,0x08,0x0F,0x06,0x06,
+ 0x06,0x2D,0x80,0x81,0x82,0x83,0x80,0x81,0x80,0x81,
+ 0x2C,0x06,0x06,0x06,0x31,0x06,0x84,0x85,0x86,0x87,
+ 0x08,0x88,0x06,0x06,0x06,0x06,0x2D,0x0D,0x0C,0x04,
+ 0x05,0x06,0x0D,0x0C,0x05,0x04,0x0D,0x06,0x06,0x06,
+ 0x4C,0x4D,0x64,0x6A,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x75,0x76,0x77,0x78,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x89,0x4E,0x4F,0x06,0x06,0x06,0x0C,
+ 0x0D,0x06,0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x03,0x02,0x03,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x12,0x13,
+ 0x12,0x13,0x12,0x13,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x12,0x13,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,
+ 0x06,0x06,0x12,0x13,0x12,0x13,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x31,0x06,0x06,
+ 0x06,0x06,0x02,0x03,0x02,0x03,0x06,0x31,0x06,0x06,
+ 0x06,0x06,0x02,0x03,0x02,0x03,0x02,0x03,0x06,0x06,
+ 0x02,0x03,0x00,0x01,0x12,0x13,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x02,0x03,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x06,
+ 0x06,0x31,0x06,0x06,0x8A,0x06,0x06,0x6E,0x6F,0x70,
+ 0x8B,0x72,0x8C,0x07,0x08,0x08,0x08,0x8D,0x8E,0x08,
+ 0x09,0x6E,0x6F,0x70,0x71,0x72,0x73,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x36,0x36,0x29,0x06,0x06,0x06,0x14,
+ 0x15,0x08,0x08,0x24,0x25,0x06,0x06,0x06,0x32,0x8F,
+ 0x90,0x91,0x92,0x8F,0x90,0x8F,0x90,0x30,0x06,0x06,
+ 0x06,0x06,0x06,0x93,0x94,0x95,0x96,0x97,0x98,0x06,
+ 0x31,0x06,0x06,0x32,0x05,0x04,0x0C,0x0D,0x04,0x05,
+ 0x04,0x0D,0x0C,0x06,0x06,0x06,0x06,0x74,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x75,
+ 0x76,0x77,0x78,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x79,0x41,0x42,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x06,0x31,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0A,
+ 0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0A,
+ 0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x00,0x01,0x00,0x01,0x06,0x06,0x06,0x06,
+ 0x06,0x33,0x34,0x06,0x99,0x08,0x86,0x87,0x9A,0x88,
+ 0x0E,0x08,0x08,0x08,0x08,0x08,0x08,0x0F,0x84,0x85,
+ 0x86,0x87,0x08,0x88,0x06,0x06,0x31,0x06,0x06,0x06,
+ 0x7F,0x36,0x39,0x06,0x06,0x06,0x06,0x9B,0x9C,0x08,
+ 0x39,0x06,0x06,0x06,0x06,0x9B,0x9D,0x06,0x06,0x06,
+ 0x06,0x9E,0x9F,0xA0,0x2C,0x06,0x06,0x06,0x06,0x06,
+ 0xA1,0xA2,0x36,0x36,0x2E,0x06,0x06,0x06,0x06,0x06,
+ 0x2D,0x0D,0x0C,0x06,0x06,0x0C,0x0D,0x0C,0x05,0x04,
+ 0x06,0x06,0x06,0x06,0x0E,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x75,0xA3,0xA4,0x78,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x89,
+ 0x4E,0x4F,0x06,0x06,0x04,0x05,0x06,0x06,0x02,0x03,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x06,0x31,0x06,0x06,0x12,0x13,0x12,0x13,0x06,0x06,
+ 0x31,0x06,0x02,0x03,0x02,0x03,0x02,0x03,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x12,0x13,0x12,0x13,0x12,0x13,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x12,0x13,0x00,0x01,0x00,0x01,
+ 0x12,0x13,0x12,0x13,0x31,0x06,0x06,0x06,0x12,0x13,
+ 0x12,0x13,0x12,0x13,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x02,0x03,0x00,0x01,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x12,0x13,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0A,
+ 0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,0x3A,0x3B,
+ 0x06,0x93,0x94,0x95,0x96,0x97,0x98,0x14,0x15,0x21,
+ 0x22,0x21,0x22,0x24,0x25,0x93,0x94,0x95,0x96,0x97,
+ 0x98,0x31,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x3C,
+ 0x3D,0x6C,0x6D,0xA5,0xA6,0xA7,0xA8,0x3C,0x3D,0xA9,
+ 0xAA,0xA5,0xA6,0xAB,0x06,0x06,0x06,0x06,0xAC,0xAD,
+ 0xAE,0x30,0x06,0x06,0x06,0x06,0x06,0xAF,0xB0,0x36,
+ 0x36,0xB1,0x06,0x31,0x06,0x06,0x06,0x32,0x04,0x05,
+ 0x06,0x06,0x06,0x04,0x05,0x0D,0x0C,0x04,0x06,0x06,
+ 0x06,0x74,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x75,0xB2,0xB3,0x78,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x5C,0x06,
+ 0x06,0x0C,0x0D,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x31,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x12,0x13,0x12,
+ 0x13,0x12,0x13,0x12,0x13,0x0A,0x0B,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x00,0x01,0x02,0x03,
+ 0x06,0x06,0xB4,0xB5,0x5F,0x60,0x61,0x62,0xA1,0xA2,
+ 0x36,0x36,0x2E,0x06,0x12,0x13,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0xA1,0xA2,0x36,0x36,0x2E,0x06,0x06,0x31,
+ 0x06,0x5A,0x19,0x19,0x19,0x19,0x46,0x47,0x80,0x81,
+ 0x80,0xB6,0xB7,0xB8,0x46,0x47,0xB9,0xBA,0x80,0xB6,
+ 0x9D,0x06,0x06,0x06,0x06,0x9E,0x06,0x06,0x2C,0x06,
+ 0x06,0x06,0x12,0x13,0x06,0x35,0x36,0x36,0x2E,0x06,
+ 0x06,0x06,0x06,0x06,0x2D,0x0C,0x0D,0x06,0x06,0x06,
+ 0x0C,0x0D,0x05,0x04,0x0C,0x06,0x06,0x06,0x07,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x23,0xBB,
+ 0xBC,0xA3,0xA4,0xBD,0x22,0x22,0x22,0x16,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x09,0x06,0x04,0x05,0x04,
+ 0x05,0x06,0x06,0x06,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x06,0x06,0x12,0x13,0x00,0x01,
+ 0x00,0x01,0x12,0x13,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x12,0x13,0x12,0x13,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,
+ 0x12,0x13,0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,
+ 0x06,0x06,0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13,
+ 0x12,0x13,0x06,0x06,0x31,0x06,0x12,0x13,0x31,0x06,
+ 0x06,0x06,0x02,0x03,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,
+ 0x0A,0x0B,0x02,0x03,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x12,0x13,0x12,0x0A,0x0B,0x06,0x06,0x06,0x06,0xBE,
+ 0x6F,0x70,0x71,0x72,0x73,0xAF,0xB0,0x36,0x36,0xB1,
+ 0x06,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0xAF,
+ 0xB0,0x36,0x36,0xB1,0x06,0x06,0x06,0x06,0x69,0x26,
+ 0x26,0x26,0x26,0x52,0x53,0x8F,0x90,0xBF,0xC0,0xC1,
+ 0xC2,0x52,0x53,0xC3,0xC4,0xBF,0xC0,0xAB,0x06,0x06,
+ 0x06,0x06,0xAC,0x06,0x06,0x30,0x06,0x06,0x06,0x0A,
+ 0x0B,0x06,0x2F,0x36,0x36,0xB1,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0x40,0x54,0x55,
+ 0x54,0x55,0x54,0x55,0x54,0x55,0xC9,0xCA,0x41,0x42,
+ 0x06,0x06,0x44,0x45,0x9D,0x06,0x06,0x06,0x06,0x9E,
+ 0x06,0x06,0x2C,0x06,0x06,0x06,0x02,0x03,0x06,0x35,
+ 0x36,0x36,0x2E,0x06,0x06,0x06,0x06,0x06,0x2D,0x06,
+ 0x06,0x06,0x06,0x06,0x0C,0x0D,0x05,0x04,0x04,0x06,
+ 0x06,0x06,0x74,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x09,0x06,0x31,0x06,0x31,0x06,0x31,0x06,
+ 0x06,0x07,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x09,
+ 0x06,0x06,0x04,0x05,0x06,0x06,0x06,0x06,0x00,0x01,
+ 0x00,0x01,0x02,0x03,0x02,0x03,0x02,0x03,0x06,0x06,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,
+ 0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x03,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x02,0x03,0x02,0x03,0x12,0x13,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,0x06,0x06,
+ 0x00,0x01,0x12,0x13,0x06,0x06,0x06,0x06,0x0A,0x0B,
+ 0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x12,0x13,0x00,0x01,0x00,0x0A,0x0B,0x06,
+ 0x06,0x06,0x06,0x93,0x94,0x95,0x96,0x97,0x98,0x06,
+ 0x2F,0x36,0x36,0xB1,0x06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x02,0x03,0x02,0x03,0x02,
+ 0x03,0x02,0x03,0x06,0x06,0x06,0x06,0x06,0x06,0x0A,
+ 0x0B,0x0A,0x0B,0x0B,0x00,0x01,0x06,0x06,0x06,0x06,
+ 0x06,0x35,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,
+ 0x2E,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x35,0x36,0x36,0x2E,0x06,0x06,0x06,0x06,0x06,
+ 0x74,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x5C,0x06,0x06,0x06,0xCD,0xCE,0x06,
+ 0x06,0x06,0x06,0x9E,0x06,0x06,0x2C,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x2D,0x06,0x06,0x06,0x06,0x0C,0x0D,0x0C,
+ 0x05,0x04,0x0C,0x06,0x06,0x06,0x74,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x5C,0x06,0x06,0x31,
+ 0x06,0x31,0x31,0x06,0x06,0x07,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x09,0x06,0x06,0x06,0x06,0x0C,0x0D,
+ 0x06,0x06,0x00,0x01,0x02,0x03,0x06,0x06,0x06,0x06,
+ 0x31,0x06,0x06,0x06,0x02,0x03,0x02,0x03,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x02,0x03,0x02,0x03,0x02,0x03,
+ 0x02,0x03,0x02,0x03,0x02,0x03,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x12,0x13,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x12,0x13,0x12,0x13,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x12,0x13,0x00,0x01,0x00,0x01,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x12,0x13,0x00,0x01,0x00,0x01,
+ 0x00,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,0x2F,0x36,
+ 0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x2E,0x2F,0x2E,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x2F,0x36,
+ 0x36,0x2E,0x2F,0x2E,0x06,0x06,0x06,0x74,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x09,0x06,0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,
+ 0xAC,0x06,0x06,0x30,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x32,
+ 0x06,0x06,0x06,0x06,0x06,0x04,0x05,0x0D,0x06,0x06,
+ 0x06,0x06,0x06,0x0E,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x09,0x06,0x06,0x31,0x31,0x06,0x06,
+ 0x06,0x06,0x74,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x4F,0x06,0x06,0x06,0x04,0x05,0x06,0x06,0x06,0x0A,
+ 0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x0A,0x0B,0x0B,0x0A,0x0A,0x0B,0x0B,0xCF,0xD0,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x7F,0x36,
+ 0x7F,0x36,0x36,0x36,0x36,0x36,0x2E,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x35,0x36,0x36,0x36,0x36,
+ 0x2E,0x06,0x06,0x06,0x07,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x5C,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x31,0x06,0x9E,0x06,0x06,
+ 0x2C,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x31,0x06,0x06,0x06,0x2D,0x06,0x06,0x06,
+ 0x06,0x06,0x0C,0x0D,0x06,0x06,0x06,0x31,0x06,0x06,
+ 0x74,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x79,0x41,0x42,0x06,0x06,0x31,0x06,0x3F,0x40,0x5B,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x5C,0x06,0x06,
+ 0x06,0x0C,0x0D,0x06,0x06,0x06,0x02,0x03,0x06,0x06,
+ 0x06,0x06,0x12,0x13,0x12,0x13,0x12,0x13,0x06,0x06,
+ 0x06,0x06,0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x03,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,0x12,0x13,
+ 0x12,0x13,0x12,0x13,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x12,0x13,0x12,0x13,0x31,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x12,0x13,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x5A,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x36,
+ 0x36,0x36,0x36,0xB1,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x2F,0x2E,0x2F,0x36,0x36,0x36,0x36,0xB1,0x06,0x06,
+ 0x06,0x74,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x09,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0xAC,0x06,0x06,0x30,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x32,0x06,0x06,0x06,0x06,0x06,0x05,
+ 0x04,0x05,0x04,0x06,0x06,0x31,0x06,0x07,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x89,0x4E,0x4F,
+ 0x06,0x06,0x06,0x06,0x4C,0x4D,0x6A,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x09,0x06,0x06,0x04,0x05,0x04,
+ 0x05,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0A,
+ 0x0B,0x0A,0x0B,0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08,0x79,0x54,0x55,0x54,
+ 0x55,0x5B,0x08,0x08,0x08,0x08,0x08,0x08,0x23,0x24,
+ 0x24,0x25,0x06,0x06,0x0C,0x0D,0x0C,0x0D,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x12,0x13,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x12,0x13,0x12,0x13,0x06,0x06,0x02,0x03,
+ 0x02,0x03,0x02,0x03,0x02,0x03,0x00,0x01,0x02,0x03,
+ 0x06,0x06,0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13,
+ 0x12,0x13,0x06,0x06,0x31,0x06,0x02,0x03,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x10,0x11,0x00,0x01,0x00,0x01,0x02,0x03,0x00,0x01,
+ 0x00,0x01,0x12,0x13,0x00,0x01,0x02,0x03,0x02,0x03,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,0x12,0x13,
+ 0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x8A,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x36,0x36,0x2E,0x2F,0x2E,
+ 0x2F,0x2E,0x2F,0x36,0x36,0x36,0x36,0x36,0x36,0xB1,
+ 0x06,0x06,0x06,0x06,0x06,0x0E,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x09,0x06,
+ 0x06,0x06,0xD3,0xD4,0xD5,0xD4,0xD5,0xD6,0xD7,0x0C,
+ 0x0D,0x30,0x06,0x06,0x06,0x50,0x51,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x32,0x06,0x06,
+ 0x06,0x06,0x0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x08,0x08,0x08,0x08,0x5C,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x04,0x05,0x04,0x05,0x39,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x9B,0x06,0x06,0x06,0x06,0x06,
+ 0x0D,0x0C,0x06,0x06,0x06,0x06,0x06,0x06,0x0E,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x5C,0x06,0x06,0x06,0x06,0x0C,0x0D,0x0C,
+ 0x0D,0x06,0x06,0x06,0x12,0x13,0x12,0x13,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x12,0x13,0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x06,
+ 0x02,0x03,0x06,0x06,0x12,0x13,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,0x06,0x06,
+ 0x06,0x06,0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,
+ 0x02,0x03,0x00,0x01,0x12,0x13,0x00,0x01,0x00,0x01,
+ 0x12,0x13,0x00,0x01,0x02,0x03,0x02,0x03,0x02,0x03,
+ 0x06,0x06,0x31,0x06,0x02,0x03,0x02,0x03,0x02,0x03,
+ 0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x8A,0x06,0xAF,0xB0,0xAF,0xB0,0xAF,
+ 0xB0,0xAF,0xB0,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x2F,0x36,0x36,0xB1,0x06,0x06,0x06,0x06,0x06,0x06,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0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x33,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,
+ 0x19,0x19,0x19,0x19,0x34,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x3F,0x40,0x54,0x55,0x54,0x55,
+ 0x54,0x55,0x5B,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x79,
+ 0x41,0x42,0x06,0x06,0x04,0x05,0x04,0x05,0x3F,0x40,
+ 0x41,0x42,0xD8,0xD9,0xDA,0xD9,0xDA,0xD9,0xDB,0xDB,
+ 0xDB,0xDB,0xDB,0xDB,0xDB,0xDB,0xDB,0xDB,0xDC,0x31,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x31,0x06,0x06,0x06,0x07,0x08,0x08,0x08,0x7D,
+ 0x7E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x5C,0x06,0x06,0x06,0x06,0x06,
+ 0x0C,0x0D,0x06,0x06,0x06,0x06,0x12,0x13,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,0x12,0x13,
+ 0x12,0x13,0x06,0x06,0x06,0x06,0x06,0x06,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x12,0x13,0x06,0x06,0x31,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x10,0x11,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x03,0x06,0x5A,
+ 0x19,0x19,0x19,0x19,0x19,0x19,0x34,0x19,0x19,0x19,
+ 0x19,0x5A,0x06,0x06,0x06,0x06,0x02,0x03,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x02,0x03,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x03,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x3A,0x26,0x26,
+ 0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,
+ 0x26,0x3B,0x06,0x06,0x48,0x49,0x4A,0x4B,0x06,0x06,
+ 0x06,0x4C,0x4D,0x63,0x64,0x63,0x64,0x63,0x64,0x6A,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x89,0x4E,0x4F,0x06,
+ 0x06,0x0C,0x0D,0x0C,0x0D,0x4C,0x4D,0x4E,0x4F,0xDD,
+ 0xDE,0xDF,0xE0,0xDF,0xE0,0xE1,0xE1,0xE1,0xE1,0xE1,
+ 0xE1,0xE1,0xE1,0xE1,0xE1,0xE2,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x31,0x06,0x06,0x31,0x06,0x06,0x31,
+ 0x06,0x06,0x0E,0x08,0x08,0x08,0x8D,0x8E,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x23,0xBB,0xE3,0xBB,0xE3,
+ 0x24,0x25,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x17,0x18,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x06,0x06,0x06,0x69,0x26,0x26,0x26,
+ 0x26,0x3A,0x26,0x3B,0x26,0x26,0x26,0x26,0x69,0x06,
+ 0x31,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x54,0x55,0x54,0x55,0x54,0x55,
+ 0x54,0x55,0x54,0x55,0x54,0x55,0x54,0x55,0x54,0x55,
+ 0x54,0x56,0x57,0x58,0x59,0x55,0x54,0x55,0x5B,0x08,
+ 0x08,0x08,0x08,0x08,0x7D,0x7E,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x7D,0x7E,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x79,0x54,0x55,0x54,0x55,
+ 0x54,0x55,0x5B,0x08,0x08,0x5C,0x46,0x47,0x80,0x81,
+ 0x80,0x81,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
+ 0x80,0x80,0xB6,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x74,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x5C,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x04,0x05,0x06,0x06,0x06,0x06,0x06,0x06,0x12,0x13,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,0x12,0x13,
+ 0x12,0x13,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,
+ 0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13,0x06,0x06,
+ 0x06,0x06,0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,
+ 0x06,0x5A,0x19,0x7A,0x06,0x06,0x06,0x06,0x3F,0x40,
+ 0x41,0x42,0x12,0x13,0x06,0x7A,0x34,0x19,0x19,0x5A,
+ 0x06,0x06,0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x06,0x06,0x02,0x03,0x00,0x01,0x02,0x03,
+ 0x00,0x63,0x64,0x63,0x64,0x63,0x64,0x63,0x64,0x63,
+ 0x64,0x63,0x64,0x63,0x64,0x63,0x64,0x63,0x65,0x66,
+ 0x67,0x68,0xE4,0x63,0x64,0x6A,0x08,0x08,0x08,0x08,
+ 0x08,0x8D,0x8E,0x08,0x08,0x7D,0x7E,0x08,0x08,0x8D,
+ 0x8E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x89,0x63,0x64,0x63,0x64,0x63,0x64,0x6A,
+ 0x08,0x08,0x09,0x52,0x53,0x8F,0x90,0x8F,0x90,0xBF,
+ 0xBF,0xBF,0xBF,0xBF,0xBF,0xBF,0xBF,0xBF,0xBF,0xC0,
+ 0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x31,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x07,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x09,
+ 0x06,0x06,0x06,0x06,0x06,0x04,0x05,0x0C,0x0D,0x04,
+ 0x05,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x69,0x26,
+ 0x26,0x06,0x06,0x06,0x06,0x4C,0x4D,0x4E,0x4F,0x0A,
+ 0x0B,0x06,0x26,0x3B,0x26,0x26,0x7A,0x06,0x06,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,
+ 0x06,0x06,0x06,0x0A,0x0B,0x06,0x06,0x0A,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x75,0x76,0x77,0x78,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x8D,0x8E,0x08,0x08,0x08,0x08,0x08,0x7D,
+ 0x7E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x79,
+ 0x54,0x55,0x41,0x42,0x12,0x13,0x12,0x13,0x12,0x13,
+ 0x12,0x13,0x12,0x13,0x12,0x13,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x0E,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x5C,0x06,0x06,0x06,
+ 0x06,0x06,0x0C,0x0D,0x04,0x05,0x0C,0x0D,0x04,0x05,
+ 0x06,0x06,0x02,0x03,0x02,0x03,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,
+ 0x02,0x03,0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x12,0x13,0x06,0x06,0x06,0x06,0x06,0x5A,
+ 0x19,0x19,0x19,0x19,0x19,0x7A,0x06,0x06,0x3F,0x40,
+ 0x54,0x55,0x5B,0x08,0x08,0x5C,0x02,0x03,0x06,0x06,
+ 0x06,0x06,0x06,0x7A,0x06,0x06,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,0x06,0x06,
+ 0x00,0x01,0x12,0x13,0x00,0x08,0x08,0x7D,0x7E,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x75,0xA3,0xA4,0x78,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x8D,0x8E,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x89,0x63,0x64,0x4E,
+ 0x4F,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x06,0x06,0x31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x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x5C,0x02,0x03,
+ 0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x4C,0x4D,0x63,0x64,0x6A,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x09,0x06,0x48,0x49,0x4A,0x4B,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x02,0x03,0x02,0x03,0x02,0x03,0x06,0x4C,0x4D,0x63,
+ 0x64,0x64,0x64,0x64,0x63,0x64,0x4E,0x4F,0x02,0x03,
+ 0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,
+ 0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x06,0x31,
+ 0x06,0x31,0x06,0x7A,0x06,0x06,0x5D,0x5E,0x5F,0x60,
+ 0x7B,0x7C,0x74,0x08,0x08,0x08,0x7D,0x7E,0x08,0x5C,
+ 0x06,0x06,0x06,0x0A,0x0B,0x06,0x06,0x7A,0x06,0x06,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x12,0x13,0x00,0x01,0x00,0x01,0x00,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0xBE,0x6F,0x70,0x71,0x72,
+ 0x73,0x21,0x22,0x21,0x22,0x21,0xBC,0xA3,0xA4,0xBD,
+ 0x22,0x16,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x7D,0x7E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x09,0x54,0x55,0x54,0x55,0x54,
+ 0x55,0x54,0x55,0x54,0x55,0x54,0x55,0x54,0x55,0x54,
+ 0x54,0x55,0x54,0x55,0x54,0x55,0x54,0x55,0x54,0x55,
+ 0x5B,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x79,0x41,0x56,
+ 0x57,0x58,0x59,0x55,0x54,0x55,0x54,0x55,0x54,0x55,
+ 0x54,0x54,0x55,0x54,0x55,0x54,0x55,0x54,0x55,0x54,
+ 0x55,0x54,0x55,0x55,0x5B,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x5C,0x55,0x55,0x54,0x55,0x41,
+ 0x42,0x06,0x06,0x06,0x06,0x31,0x06,0x31,0x06,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x31,0x06,0x06,
+ 0x8A,0x06,0x06,0x6E,0x6F,0x70,0x8B,0x72,0x8C,0x07,
+ 0x08,0x08,0x08,0x8D,0x8E,0x08,0x09,0x06,0x06,0x06,
+ 0x02,0x03,0x06,0x06,0x8A,0x06,0x06,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x1B,0x1C,0x1D,0x1E,
+ 0x1F,0x20,0x99,0x08,0x86,0x87,0x9A,0x88,0x1A,0x06,
+ 0x06,0x06,0x06,0xC5,0xC6,0xC7,0xC8,0x06,0x0E,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x8D,0x8E,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x64,0x63,0x64,0x64,0x63,0x64,0x63,0x64,
+ 0x63,0x64,0x63,0x64,0x63,0x64,0x63,0x63,0x64,0x63,
+ 0x64,0x63,0x64,0x63,0x64,0x63,0x64,0x6A,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x89,0x4E,0x65,0x66,0x67,0x68,
+ 0xE4,0x63,0x64,0x63,0x64,0x63,0x64,0x63,0x63,0x64,
+ 0x63,0x64,0x63,0x64,0x63,0x64,0x63,0x64,0x63,0x64,
+ 0x64,0x6A,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x64,0x64,0x64,0x63,0x64,0x4E,0x4F,0x06,0x44,
+ 0x45,0x31,0x06,0x31,0x06,0x06,0x02,0x03,0x02,0x03,
+ 0x02,0x03,0x02,0x03,0x02,0x03,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x03,
+ 0x02,0x03,0x06,0x06,0x06,0x06,0x06,0x33,0x06,0x06,
+ 0x99,0x08,0x86,0x87,0x9A,0x88,0x0E,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x5C,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x8A,0x06,0x06,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x29,0x06,0x06,0x06,0x06,0x2A,0x93,
+ 0x94,0x95,0x96,0x97,0x98,0x27,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x14,0x15,0xBB,0xE3,0xBB,
+ 0xE3,0xBB,0xE3,0xBB,0xE3,0xEB,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x75,0x76,0x77,0x78,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x5C,0x06,0x50,0x51,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,0x5A,0x19,
+ 0x19,0x06,0x06,0x06,0x33,0x06,0x06,0x93,0x94,0x95,
+ 0x96,0x97,0x98,0x0E,0x08,0x08,0x7D,0x7E,0x08,0x08,
+ 0x09,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x7A,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x43,0x06,0x12,0x13,0x06,0x2D,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x2B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13,
+ 0x12,0x13,0x0E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x7D,0x7E,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x75,0xA3,0xA4,0x78,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x09,0x31,0x06,0x06,0x06,0x06,0x31,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x02,0x03,0x06,0x06,0x06,0x69,0x26,0x7A,0x06,0x06,
+ 0x06,0x7A,0x06,0x06,0xA1,0xA2,0x36,0x36,0x2E,0x06,
+ 0x14,0x15,0x16,0x8D,0x8E,0x08,0x08,0x25,0xA1,0xA2,
+ 0x36,0x36,0x2E,0x06,0x06,0x8A,0x06,0x06,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x12,0x13,0x00,0x01,0x00,0x01,
+ 0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x06,0x06,0x0A,
+ 0x0B,0x06,0x32,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0xEC,0x06,0x06,0x06,0x06,0xD3,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x14,
+ 0x15,0x16,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x8D,0x8E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x7D,0x7E,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x75,0xB2,0xB3,
+ 0x78,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x5C,0x06,
+ 0x06,0x06,0x44,0x45,0x1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3,0x15,0x21,0x22,0x21,0x22,
+ 0x21,0x22,0x21,0x22,0x21,0x22,0x21,0x22,0x21,0x22,
+ 0x16,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x09,0x06,0x06,0x06,0x50,
+ 0x51,0x30,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x32,0x06,0x06,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x06,0x06,0x7A,0x26,0x26,0x26,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x35,
+ 0x36,0x36,0x2E,0x06,0x06,0x06,0x14,0xE3,0xE3,0x24,
+ 0x25,0x06,0x06,0x35,0x36,0x36,0x2E,0x06,0x06,0x8A,
+ 0x06,0x31,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0xA1,0xA2,0x00,0x01,0x00,0x01,
+ 0x00,0x0A,0x0B,0x0A,0x0B,0x06,0x32,0x26,0x26,0x26,
+ 0x26,0x3B,0x06,0x06,0x06,0x06,0x06,0xAC,0x06,0x06,
+ 0x06,0x06,0xEE,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x07,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x8D,0x8E,
+ 0x08,0x08,0x7D,0x7E,0x08,0x08,0x8D,0x8E,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x7D,0x7E,0x08,0x5C,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0xC5,0xC6,0xC7,0xC8,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x12,0x13,0x12,0x13,0x12,0x13,0x12,
+ 0x13,0x06,0x06,0x12,0x13,0x06,0x06,0x74,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x79,0x41,0x42,0x06,0x06,0x06,0x2C,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x2D,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x06,0x06,0x7A,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x2F,0x2E,0x06,0x36,0x36,0x36,
+ 0x2E,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x35,0x36,0x36,0x2E,0x06,0x06,0x7A,0x06,0x06,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0xAF,0xB0,0x0A,0x0B,0x0A,0x0B,0x0A,0x02,0x03,
+ 0x00,0x01,0x06,0x2D,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x9E,0x06,0x06,0x06,0x06,0xED,
+ 0x06,0x06,0x02,0x03,0x02,0x03,0x04,0x05,0x06,0x06,
+ 0x06,0x06,0x74,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x8D,
+ 0x8E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x8D,0x8E,0x08,0x09,0x06,0x06,0x06,0x12,0x13,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x31,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x31,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x06,
+ 0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,
+ 0x0A,0x0B,0x06,0x06,0x07,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x89,
+ 0x4E,0x4F,0x06,0x06,0x06,0x30,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x32,0x06,0x06,0x02,0x03,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x06,0x06,
+ 0x8A,0x06,0x06,0x06,0x06,0x44,0x45,0x06,0x06,0x35,
+ 0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x2E,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x35,0x36,0x36,0x36,0x36,0x36,
+ 0x36,0x2E,0x06,0x8A,0x06,0x06,0x00,0x01,0x00,0x01,
+ 0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x06,0x06,0x0A,0x0B,0x06,
+ 0x32,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0xAC,0x06,0x06,0x06,0x06,0xEE,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x0C,0x0D,0x06,0x06,0x06,0x06,0x07,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x23,0x21,0x22,0x22,
+ 0x24,0x25,0x06,0x06,0x06,0x0A,0x0B,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x31,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x31,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x02,0x03,0x00,
+ 0x01,0x00,0x01,0x00,0x01,0x12,0x13,0x00,0x01,0x06,
+ 0x06,0x74,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x4F,0x06,
+ 0x06,0x06,0x2C,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x9B,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x8A,0x06,0x31,
+ 0x06,0x06,0x50,0x51,0x06,0x06,0x2F,0x2E,0x2E,0x06,
+ 0x06,0x2F,0x36,0x36,0x36,0x36,0x2E,0x06,0x06,0x06,
+ 0x06,0x06,0x2F,0x36,0x36,0x36,0x36,0x36,0xB1,0x06,
+ 0x8A,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x06,0x06,0x02,0x03,0x06,0x2D,0x12,0x13,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x9D,0x06,
+ 0x06,0x06,0x06,0xCD,0x06,0x06,0x04,0x05,0x04,0x05,
+ 0x04,0x05,0x06,0x06,0x06,0x06,0x0E,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x5C,0x12,0x13,0x12,0x13,0x12,0x13,
+ 0x12,0x13,0x00,0x01,0x06,0x06,0x12,0x13,0x06,0x06,
+ 0x06,0x31,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x31,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x04,0x06,
+ 0x06,0x06,0x06,0x04,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x31,0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,
+ 0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x07,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x4F,0x06,0x06,0x06,0x30,
+ 0x06,0x06,0x6B,0x6C,0x6D,0x6C,0x6D,0x6C,0x6D,0xA6,
+ 0x06,0x06,0x06,0x06,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x06,0x06,0x33,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x36,0x36,0x36,0x2E,0x06,0x06,0x06,0x06,0x2F,0x36,
+ 0x2F,0x36,0x36,0x36,0x2E,0x06,0x06,0x7A,0x06,0x06,
+ 0x00,0x01,0x00,0x01,0x12,0x13,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x06,
+ 0x06,0x06,0x06,0x06,0x32,0x0A,0x0B,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0xAB,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x0C,0x0D,0x0C,0x0D,0x0C,0x0D,0x06,
+ 0x06,0x06,0x06,0x14,0x15,0x16,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x09,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x06,0x06,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x31,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x05,
+ 0x04,0x05,0x04,0x05,0x04,0x04,0x06,0x06,0x05,0x04,
+ 0x0C,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x31,0x06,
+ 0x06,0x06,0x06,0x00,0x01,0x00,0x01,0x00,0x01,0x00,
+ 0x01,0x00,0x01,0x06,0x06,0x0E,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x4F,0x06,0x06,0x06,0x2C,0x06,0x06,0x2D,
+ 0x80,0x81,0x82,0x83,0x80,0x81,0xDC,0x06,0x06,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,
+ 0x06,0x7A,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x31,
+ 0x06,0x06,0x06,0x06,0x12,0x13,0x35,0x36,0x36,0x2E,
+ 0x06,0x12,0x13,0x06,0x06,0x06,0x2F,0x36,0x36,0x36,
+ 0x36,0xB1,0x06,0x06,0x8A,0x06,0x31,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x02,0x03,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x06,0x06,0x06,0x06,
+ 0x06,0x9B,0x00,0x01,0x12,0x13,0x06,0x06,0x06,0xCD,
+ 0xEF,0xF0,0xCE,0x06,0x06,0x06,0x04,0x05,0x04,0x05,
+ 0x12,0x13,0x04,0x05,0x04,0x05,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x0E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x0F,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,
+ 0x00,0x01,0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x31,0x06,0x06,0x06,0x06,0x0D,0x0C,0x0D,0x0C,
+ 0x0D,0x0C,0x06,0x06,0x06,0x0D,0x0C,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x02,0x03,0x02,0x03,
+ 0x06,0x06,0x14,0x15,0x16,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x4F,
+ 0x06,0x06,0x06,0x30,0x06,0x06,0x32,0x8F,0x90,0x91,
+ 0x92,0x8F,0x8F,0x90,0x06,0x06,0x12,0x13,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x06,0x06,0x8A,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x0A,0x0B,0x2F,0x36,0x36,0xB1,0x06,0x0A,0x0B,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x7A,0x06,0x06,0x00,0x01,0x00,0x01,0x02,0x03,
+ 0x06,0x06,0x00,0x01,0x02,0x03,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x6C,0x6D,0x6C,0x6D,0xA5,0xA6,0x0A,
+ 0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x0C,0x0D,0x0C,0x0D,0x0A,0x0B,0x0C,
+ 0x0D,0x0C,0x0D,0x06,0x06,0x06,0x06,0x06,0x06,0x14,
+ 0x15,0x21,0x22,0x16,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x23,0x21,0x22,0x24,0x25,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x05,0x04,0x05,0x04,0x04,0x05,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x04,0x05,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x02,0x03,0x02,
+ 0x03,0x02,0x03,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x0E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x4F,0x06,0x06,0x06,
+ 0x2C,0x06,0x06,0x32,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x06,0x06,0x7A,0x06,0xA1,0xA2,0xA1,
+ 0xA2,0xA1,0xA2,0xA1,0xA2,0x06,0x06,0x06,0x02,0x03,
+ 0x35,0x36,0x36,0x2E,0x06,0x02,0x03,0x06,0xA1,0xA2,
+ 0xA1,0xA2,0xA1,0xA2,0xA1,0xA2,0x06,0x06,0x8A,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x0A,
+ 0x0B,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x80,0x81,0x80,0x81,0x80,0xB6,0x00,0x01,0x00,0x01,
+ 0x12,0x13,0x12,0x13,0x12,0x13,0x04,0x05,0x04,0x05,
+ 0x04,0x05,0x12,0x13,0x02,0x03,0x04,0x05,0x04,0x05,
+ 0x04,0x05,0x06,0x06,0x44,0x45,0x12,0x13,0x06,0x06,
+ 0x0E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x0F,0x12,0x13,
+ 0x12,0x13,0x00,0x01,0x02,0x03,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x03,
+ 0x00,0x01,0x00,0x01,0x12,0x13,0x12,0x13,0x12,0x13,
+ 0x12,0x13,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0D,
+ 0x0C,0x0D,0x04,0x0C,0x0D,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x12,0x13,0x0C,0x0D,0x04,0x04,0x05,0x04,0x05,
+ 0x12,0x13,0x12,0x13,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x31,0x06,0x06,0x06,0x06,0x06,0x06,0x14,0x15,
+ 0x21,0x22,0x16,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x4F,0x06,0x06,0x06,0x30,0x06,0x06,
+ 0x32,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x06,0x06,0x8A,0x06,0xAF,0xB0,0xAF,0xB0,0xAF,0xB0,
+ 0xAF,0xB0,0x06,0x06,0x06,0x06,0x19,0x06,0x06,0x06,
+ 0x06,0x06,0x19,0x06,0x06,0xAF,0xB0,0xAF,0xB0,0xAF,
+ 0xB0,0xAF,0xB0,0x06,0x06,0x7A,0x06,0x06,0x00,0x01,
+ 0x00,0x01,0x12,0x13,0x06,0x06,0x00,0x01,0x12,0x13,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x8F,0x90,0x8F,
+ 0x90,0xBF,0xC0,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0C,0x0D,0x0C,0x0D,0x0C,0x0D,0x0A,
+ 0x0B,0x06,0x06,0x0C,0x0D,0x0C,0x0D,0x0C,0x0D,0x06,
+ 0x06,0x50,0x51,0x0A,0x0B,0x06,0x06,0x14,0x15,0x21,
+ 0x22,0x21,0x22,0x21,0x22,0x21,0x22,0x21,0x22,0x21,
+ 0x22,0x21,0x22,0x24,0x25,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x05,0x04,0x05,0x0C,
+ 0x04,0x06,0x06,0x06,0x06,0x05,0x04,0x05,0x0A,0x0B,
+ 0x12,0x13,0x0C,0x0C,0x0D,0x0C,0x0D,0x0A,0x0B,0x0A,
+ 0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x07,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x79,0x41,0x41,0x41,0x2C,0x06,0x06,0x2D,0x41,0x41,
+ 0x42,0x06,0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x33,
+ 0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,
+ 0x19,0x19,0x19,0x28,0x06,0x06,0x06,0x06,0x06,0x28,
+ 0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,
+ 0x19,0x19,0x8A,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x06,0x06,0x12,0x13,0x06,0x06,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x1B,0x1C,
+ 0x1D,0x1E,0x1D,0x1E,0x1D,0x1E,0x1F,0x20,0x04,0x05,
+ 0x04,0x05,0x04,0x05,0x04,0x05,0x12,0x13,0x12,0x13,
+ 0x02,0x03,0x12,0x13,0x06,0x06,0x12,0x13,0x12,0x13,
+ 0x12,0x13,0x12,0x13,0x06,0x06,0x12,0x13,0x06,0x06,
+ 0x12,0x13,0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,
+ 0x10,0x11,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x12,0x13,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,0x12,0x13,
+ 0x06,0x06,0x04,0x05,0x04,0x05,0x04,0x0C,0x06,0x06,
+ 0x06,0x06,0x0D,0x0C,0x0D,0x00,0x01,0x0A,0x0B,0x04,
+ 0x04,0x05,0x04,0x05,0x00,0x01,0x00,0x01,0x12,0x13,
+ 0x12,0x13,0x12,0x13,0x06,0x06,0x12,0x13,0x12,0x13,
+ 0x06,0x06,0x31,0x06,0x06,0x06,0x0E,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x30,0x06,0x06,0x32,0x4E,0x4E,0x4F,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x06,0x06,0x26,0x26,0x26,0x26,
+ 0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,
+ 0x26,0x06,0x06,0x06,0x06,0x06,0x26,0x26,0x26,0x26,
+ 0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,
+ 0x06,0x06,0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x03,
+ 0x02,0x03,0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x06,0x06,0x0A,0x0B,0x06,0x06,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x29,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x2A,0x0C,0x0D,0x0C,0x0D,0x0C,
+ 0x0D,0x0C,0x0D,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0A,
+ 0x0B,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x06,0x06,0x0A,0x0B,0x06,0x06,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x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,0x12,0x13,0x12,0x13,
+ 0x00,0x01,0x00,0x01,0x12,0x13,0x00,0x01,0x12,0x13,
+ 0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,
+ 0x00,0x01,0x12,0x13,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x0A,0x0B,0x02,0x03,0x10,0x11,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x06,0x0C,0x04,0x05,0x12,0x13,
+ 0x04,0x0C,0x0D,0x06,0x06,0x0C,0x0D,0x0A,0x0B,0x10,
+ 0x11,0x0A,0x0B,0x04,0x04,0x05,0x04,0x05,0x10,0x11,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,
+ 0x00,0x01,0x00,0x01,0x12,0x13,0x06,0x06,0x06,0x06,
+ 0x07,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x30,0x06,0x06,0x32,0x08,
+ 0x08,0x09,0x06,0x06,0x06,0x06,0x0A,0x0B,0x02,0x03,
+ 0x02,0x03,0x02,0x03,0x00,0x01,0x00,0x01,0x12,0x13,
+ 0x12,0x13,0x06,0x06,0x06,0x06,0x06,0x06,0x12,0x13,
+ 0x12,0x13,0x12,0x13,0x12,0x13,0x06,0x06,0x06,0x06,
+ 0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13,
+ 0x12,0x13,0x12,0x13,0x12,0x13,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x02,0x03,0x06,0x06,0x06,0x06,0x06,0x06,0x02,0x03,
+ 0x00,0x01,0x00,0x01,0x00,0x0A,0x0B,0x06,0x06,0x50,
+ 0x51,0x17,0x18,0x0A,0x0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
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,
+ 0x06,0x06,0x12,0x13,0x06,0x06,0x06,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x02,0x03,0x06,0x06,0x06,0x06,0x31,0x06,
+ 0x02,0x03,0x02,0x03,0x12,0x13,0x39,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x9B,0x04,0x05,0x04,0x05,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x12,0x13,0x00,0x01,0x10,0x11,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x03,
+ 0x02,0x03,0x02,0x03,0x00,0x01,0x00,0x01,0x0A,0x0B,
+ 0x0A,0x0B,0x06,0x06,0x02,0x03,0x02,0x03,0x02,0x03,
+ 0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,
+ 0x02,0x03,0x02,0x03,0x00,0x01,0x00,0x01,0x06,0x04,
+ 0x04,0x05,0x00,0x01,0x04,0x0C,0x0D,0x0C,0x0C,0x0D,
+ 0x0C,0x0D,0x0D,0x06,0x06,0x17,0x18,0x04,0x04,0x05,
+ 0x04,0x05,0x04,0x05,0x02,0x03,0x02,0x03,0x02,0x03,
+ 0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x00,0x01,
+ 0x12,0x13,0x06,0x06,0x07,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x09,0x06,0x30,
+ 0x06,0x06,0x9B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x31,0x06,0x50,0x51,0x06,0x02,0x03,
+ 0x02,0x03,0x02,0x03,0x02,0x03,0x0A,0x0B,0x0A,0x0B,
+ 0x0A,0x0B,0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,
+ 0x06,0x06,0x06,0x06,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x02,0x03,0x00,0x01,0x06,0x06,0x06,0x06,0x06,0x0A,
+ 0x0B,0x06,0x06,0x06,0x00,0x01,0x00,0x01,0x00,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,
+ 0x06,0x0A,0x0B,0x3C,0x3D,0x3E,0x06,0x06,0x06,0x06,
+ 0x6B,0xA5,0xA6,0x0C,0x0D,0x0C,0x0D,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x17,0x18,0x0A,0x0B,0x02,
+ 0x03,0x02,0x03,0x02,0x03,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x00,0x01,0x00,0x01,0x12,
+ 0x13,0x12,0x13,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x06,0x0C,0x0C,0x0D,0x0A,
+ 0x0B,0x0C,0x04,0x05,0x04,0x05,0x04,0x05,0x04,0x05,
+ 0x04,0x05,0x04,0x05,0x04,0x0C,0x0D,0x0C,0x0D,0x0C,
+ 0x0D,0x06,0x06,0x06,0x06,0x06,0x06,0x02,0x03,0x00,
+ 0x01,0x00,0x01,0x00,0x01,0x0A,0x0B,0x0A,0x0B,0x06,
+ 0x06,0x0E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x09,0x06,0x2C,0x06,0x06,0x06,
+ 0x1D,0x1E,0x1D,0x1F,0x20,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x02,0x03,0x02,0x03,0x02,0x03,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0A,
+ 0x0B,0x06,0x06,0x06,0x06,0x06,0x02,0x03,0x06,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x06,0x06,0x12,0x13,
+ 0x06,0x06,0x12,0x13,0x06,0x06,0x06,0x06,0x02,0x03,
+ 0x46,0x47,0x39,0x06,0x06,0x06,0x06,0x9B,0x80,0xB6,
+ 0x04,0x05,0x04,0x05,0x10,0x11,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x10,0x11,0x12,0x13,0x02,0x03,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x12,0x13,0x06,0x06,0x02,0x03,
+ 0x02,0x03,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x02,0x03,
+ 0x02,0x03,0x06,0x04,0x04,0x05,0x10,0x11,0x04,0x0C,
+ 0x0D,0x0C,0x0D,0x0C,0x0D,0x0C,0x0D,0x06,0x06,0x06,
+ 0x0D,0x04,0x04,0x05,0x04,0x05,0x04,0x05,0x04,0x05,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,
+ 0x0A,0x0B,0x00,0x01,0x00,0x01,0x06,0x06,0x74,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x09,0x06,0x30,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x32,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x12,0x13,0x00,0x01,0x12,0x13,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x00,0x01,
+ 0x00,0x01,0x00,0x06,0x06,0x0A,0x0B,0x06,0x06,0x0A,
+ 0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x52,0x53,0x3C,
+ 0x3D,0x6C,0x6D,0xA5,0xA6,0xBF,0xC0,0x0C,0x0D,0x0C,
+ 0x0D,0x17,0x18,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x17,0x18,0x0A,
+ 0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x02,
+ 0x03,0x02,0x03,0x02,0x03,0x02,0x03,0x06,0x06,0x06,
+ 0x06,0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13,0x12,
+ 0x13,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x0C,0x0C,0x0D,0x17,0x18,0x0C,0x04,0x05,0x05,0x04,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0C,0x0C,
+ 0x0D,0x0C,0x0D,0x0C,0x0D,0x0C,0x0D,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x02,0x03,0x02,0x03,0x02,0x03,0x0A,
+ 0x0B,0x0A,0x0B,0x06,0x06,0x07,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x09,0x06,
+ 0x39,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x32,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x31,0x06,0x06,0x06,0x06,0x06,0x31,0x06,0x06,
+ 0x06,0x06,0x06,0x12,0x13,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x31,0x06,0x02,0x03,0x06,0x06,0x02,0x03,0x06,0x06,
+ 0x12,0x13,0x06,0x06,0x06,0x06,0x46,0x47,0x80,0x81,
+ 0x80,0xB6,0x44,0x45,0x04,0x05,0x04,0x05,0x04,0x05,
+ 0x02,0x03,0x02,0x03,0x02,0x03,0x0A,0x0B,0x0A,0x0B,
+ 0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x02,0x03,0x06,0x06,
+ 0x06,0x06,0x12,0x13,0x12,0x13,0x12,0x13,0x00,0x01,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,
+ 0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x04,0x05,
+ 0x04,0x05,0x04,0x0C,0x0D,0x0D,0x0C,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x00,0x01,0x00,0x01,
+ 0x06,0x06,0x74,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x09,0x06,0x39,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x9B,0x06,0x06,0x12,0x13,
+ 0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13,
+ 0x06,0x06,0x06,0x06,0x12,0x13,0x12,0x13,0x12,0x13,
+ 0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x12,0x13,0x06,0x06,0x12,0x13,
+ 0x12,0x13,0x00,0x01,0x00,0x01,0x00,0x06,0x31,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x06,
+ 0x06,0x06,0x06,0x52,0x53,0x8F,0x90,0xBF,0xC0,0x50,
+ 0x51,0x0C,0x0D,0x0C,0x0D,0x0C,0x0D,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x02,0x03,0x00,0x01,0x00,0x01,0x00,
+ 0x01,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0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,
+ 0x04,0x05,0x04,0x05,0x04,0x05,0x06,0x06,0x04,0x05,
+ 0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x02,0x03,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x12,0x13,0x0A,0x0B,0x12,0x13,
+ 0x12,0x13,0x12,0x13,0x12,0x13,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x17,0x18,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,
+ 0x0A,0x0B,0x06,0x06,0x12,0x13,0x12,0x13,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x31,
+ 0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x12,0x13,0x12,0x13,0x06,0x06,0x12,0x13,
+ 0x00,0x01,0x02,0x03,0x06,0x06,0x0E,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x09,
+ 0x06,0x46,0x47,0x81,0x80,0x81,0x81,0x80,0x81,0xDC,
+ 0x12,0x13,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x12,0x13,0x12,0x13,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x12,0x13,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0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06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x06,0x06,
+ 0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x06,0x06,0x04,0x05,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x12,0x13,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x02,0x03,0x02,0x03,0x02,0x03,0x00,0x01,
+ 0x06,0x06,0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,
+ 0x0A,0x0B,0x06,0x06,0x06,0x06,0x0A,0x0B,0x06,0x06,
+ 0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x02,0x03,
+ 0x02,0x03,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x05,0x04,0x05,0x05,0x04,0x05,
+ 0x04,0x05,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x05,0x04,0x05,0x00,0x01,0x00,0x01,
+ 0x06,0x06,0x00,0x01,0x00,0x01,0x12,0x13,0x12,0x13,
+ 0x07,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x09,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x12,0x13,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x03,
+ 0x02,0x03,0x02,0x03,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x02,0x03,0x02,0x03,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0C,
+ 0x0D,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x00,0x01,0x12,
+ 0x13,0x06,0x06,0x02,0x03,0x06,0x06,0x02,0x03,0x02,
+ 0x03,0x02,0x03,0x00,0x01,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x05,0x04,0x05,
+ 0x04,0x05,0x0C,0x0C,0x0D,0x0C,0x0D,0x0C,0x0C,0x05,
+ 0x04,0x05,0x06,0x06,0x06,0x06,0x06,0x05,0x04,0x05,
+ 0x05,0x04,0x05,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x74,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x5C,0x06,0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A
+};
+
+/* End of BIGMAP_MAP.C */
diff --git a/gbdk/gbdk-lib/examples/cross-platform/large_map/src/bigmap_map.h b/gbdk/gbdk-lib/examples/cross-platform/large_map/src/bigmap_map.h
new file mode 100644
index 00000000..4ab64633
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/large_map/src/bigmap_map.h
@@ -0,0 +1,32 @@
+/*
+
+ BIGMAP_MAP.H
+
+ Map Include File.
+
+ Info:
+ Section :
+ Bank : 0
+ Map size : 247 x 66
+ Tile set : bigmap_tiles.gbr
+ Plane count : 1 plane (8 bits)
+ Plane order : Planes are continues
+ Tile offset : 0
+ Split data : No
+
+ This file was generated by GBMB v1.8
+
+*/
+#ifndef __bigmap_map_h_INCLUDE
+#define __bigmap_map_h_INCLUDE
+
+#define bigmap_mapWidth 247
+#define bigmap_mapHeight 66
+#define bigmap_mapBank 0
+
+#define bigmap_map bigmap_mapPLN0
+extern const unsigned char bigmap_mapPLN0[];
+
+#endif
+
+/* End of BIGMAP_MAP.H */
diff --git a/gbdk/gbdk-lib/examples/cross-platform/large_map/src/bigmap_tiles.c b/gbdk/gbdk-lib/examples/cross-platform/large_map/src/bigmap_tiles.c
new file mode 100644
index 00000000..6cef85df
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/large_map/src/bigmap_tiles.c
@@ -0,0 +1,512 @@
+/*
+
+ BIGMAP_TILES.C
+
+ Tile Source File.
+
+ Info:
+ Form : All tiles as one unit.
+ Format : Gameboy 4 color.
+ Compression : None.
+ Counter : None.
+ Tile size : 8 x 8
+ Tiles : 0 to 240
+
+ Palette colors : Included.
+ SGB Palette : None.
+ CGB Palette : None.
+
+ Convert to metatiles : No.
+
+ This file was generated by GBTD v2.2
+
+*/
+
+/* Start of tile array. */
+const unsigned char bigmap_tiles[] =
+{
+ 0x5C,0x63,0x33,0x3C,0x2D,0x10,0x5A,0x20,
+ 0xDD,0x20,0xBF,0x40,0xBF,0x40,0x1B,0x64,
+ 0x02,0xFE,0xCC,0x3C,0x74,0x08,0xFA,0x04,
+ 0xFB,0x04,0xFB,0x06,0xD3,0x2E,0xC6,0x3E,
+ 0x5C,0x63,0x3B,0x37,0x3C,0x0F,0x6F,0x18,
+ 0xCD,0x3A,0xC9,0x3E,0x3C,0x03,0x0F,0x00,
+ 0x02,0xFE,0xCC,0xFC,0x7C,0xF0,0x76,0xF8,
+ 0x73,0xFC,0x73,0xFC,0x3C,0xC0,0xF0,0x00,
+ 0x00,0x22,0x14,0x41,0x22,0x49,0x1C,0x22,
+ 0x00,0x00,0x00,0x44,0x28,0x82,0x44,0x92,
+ 0x00,0x00,0x00,0x22,0x14,0x41,0x22,0x49,
+ 0x1C,0x22,0x00,0x00,0x00,0x44,0x28,0x82,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x17,0x10,0x17,0x30,0x67,0x10,0x77,0x08,
+ 0x3B,0x08,0x0B,0x38,0x7B,0x18,0xE7,0x30,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0xFC,0x0E,0xF4,0x06,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0x00,0xFF,0x00,0xFF,0x00,0x7F,0x80,
+ 0x9F,0x60,0x8F,0x30,0x2F,0x10,0x77,0x10,
+ 0x3C,0x03,0x0F,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x3C,0xC0,0xF0,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x38,0x00,0x44,0x00,
+ 0xBA,0x00,0xC6,0x82,0xDB,0xA7,0xDB,0xA6,
+ 0x00,0x00,0x00,0x00,0x38,0x00,0x44,0x00,
+ 0xBA,0x00,0xC6,0x82,0xDA,0xA6,0xFA,0xAE,
+ 0xFF,0x06,0xFD,0x1B,0xE6,0x31,0xF2,0x20,
+ 0xF8,0x20,0xE0,0x30,0xF0,0x40,0xE0,0x90,
+ 0xFF,0xFB,0x35,0xCE,0xBB,0x40,0x9A,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xFF,0xBE,0x4D,0xF3,0xAE,0x50,0xA6,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xFF,0xE0,0x5F,0xBF,0xCC,0x33,0x9C,0x00,
+ 0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xFF,0xEE,0xD5,0x3B,0xEC,0x03,0x69,0x00,
+ 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xFF,0x00,0xFF,0xF8,0xCF,0x36,0xC9,0x03,
+ 0x83,0x01,0x07,0x01,0x03,0x06,0x07,0x01,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0x41,0xBE,
+ 0x0C,0xF3,0xAE,0x50,0xA6,0x00,0x00,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0x1F,0xE0,
+ 0x40,0xBF,0xCC,0x33,0x9C,0x00,0x18,0x00,
+ 0xFF,0x00,0xFF,0x00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00,0x00,0x00,0x00,0x00,0x10,0x80,
+ 0x32,0xC4,0xAB,0xDC,0xF5,0x7F,0xF3,0x0F,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x30,0x00,0x70,0x80,0xE0,0x90,0x40,0xE0,
+ 0x00,0x00,0x0C,0x00,0x0E,0x01,0x06,0x09,
+ 0x01,0x1F,0x32,0x0E,0x1D,0x04,0x0E,0x1D,
+ 0x30,0x00,0x70,0x00,0x62,0x90,0x97,0xF8,
+ 0x9D,0x9A,0x6B,0x0F,0x10,0xE0,0x07,0xF8,
+ 0x00,0x00,0x00,0x00,0x06,0x80,0x07,0x88,
+ 0xCB,0x8C,0xED,0x9F,0x30,0x58,0xC4,0x73,
+ 0x0C,0x00,0x1C,0x00,0x58,0xE0,0x60,0xF8,
+ 0x80,0x8E,0x31,0x84,0x1F,0x68,0x0E,0xFC,
+ 0x40,0xE0,0xE0,0x90,0x70,0x80,0x30,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,
+ 0x04,0x00,0x0B,0x00,0x1C,0x18,0x1D,0x12,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x00,
+ 0x20,0x00,0xD0,0x00,0x30,0x10,0xD0,0x30,
+ 0xEB,0x5C,0xF1,0x3E,0xE3,0x3C,0xF7,0x28,
+ 0xFF,0x20,0xFB,0x44,0xFF,0x44,0xFF,0x44,
+ 0xF0,0x0F,0xE0,0x1F,0xE1,0x1E,0x47,0xBC,
+ 0x07,0xFC,0x8B,0x7C,0x99,0x76,0x9B,0x66,
+ 0x00,0x0F,0x00,0x30,0x00,0x40,0x03,0x40,
+ 0x3E,0x21,0x3B,0x3C,0x1D,0x13,0x1F,0x14,
+ 0x00,0x00,0x00,0x80,0x00,0x80,0x80,0x80,
+ 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
+ 0x00,0x00,0x00,0x01,0x00,0x01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0xFF,0x80,0xFF,0x80,
+ 0xC0,0xFF,0xFF,0x80,0xFF,0x80,0xFF,0x80,
+ 0x07,0xF9,0xFF,0x01,0xFF,0x01,0xFF,0x01,
+ 0x03,0xFF,0xFF,0x01,0xDF,0x21,0xFF,0x01,
+ 0xF0,0x30,0x70,0x30,0x62,0x30,0x76,0x38,
+ 0x6D,0x3B,0x6A,0x2E,0x71,0x20,0x64,0x3B,
+ 0x00,0x00,0x00,0x00,0x38,0x00,0x44,0x00,
+ 0xBA,0x00,0xC6,0x82,0xDA,0xA6,0xFB,0xAF,
+ 0x77,0x10,0x37,0x30,0xA3,0x34,0xCB,0x64,
+ 0x93,0x8C,0x47,0x38,0x87,0x78,0x17,0xE8,
+ 0xE0,0x0C,0xCC,0x10,0xF8,0x24,0xD0,0x18,
+ 0xA0,0x4C,0x93,0x64,0x97,0x68,0xDE,0x28,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x03,0x00,0x0D,0x00,0x31,0x00,0xD1,0x00,
+ 0x03,0x00,0x0D,0x00,0x31,0x00,0xD1,0x00,
+ 0x11,0x00,0x01,0x00,0x01,0x00,0x11,0x00,
+ 0xFF,0x00,0x10,0x00,0x10,0x00,0x00,0x00,
+ 0x10,0x00,0x00,0x00,0x10,0x00,0x10,0x00,
+ 0xFF,0x00,0x08,0x00,0x08,0x00,0x08,0x00,
+ 0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,
+ 0xC0,0x00,0xF0,0x00,0xAC,0x00,0xDF,0x00,
+ 0xAA,0x00,0xDD,0x00,0xAA,0x00,0xDD,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xC0,0x00,0xF0,0x00,0xAC,0x00,0xDF,0x00,
+ 0x40,0xBF,0xEE,0x11,0xFF,0x00,0xFF,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0x38,0xC7,0x00,0xFF,0xC7,0x38,0xFF,0x00,
+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10,0x9F,0x00,0x9C,0x01,0x90,
+ 0x01,0x80,0x01,0x80,0x11,0x80,0x12,0x81,
+ 0xEE,0x19,0xC6,0x39,0x42,0xBD,0x04,0xFF,
+ 0x87,0xFF,0xFF,0x78,0xFF,0x00,0x8E,0x00,
+ 0x33,0xCE,0x33,0xCE,0x33,0xCE,0x33,0xCE,
+ 0x97,0xEE,0xCF,0x3C,0xFE,0x00,0x7C,0x00,
+ 0x04,0xFB,0x03,0xFC,0x00,0xFF,0x10,0xEF,
+ 0x90,0x6F,0x52,0x8C,0x7F,0x80,0x47,0x80,
+ 0xA0,0x5F,0xC0,0x3F,0x00,0xFF,0x04,0xFB,
+ 0x0D,0xF2,0x4A,0x31,0xFE,0x01,0xE2,0x01,
+ 0xF8,0x40,0x78,0xC0,0xF8,0x80,0xF0,0x80,
+ 0xF0,0x00,0xE0,0x00,0xC0,0x00,0x00,0x00,
+ 0x02,0x03,0x02,0x03,0x06,0x03,0x07,0x01,
+ 0x07,0x01,0x03,0x00,0x01,0x00,0x00,0x00,
+ 0x1F,0x10,0x1F,0x10,0x0F,0x09,0x02,0x0F,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xC0,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x03,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xF8,0x08,0xF8,0x08,0xF0,0x90,0x40,0xF0,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x02,0x80,0x07,0x80,0x08,0x80,0x70,0x80,
+ 0x3C,0x80,0x07,0x80,0x78,0x00,0xFF,0x00,
+ 0x40,0x01,0xE0,0x01,0x10,0x01,0x0E,0x01,
+ 0x3C,0x01,0xE0,0x01,0x1E,0x00,0xFF,0x00,
+ 0xBF,0x00,0xCF,0x00,0xF0,0x00,0xFF,0x00,
+ 0x7F,0x00,0xFF,0x00,0xFE,0x00,0xFF,0x00,
+ 0xFD,0x00,0xF3,0x00,0x0F,0x00,0xFF,0x00,
+ 0xFE,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0x16,0x08,0x14,0x08,0x01,0x0C,0x11,0x06,
+ 0x02,0x01,0x05,0x00,0x03,0x00,0x05,0x00,
+ 0x68,0x10,0x28,0x10,0x80,0x30,0x88,0x60,
+ 0x40,0x80,0xA0,0x00,0xC0,0x00,0xA0,0x00,
+ 0xC9,0x3E,0x3C,0x03,0x0F,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x73,0xFC,0x3C,0xC0,0xF0,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,
+ 0x2C,0x10,0x18,0x24,0x00,0x38,0x30,0x0C,
+ 0x6B,0x04,0xB7,0x08,0x5E,0x08,0x7C,0x0E,
+ 0x05,0x00,0x03,0x00,0x05,0x00,0x02,0x01,
+ 0x11,0x06,0x01,0x0C,0x14,0x08,0x16,0x08,
+ 0x01,0x00,0x28,0x00,0x51,0x00,0x41,0xBE,
+ 0x0C,0xF3,0xAE,0x50,0xA6,0x00,0x00,0x00,
+ 0x80,0x00,0x02,0x00,0x55,0x00,0x1E,0xE0,
+ 0x40,0xBF,0xCC,0x33,0x9C,0x00,0x18,0x00,
+ 0x01,0x00,0x82,0x00,0x55,0x00,0x9E,0x60,
+ 0xC0,0x3F,0x4C,0xB3,0x1C,0x00,0x18,0x00,
+ 0xEC,0x06,0xBC,0x02,0x72,0x04,0xC3,0x1C,
+ 0xD1,0x2C,0x18,0xE0,0x08,0x60,0x40,0x00,
+ 0xF3,0x4C,0xF7,0x28,0xEF,0x30,0xFF,0x20,
+ 0xFF,0x20,0xFA,0x25,0xFE,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x20,0xCE,0x20,0xC0,0x20,
+ 0xDF,0x20,0xDF,0x20,0xF3,0x3F,0x19,0xDF,
+ 0x7C,0x83,0x71,0x8C,0x41,0xB0,0x11,0xC0,
+ 0x11,0x80,0x01,0x80,0x81,0x80,0x11,0x00,
+ 0x00,0xFF,0x10,0x00,0x10,0x00,0x00,0x00,
+ 0x10,0x00,0x00,0x00,0x10,0x00,0x10,0x00,
+ 0x00,0xFF,0x08,0x00,0x08,0x00,0x08,0x00,
+ 0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,
+ 0x3F,0xC0,0xCF,0x30,0xA3,0x0C,0xDC,0x03,
+ 0xAA,0x00,0xDD,0x00,0xAA,0x00,0xDD,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0x3F,0xC0,0xCF,0x30,0xA3,0x0C,0xDC,0x03,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0x9F,0x60,0x8F,0x30,0x2F,0x10,0x77,0x10,
+ 0xA0,0x00,0xC0,0x00,0xA0,0x00,0x40,0x80,
+ 0x88,0x60,0x80,0x30,0x28,0x10,0x68,0x10,
+ 0x10,0x0C,0x2C,0x10,0x18,0x24,0x00,0x38,
+ 0x30,0x0C,0x6B,0x04,0x77,0x08,0x5E,0x08,
+ 0x3C,0x0E,0x6C,0x06,0x57,0x08,0x3B,0x0C,
+ 0x30,0x0E,0x0C,0x10,0x26,0x18,0x10,0x0C,
+ 0x00,0x00,0x80,0x00,0xC2,0x10,0xD6,0x78,
+ 0x6C,0x9B,0xFD,0x0E,0xDF,0x00,0xF5,0x00,
+ 0x00,0x00,0x00,0x00,0x06,0x00,0x47,0x88,
+ 0xEB,0x9C,0x3C,0xDF,0xBF,0x78,0xAB,0x00
+};
+
+/* End of BIGMAP_TILES.C */
diff --git a/gbdk/gbdk-lib/examples/cross-platform/large_map/src/bigmap_tiles.h b/gbdk/gbdk-lib/examples/cross-platform/large_map/src/bigmap_tiles.h
new file mode 100644
index 00000000..708077e2
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/large_map/src/bigmap_tiles.h
@@ -0,0 +1,107 @@
+/*
+
+ BIGMAP_TILES.H
+
+ Include File.
+
+ Info:
+ Form : All tiles as one unit.
+ Format : Gameboy 4 color.
+ Compression : None.
+ Counter : None.
+ Tile size : 8 x 8
+ Tiles : 0 to 240
+
+ Palette colors : Included.
+ SGB Palette : None.
+ CGB Palette : None.
+
+ Convert to metatiles : No.
+
+ This file was generated by GBTD v2.2
+
+*/
+
+#ifndef __bigmap_tiles_h_INCLUDE
+#define __bigmap_tiles_h_INCLUDE
+
+/* Bank of tiles. */
+#define bigmap_tilesBank 0
+
+/* Super Gameboy palette 0 */
+#define bigmap_tilesSGBPal0c0 0
+#define bigmap_tilesSGBPal0c1 0
+#define bigmap_tilesSGBPal0c2 10240
+#define bigmap_tilesSGBPal0c3 400
+
+/* Super Gameboy palette 1 */
+#define bigmap_tilesSGBPal1c0 6076
+#define bigmap_tilesSGBPal1c1 8935
+#define bigmap_tilesSGBPal1c2 6596
+#define bigmap_tilesSGBPal1c3 5344
+
+/* Super Gameboy palette 2 */
+#define bigmap_tilesSGBPal2c0 6076
+#define bigmap_tilesSGBPal2c1 8935
+#define bigmap_tilesSGBPal2c2 6596
+#define bigmap_tilesSGBPal2c3 5344
+
+/* Super Gameboy palette 3 */
+#define bigmap_tilesSGBPal3c0 6076
+#define bigmap_tilesSGBPal3c1 8935
+#define bigmap_tilesSGBPal3c2 6596
+#define bigmap_tilesSGBPal3c3 5344
+
+/* Gameboy Color palette 0 */
+#define bigmap_tilesCGBPal0c0 0
+#define bigmap_tilesCGBPal0c1 10570
+#define bigmap_tilesCGBPal0c2 20083
+#define bigmap_tilesCGBPal0c3 32767
+
+/* Gameboy Color palette 1 */
+#define bigmap_tilesCGBPal1c0 6076
+#define bigmap_tilesCGBPal1c1 8935
+#define bigmap_tilesCGBPal1c2 6596
+#define bigmap_tilesCGBPal1c3 5344
+
+/* Gameboy Color palette 2 */
+#define bigmap_tilesCGBPal2c0 6076
+#define bigmap_tilesCGBPal2c1 8935
+#define bigmap_tilesCGBPal2c2 6596
+#define bigmap_tilesCGBPal2c3 5344
+
+/* Gameboy Color palette 3 */
+#define bigmap_tilesCGBPal3c0 6076
+#define bigmap_tilesCGBPal3c1 8935
+#define bigmap_tilesCGBPal3c2 6596
+#define bigmap_tilesCGBPal3c3 5344
+
+/* Gameboy Color palette 4 */
+#define bigmap_tilesCGBPal4c0 6076
+#define bigmap_tilesCGBPal4c1 8935
+#define bigmap_tilesCGBPal4c2 6596
+#define bigmap_tilesCGBPal4c3 5344
+
+/* Gameboy Color palette 5 */
+#define bigmap_tilesCGBPal5c0 6076
+#define bigmap_tilesCGBPal5c1 8935
+#define bigmap_tilesCGBPal5c2 6596
+#define bigmap_tilesCGBPal5c3 5344
+
+/* Gameboy Color palette 6 */
+#define bigmap_tilesCGBPal6c0 6076
+#define bigmap_tilesCGBPal6c1 8935
+#define bigmap_tilesCGBPal6c2 6596
+#define bigmap_tilesCGBPal6c3 5344
+
+/* Gameboy Color palette 7 */
+#define bigmap_tilesCGBPal7c0 6076
+#define bigmap_tilesCGBPal7c1 8935
+#define bigmap_tilesCGBPal7c2 6596
+#define bigmap_tilesCGBPal7c3 5344
+/* Start of tile array. */
+extern const unsigned char bigmap_tiles[];
+
+#endif
+
+/* End of BIGMAP_TILES.H */
diff --git a/gbdk/gbdk-lib/examples/cross-platform/large_map/src/large_map.c b/gbdk/gbdk-lib/examples/cross-platform/large_map/src/large_map.c
new file mode 100644
index 00000000..937e55f5
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/large_map/src/large_map.c
@@ -0,0 +1,104 @@
+#include <stdint.h>
+
+#include <gbdk/platform.h>
+
+#include "bigmap_map.h"
+#include "bigmap_tiles.h"
+
+#define camera_max_y ((bigmap_mapHeight - 18) * 8)
+#define camera_max_x ((bigmap_mapWidth - 20) * 8)
+
+#if defined(SEGA)
+ #define WRAP_SCROLL_Y(y) ((y) % 224u)
+#elif defined(NINTENDO)
+ #define WRAP_SCROLL_Y(y) y
+#endif
+
+#define MIN(A,B) ((A)<(B)?(A):(B))
+
+uint8_t joy;
+
+// current and old positions of the camera in pixels
+uint16_t camera_x, camera_y, old_camera_x, old_camera_y;
+// current and old position of the map in tiles
+uint8_t map_pos_x, map_pos_y, old_map_pos_x, old_map_pos_y;
+// redraw flag, indicates that camera position was changed
+uint8_t redraw;
+
+void set_camera() {
+ // update hardware scroll position
+ move_bkg(camera_x, WRAP_SCROLL_Y(camera_y));
+ // up or down
+ map_pos_y = (uint8_t)(camera_y >> 3u);
+ if (map_pos_y != old_map_pos_y) {
+ if (camera_y < old_camera_y) {
+ set_bkg_submap(map_pos_x, map_pos_y, MIN(21u, bigmap_mapWidth-map_pos_x), 1, bigmap_map, bigmap_mapWidth);
+ } else {
+ if ((bigmap_mapHeight - 18u) > map_pos_y) set_bkg_submap(map_pos_x, map_pos_y + 18u, MIN(21u, bigmap_mapWidth-map_pos_x), 1, bigmap_map, bigmap_mapWidth);
+ }
+ old_map_pos_y = map_pos_y;
+ }
+ // left or right
+ map_pos_x = (uint8_t)(camera_x >> 3u);
+ if (map_pos_x != old_map_pos_x) {
+ if (camera_x < old_camera_x) {
+ set_bkg_submap(map_pos_x, map_pos_y, 1, MIN(19u, bigmap_mapHeight - map_pos_y), bigmap_map, bigmap_mapWidth);
+ } else {
+ if ((bigmap_mapWidth - 20u) > map_pos_x) set_bkg_submap(map_pos_x + 20u, map_pos_y, 1, MIN(19u, bigmap_mapHeight - map_pos_y), bigmap_map, bigmap_mapWidth);
+ }
+ old_map_pos_x = map_pos_x;
+ }
+ // set old camera position to current camera position
+ old_camera_x = camera_x, old_camera_y = camera_y;
+}
+
+void main(){
+ DISPLAY_OFF;
+ set_2bpp_palette(COMPAT_PALETTE(11,5,4,3));
+ set_bkg_data(0, 241u, bigmap_tiles);
+
+ map_pos_x = map_pos_y = 0;
+ old_map_pos_x = old_map_pos_y = 255;
+ set_bkg_submap(map_pos_x, map_pos_y, 20, 18, bigmap_map, bigmap_mapWidth);
+
+ camera_x = camera_y = 0;
+ old_camera_x = camera_x; old_camera_y = camera_y;
+
+ redraw = FALSE;
+
+ move_bkg(camera_x, WRAP_SCROLL_Y(camera_y));
+ SHOW_BKG;
+ DISPLAY_ON;
+ while (TRUE) {
+ joy = joypad();
+ // up or down
+ if (joy & J_UP) {
+ if (camera_y) {
+ camera_y--;
+ redraw = TRUE;
+ }
+ } else if (joy & J_DOWN) {
+ if (camera_y < camera_max_y) {
+ camera_y++;
+ redraw = TRUE;
+ }
+ }
+ // left or right
+ if (joy & J_LEFT) {
+ if (camera_x) {
+ camera_x--;
+ redraw = TRUE;
+ }
+ } else if (joy & J_RIGHT) {
+ if (camera_x < camera_max_x) {
+ camera_x++;
+ redraw = TRUE;
+ }
+ }
+ if (redraw) {
+ wait_vbl_done();
+ set_camera();
+ redraw = FALSE;
+ } else wait_vbl_done();
+ }
+} \ No newline at end of file
diff --git a/gbdk/gbdk-lib/examples/cross-platform/logo/Makefile b/gbdk/gbdk-lib/examples/cross-platform/logo/Makefile
new file mode 100644
index 00000000..1961934c
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/logo/Makefile
@@ -0,0 +1,94 @@
+# If you move this project you can change the directory
+# to match your GBDK root directory (ex: GBDK_HOME = "C:/GBDK/"
+GBDK_HOME = ../../../
+LCC = $(GBDK_HOME)bin/lcc
+PNG2ASSETS = $(GBDK_HOME)bin/png2asset
+
+# Set platforms to build here, spaced separated. (These are in the separate Makefile.targets)
+# They can also be built/cleaned individually: "make gg" and "make gg-clean"
+# Possible are: gb gbc pocket megaduck sms gg
+TARGETS=gb gbc pocket megaduck sms gg
+
+# Configure platform specific LCC flags here:
+LCCFLAGS_gb = -Wl-yt0x1B # Set an MBC for banking (1B-ROM+MBC5+RAM+BATT)
+LCCFLAGS_pocket = -Wl-yt0x1B # Usually the same as required for .gb
+LCCFLAGS_duck = -Wl-yt0x1B # Usually the same as required for .gb
+LCCFLAGS_gbc = -Wl-yt0x1B -Wm-yc # Same as .gb with: -Wm-yc (gb & gbc) or Wm-yC (gbc exclusive)
+LCCFLAGS_sms =
+LCCFLAGS_gg =
+
+LCCFLAGS += $(LCCFLAGS_$(EXT)) # This adds the current platform specific LCC Flags
+
+LCCFLAGS += -Wl-j -Wm-yoA -Wm-ya4 -autobank -Wb-ext=.rel -Wb-v # MBC + Autobanking related flags
+# LCCFLAGS += -debug # Uncomment to enable debug output
+# LCCFLAGS += -v # Uncomment for lcc verbose output
+
+RESFLAGS_DMG = -map -noflip -bpp 2 -max_palettes 1 -pack_mode gb
+RESFLAGS_CGB = -map -use_map_attributes -bpp 2 -max_palettes 1 -pack_mode gb
+RESFLAGS_SEGA = -map -use_map_attributes -bpp 4 -max_palettes 2 -pack_mode sms
+
+RESFLAGS += $(RESFLAGS_$(TYP))
+
+CFLAGS += -I$(OBJDIR) -DSYSTEM_$(TYP)
+
+# You can set the name of the ROM file here
+PROJECTNAME = logo
+
+# EXT?=gb # Only sets extension to default (game boy .gb) if not populated
+SRCDIR = src
+OBJDIR = obj/$(EXT)
+RESDIR = res/$(TYP)
+BINDIR = build/$(EXT)
+MKDIRS = $(OBJDIR) $(BINDIR) # See bottom of Makefile for directory auto-creation
+
+BINS = $(OBJDIR)/$(PROJECTNAME).$(EXT)
+IMAGES = $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.png)))
+CSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.c)))
+ASMSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.s)))
+OBJS = $(IMAGES:%.png=$(OBJDIR)/%.o) $(CSOURCES:%.c=$(OBJDIR)/%.o) $(ASMSOURCES:%.s=$(OBJDIR)/%.o)
+
+# Builds all targets sequentially
+all: $(TARGETS)
+
+$(OBJDIR)/%.c: $(RESDIR)/%.png
+ $(PNG2ASSETS) $< $(RESFLAGS) -c $@
+
+$(OBJDIR)/%.o: $(OBJDIR)/%.c
+ $(LCC) $(CFLAGS) -c -o $@ $<
+
+# Compile .c files in "src/" to .o object files
+$(OBJDIR)/%.o: $(SRCDIR)/%.c
+ $(LCC) $(CFLAGS) -c -o $@ $<
+
+# Compile .c files in "res/" to .o object files
+$(OBJDIR)/%.o: $(RESDIR)/%.c
+ $(LCC) $(CFLAGS) -c -o $@ $<
+
+# Compile .s assembly files in "src/" to .o object files
+$(OBJDIR)/%.o: $(SRCDIR)/%.s
+ $(LCC) $(CFLAGS) -c -o $@ $<
+
+# If needed, compile .c files i n"src/" to .s assembly files
+# (not required if .c is compiled directly to .o)
+$(OBJDIR)/%.s: $(SRCDIR)/%.c
+ $(LCC) $(CFLAGS) -S -o $@ $<
+
+# Link the compiled object files into a .gb ROM file
+$(BINS): $(OBJS)
+ $(LCC) $(LCCFLAGS) $(CFLAGS) -o $(BINDIR)/$(PROJECTNAME).$(EXT) $(OBJS)
+
+clean:
+ @echo Cleaning
+ @for target in $(TARGETS); do \
+ $(MAKE) $$target-clean; \
+ done
+
+# Include available build targets
+include Makefile.targets
+
+
+# create necessary directories after Makefile is parsed but before build
+# info prevents the command from being pasted into the makefile
+ifneq ($(strip $(EXT)),) # Only make the directories if EXT has been set by a target
+$(info $(shell mkdir -p $(MKDIRS)))
+endif
diff --git a/gbdk/gbdk-lib/examples/cross-platform/logo/Makefile.targets b/gbdk/gbdk-lib/examples/cross-platform/logo/Makefile.targets
new file mode 100644
index 00000000..4115fafb
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/logo/Makefile.targets
@@ -0,0 +1,50 @@
+
+# Platform specific flags for compiling (only populate if they're both present)
+ifneq ($(strip $(PORT)),)
+ifneq ($(strip $(PLAT)),)
+CFLAGS += -m$(PORT):$(PLAT)
+endif
+endif
+
+# Called by the individual targets below to build a ROM
+build-target: $(BINS)
+
+clean-target:
+ rm -rf $(OBJDIR)
+ rm -rf $(BINDIR)
+
+gb-clean:
+ ${MAKE} clean-target EXT=gb
+gb:
+ ${MAKE} build-target PORT=sm83 PLAT=gb EXT=gb TYP=DMG
+
+
+gbc-clean:
+ ${MAKE} clean-target EXT=gbc
+gbc:
+ ${MAKE} build-target PORT=sm83 PLAT=gb EXT=gbc TYP=CGB
+
+
+pocket-clean:
+ ${MAKE} clean-target EXT=pocket
+pocket:
+ ${MAKE} build-target PORT=sm83 PLAT=ap EXT=pocket TYP=DMG
+
+
+megaduck-clean:
+ ${MAKE} clean-target EXT=duck
+megaduck:
+ ${MAKE} build-target PORT=sm83 PLAT=duck EXT=duck TYP=DMG
+
+
+sms-clean:
+ ${MAKE} clean-target EXT=sms
+sms:
+ ${MAKE} build-target PORT=z80 PLAT=sms EXT=sms TYP=SEGA
+
+
+gg-clean:
+ ${MAKE} clean-target EXT=gg
+gg:
+ ${MAKE} build-target PORT=z80 PLAT=gg EXT=gg TYP=SEGA
+
diff --git a/gbdk/gbdk-lib/examples/cross-platform/logo/Readme.md b/gbdk/gbdk-lib/examples/cross-platform/logo/Readme.md
new file mode 100644
index 00000000..ff3c9cb3
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/logo/Readme.md
@@ -0,0 +1,4 @@
+This project shows how assets can be managed for multiple different console targets together.
+
+`png2asset` is used to generate assets in the native format for each console at compile-time from separate source PNG images. The Makefile is set to use the source PNG folder which matches the current console being compiled, and the source code uses @ref set_native_tile_data() to load the assets tiles in native format.
+
diff --git a/gbdk/gbdk-lib/examples/cross-platform/logo/res/CGB/logo.png b/gbdk/gbdk-lib/examples/cross-platform/logo/res/CGB/logo.png
new file mode 100644
index 00000000..d32c6f46
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/logo/res/CGB/logo.png
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/cross-platform/logo/res/DMG/logo.png b/gbdk/gbdk-lib/examples/cross-platform/logo/res/DMG/logo.png
new file mode 100644
index 00000000..d32c6f46
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/logo/res/DMG/logo.png
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/cross-platform/logo/res/SEGA/logo.png b/gbdk/gbdk-lib/examples/cross-platform/logo/res/SEGA/logo.png
new file mode 100644
index 00000000..e1239090
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/logo/res/SEGA/logo.png
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/cross-platform/logo/src/main.c b/gbdk/gbdk-lib/examples/cross-platform/logo/src/main.c
new file mode 100644
index 00000000..b0415b22
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/logo/src/main.c
@@ -0,0 +1,24 @@
+#include <gbdk/platform.h>
+
+#include "logo.h"
+
+void main() {
+ fill_bkg_rect(0,0,DEVICE_SCREEN_WIDTH, DEVICE_SCREEN_HEIGHT, 0);
+#if defined(SYSTEM_SEGA)
+ set_palette(0, 1, logo_palettes);
+#elif defined(SYSTEM_CGB)
+ if (_cpu == CGB_TYPE) {
+ set_bkg_palette(0, 1, logo_palettes);
+ }
+#endif
+ set_native_tile_data(0, logo_TILE_COUNT, logo_tiles);
+#if defined(SYSTEM_CGB)
+ if (_cpu == CGB_TYPE) {
+ VBK_REG = 1;
+ set_tile_map(0, 0, logo_WIDTH >> 3, logo_HEIGHT >> 3, logo_map_attributes);
+ VBK_REG = 0;
+ }
+#endif
+ set_tile_map(0, 0, logo_WIDTH >> 3, logo_HEIGHT >> 3, logo_map);
+ SHOW_BKG;
+} \ No newline at end of file
diff --git a/gbdk/gbdk-lib/examples/cross-platform/metasprites/Makefile b/gbdk/gbdk-lib/examples/cross-platform/metasprites/Makefile
new file mode 100644
index 00000000..ef894948
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/metasprites/Makefile
@@ -0,0 +1,105 @@
+# If you move this project you can change the directory
+# to match your GBDK root directory (ex: GBDK_HOME = "C:/GBDK/"
+GBDK_HOME = ../../../
+LCC = $(GBDK_HOME)bin/lcc
+PNG2ASSET = $(GBDK_HOME)/bin/png2asset
+
+# Set platforms to build here, spaced separated. (These are in the separate Makefile.targets)
+# They can also be built/cleaned individually: "make gg" and "make gg-clean"
+# Possible are: gb gbc pocket megaduck sms gg
+TARGETS=gb pocket megaduck sms gg
+
+# Configure platform specific LCC flags here:
+LCCFLAGS_gb = -Wl-yt0x1B # Set an MBC for banking (1B-ROM+MBC5+RAM+BATT)
+LCCFLAGS_pocket = -Wl-yt0x1B # Usually the same as required for .gb
+LCCFLAGS_duck = -Wl-yt0x1B # Usually the same as required for .gb
+LCCFLAGS_gbc = -Wl-yt0x1B -Wm-yc # Same as .gb with: -Wm-yc (gb & gbc) or Wm-yC (gbc exclusive)
+LCCFLAGS_sms =
+LCCFLAGS_gg =
+
+LCCFLAGS += $(LCCFLAGS_$(EXT)) # This adds the current platform specific LCC Flags
+
+LCCFLAGS += -Wl-j -Wm-yoA -Wm-ya4 -autobank -Wb-ext=.rel -Wb-v # MBC + Autobanking related flags
+# LCCFLAGS += -debug # Uncomment to enable debug output
+# LCCFLAGS += -v # Uncomment for lcc verbose output
+
+# Add directory where platform specific meta tile sprites get converted into (obj/<platform ext>/src)
+# So they can be included with "#include <res/somefile.h>"
+CFLAGS += -I$(OBJDIR)
+
+# You can set the name of the ROM file here
+PROJECTNAME = metasprites
+
+SRCDIR = src
+OBJDIR = obj/$(EXT)
+RESOBJSRC = obj/$(EXT)/res
+RESDIR = res
+BINDIR = build/$(EXT)
+MKDIRS = $(OBJDIR) $(BINDIR) $(RESOBJSRC) # See bottom of Makefile for directory auto-creation
+
+BINS = $(OBJDIR)/$(PROJECTNAME).$(EXT)
+# For png2asset: converting metasprite source pngs -> .c -> .o
+METAPNGS = $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.png)))
+METASRCS = $(METAPNGS:%.png=$(RESOBJSRC)/%.c)
+METAOBJS = $(METASRCS:$(RESOBJSRC)/%.c=$(OBJDIR)/%.o)
+
+CSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.c))) $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.c)))
+ASMSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.s)))
+OBJS = $(CSOURCES:%.c=$(OBJDIR)/%.o) $(ASMSOURCES:%.s=$(OBJDIR)/%.o)
+
+
+# Builds all targets sequentially
+all: $(TARGETS)
+
+# Use png2asset to convert the png into C formatted metasprite data
+# -sh 48 : Sets sprite height to 48 (width remains automatic)
+# -spr8x16 : Use 8x16 hardware sprites
+# -c ... : Set C output file
+# Convert metasprite .pngs in res/ -> .c files in obj/<platform ext>/src/
+$(RESOBJSRC)/%.c: $(RESDIR)/%.png
+ $(PNG2ASSET) $< -sh 48 -spr8x16 -noflip -c $@
+
+# Compile the Metasprite pngs that were converted to .c files
+# .c files in obj/<platform ext>/src/ -> .o files in obj/
+$(OBJDIR)/%.o: $(RESOBJSRC)/%.c
+ $(LCC) $(CFLAGS) -c -o $@ $<
+
+# Compile .c files in "src/" to .o object files
+$(OBJDIR)/%.o: $(SRCDIR)/%.c
+ $(LCC) $(CFLAGS) -c -o $@ $<
+
+# Compile .c files in "res/" to .o object files
+$(OBJDIR)/%.o: $(RESDIR)/%.c
+ $(LCC) $(CFLAGS) -c -o $@ $<
+
+# Compile .s assembly files in "src/" to .o object files
+$(OBJDIR)/%.o: $(SRCDIR)/%.s
+ $(LCC) $(CFLAGS) -c -o $@ $<
+
+# If needed, compile .c files i n"src/" to .s assembly files
+# (not required if .c is compiled directly to .o)
+$(OBJDIR)/%.s: $(SRCDIR)/%.c
+ $(LCC) $(CFLAGS) -S -o $@ $<
+
+# Convert and build MetaSprites first so they're available when compiling the main sources
+$(OBJS): $(METAOBJS)
+
+# Link the compiled object files into a .gb ROM file
+$(BINS): $(OBJS)
+ $(LCC) $(LCCFLAGS) $(CFLAGS) -o $(BINDIR)/$(PROJECTNAME).$(EXT) $(METAOBJS) $(OBJS)
+
+clean:
+ @echo Cleaning
+ @for target in $(TARGETS); do \
+ $(MAKE) $$target-clean; \
+ done
+
+# Include available build targets
+include Makefile.targets
+
+
+# create necessary directories after Makefile is parsed but before build
+# info prevents the command from being pasted into the makefile
+ifneq ($(strip $(EXT)),) # Only make the directories if EXT has been set by a target
+$(info $(shell mkdir -p $(MKDIRS)))
+endif
diff --git a/gbdk/gbdk-lib/examples/cross-platform/metasprites/Makefile.targets b/gbdk/gbdk-lib/examples/cross-platform/metasprites/Makefile.targets
new file mode 100644
index 00000000..c502f12f
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/metasprites/Makefile.targets
@@ -0,0 +1,50 @@
+
+# Platform specific flags for compiling (only populate if they're both present)
+ifneq ($(strip $(PORT)),)
+ifneq ($(strip $(PLAT)),)
+CFLAGS += -m$(PORT):$(PLAT)
+endif
+endif
+
+# Called by the individual targets below to build a ROM
+build-target: $(BINS)
+
+clean-target:
+ rm -rf $(OBJDIR)
+ rm -rf $(BINDIR)
+
+gb-clean:
+ ${MAKE} clean-target EXT=gb
+gb:
+ ${MAKE} build-target PORT=sm83 PLAT=gb EXT=gb
+
+
+gbc-clean:
+ ${MAKE} clean-target EXT=gbc
+gbc:
+ ${MAKE} build-target PORT=sm83 PLAT=gb EXT=gbc
+
+
+pocket-clean:
+ ${MAKE} clean-target EXT=pocket
+pocket:
+ ${MAKE} build-target PORT=sm83 PLAT=ap EXT=pocket
+
+
+megaduck-clean:
+ ${MAKE} clean-target EXT=duck
+megaduck:
+ ${MAKE} build-target PORT=sm83 PLAT=duck EXT=duck
+
+
+sms-clean:
+ ${MAKE} clean-target EXT=sms
+sms:
+ ${MAKE} build-target PORT=z80 PLAT=sms EXT=sms
+
+
+gg-clean:
+ ${MAKE} clean-target EXT=gg
+gg:
+ ${MAKE} build-target PORT=z80 PLAT=gg EXT=gg
+
diff --git a/gbdk/gbdk-lib/examples/cross-platform/metasprites/res/sprite.png b/gbdk/gbdk-lib/examples/cross-platform/metasprites/res/sprite.png
new file mode 100644
index 00000000..aa0f74b9
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/metasprites/res/sprite.png
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/cross-platform/metasprites/src/metasprites.c b/gbdk/gbdk-lib/examples/cross-platform/metasprites/src/metasprites.c
new file mode 100644
index 00000000..28ac2a00
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/metasprites/src/metasprites.c
@@ -0,0 +1,139 @@
+#include <gbdk/platform.h>
+#include <gbdk/metasprites.h>
+
+#include <stdint.h>
+
+// During build, png2asset metasprite conversion will write output to: obj/<platform ext>/res/
+// Makefile adds part of that path as an include when compiling. Example: -Iobj/gb
+#include <res/sprite.h>
+
+
+const unsigned char pattern[] = {0x80,0x80,0x40,0x40,0x20,0x20,0x10,0x10,0x08,0x08,0x04,0x04,0x02,0x02,0x01,0x01};
+
+joypads_t joypads;
+
+#define ACC_X 1
+#define ACC_Y 2
+
+// The metasprite will be built starting with hardware sprite zero (the first)
+#define SPR_NUM_START 0
+
+// Metasprite tiles are loaded into VRAM starting at tile number 0
+#define TILE_NUM_START 0
+
+// sprite coords
+uint16_t PosX, PosY;
+int16_t SpdX, SpdY;
+uint8_t PosF;
+uint8_t hide, jitter;
+uint8_t idx;
+
+// main funxction
+void main(void) {
+ DISPLAY_OFF;
+
+ // Fill the screen background with a single tile pattern
+ fill_bkg_rect(0, 0, DEVICE_SCREEN_WIDTH, DEVICE_SCREEN_HEIGHT, 0);
+
+ // set tile data for background
+ set_bkg_data(0, 1, pattern);
+
+ // Load metasprite tile data into VRAM
+ set_sprite_data(TILE_NUM_START, sizeof(sprite_tiles) >> 4, sprite_tiles);
+
+ // show bkg and sprites
+ SHOW_BKG; SHOW_SPRITES;
+
+ // Check what size hardware sprite the metasprite is using (from sprite.h)
+ #if sprite_TILE_H == 16
+ SPRITES_8x16;
+ #else
+ SPRITES_8x8;
+ #endif
+ DISPLAY_ON;
+
+ // init 1 joypad
+ joypad_init(1, &joypads);
+
+ // Set initial position, zero out speed
+ PosX = PosY = 96 << 4;
+ SpdX = SpdY = 0;
+
+ hide = 0; jitter = 0; idx = 0;
+
+ while(1) {
+ // poll joypads
+ joypad_ex(&joypads);
+
+ PosF = 0;
+ // game object
+ if (joypads.joy0 & J_UP) {
+ SpdY -= 2;
+ if (SpdY < -32) SpdY = -32;
+ PosF |= ACC_Y;
+ } else if (joypads.joy0 & J_DOWN) {
+ SpdY += 2;
+ if (SpdY > 32) SpdY = 32;
+ PosF |= ACC_Y;
+ }
+
+ if (joypads.joy0 & J_LEFT) {
+ SpdX -= 2;
+ if (SpdX < -32) SpdX = -32;
+ PosF |= ACC_X;
+ } else if (joypads.joy0 & J_RIGHT) {
+ SpdX += 2;
+ if (SpdX > 32) SpdX = 32;
+ PosF |= ACC_X;
+ }
+
+
+ // Press A button to show/hide metasprite
+ if ((joypads.joy0 & J_A) && (!jitter)) {
+ hide = (!hide);
+ jitter = 20;
+ }
+
+ // Press B button to cycle through metasprite animations
+ if ((joypads.joy0 & J_B) && (!jitter) && (!hide)) {
+ idx++; if (idx >= (sizeof(sprite_metasprites) >> 1)) idx = 0;
+ jitter = 10;
+ }
+
+ // Hide/Animate/Flip input throttling
+ if (jitter) jitter--;
+
+ PosX += SpdX, PosY += SpdY;
+
+ uint8_t hiwater = 0;
+
+ // Hide the metasprite or move it
+ if (hide)
+ hide_metasprite(sprite_metasprites[idx], SPR_NUM_START);
+ else
+ hiwater = move_metasprite(sprite_metasprites[idx], TILE_NUM_START, SPR_NUM_START, (PosX >> 4), (PosY >> 4));
+
+ // Hide rest of the hardware sprites, because amount of sprites differ between animation frames.
+ hide_sprites_range(hiwater, MAX_HARDWARE_SPRITES);
+
+ // Y Axis: update velocity (reduce speed) if no U/D button pressed
+ if (!(PosF & ACC_Y)) {
+ if (SpdY != 0) {
+ if (SpdY < 0) SpdY++;
+ else SpdY --;
+ }
+ }
+
+ // X Axis: update velocity (reduce speed) if no L/R button pressed
+ if (!(PosF & ACC_X)) {
+ if (SpdX != 0) {
+ if (SpdX < 0) SpdX++;
+ else SpdX --;
+ }
+ }
+
+ // wait for VBlank to slow down everything and reduce cpu use when idle
+ wait_vbl_done();
+ }
+}
+
diff --git a/gbdk/gbdk-lib/examples/cross-platform/pong/Makefile b/gbdk/gbdk-lib/examples/cross-platform/pong/Makefile
new file mode 100644
index 00000000..0f6e2405
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/pong/Makefile
@@ -0,0 +1,78 @@
+# If you move this project you can change the directory
+# to match your GBDK root directory (ex: GBDK_HOME = "C:/GBDK/"
+GBDK_HOME = ../../../
+LCC = $(GBDK_HOME)bin/lcc
+
+# Set platforms to build here, spaced separated. (These are in the separate Makefile.targets)
+# They can also be built/cleaned individually: "make gg" and "make gg-clean"
+# Possible are: gb gbc pocket megaduck sms gg
+TARGETS=gb pocket megaduck sms gg
+
+# Configure platform specific LCC flags here:
+LCCFLAGS_gb = -Wm-ys -Wl-yt0x1B # Set an MBC for banking (1B-ROM+MBC5+RAM+BATT)
+LCCFLAGS_pocket = -Wm-ys -Wl-yt0x1B # Usually the same as required for .gb
+LCCFLAGS_duck = -Wm-ys -Wl-yt0x1B # Usually the same as required for .gb
+LCCFLAGS_gbc = -Wm-ys -Wl-yt0x1B -Wm-yc # Same as .gb with: -Wm-yc (gb & gbc) or Wm-yC (gbc exclusive)
+LCCFLAGS_sms =
+LCCFLAGS_gg =
+
+LCCFLAGS += $(LCCFLAGS_$(EXT)) # This adds the current platform specific LCC Flags
+
+LCCFLAGS += -Wl-j -Wm-yoA -Wm-ya4 -autobank -Wb-ext=.rel -Wb-v # MBC + Autobanking related flags
+# LCCFLAGS += -debug # Uncomment to enable debug output
+# LCCFLAGS += -v # Uncomment for lcc verbose output
+
+# You can set the name of the ROM file here
+PROJECTNAME = pong
+
+# EXT?=gb # Only sets extension to default (game boy .gb) if not populated
+SRCDIR = src
+OBJDIR = obj/$(EXT)
+RESDIR = res
+BINDIR = build/$(EXT)
+MKDIRS = $(OBJDIR) $(BINDIR) # See bottom of Makefile for directory auto-creation
+
+BINS = $(OBJDIR)/$(PROJECTNAME).$(EXT)
+CSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.c))) $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.c)))
+ASMSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.s)))
+OBJS = $(CSOURCES:%.c=$(OBJDIR)/%.o) $(ASMSOURCES:%.s=$(OBJDIR)/%.o)
+
+# Builds all targets sequentially
+all: $(TARGETS)
+
+# Compile .c files in "src/" to .o object files
+$(OBJDIR)/%.o: $(SRCDIR)/%.c
+ $(LCC) $(CFLAGS) -c -o $@ $<
+
+# Compile .c files in "res/" to .o object files
+$(OBJDIR)/%.o: $(RESDIR)/%.c
+ $(LCC) $(CFLAGS) -c -o $@ $<
+
+# Compile .s assembly files in "src/" to .o object files
+$(OBJDIR)/%.o: $(SRCDIR)/%.s
+ $(LCC) $(CFLAGS) -c -o $@ $<
+
+# If needed, compile .c files i n"src/" to .s assembly files
+# (not required if .c is compiled directly to .o)
+$(OBJDIR)/%.s: $(SRCDIR)/%.c
+ $(LCC) $(CFLAGS) -S -o $@ $<
+
+# Link the compiled object files into a .gb ROM file
+$(BINS): $(OBJS)
+ $(LCC) $(LCCFLAGS) $(CFLAGS) -o $(BINDIR)/$(PROJECTNAME).$(EXT) $(OBJS)
+
+clean:
+ @echo Cleaning
+ @for target in $(TARGETS); do \
+ $(MAKE) $$target-clean; \
+ done
+
+# Include available build targets
+include Makefile.targets
+
+
+# create necessary directories after Makefile is parsed but before build
+# info prevents the command from being pasted into the makefile
+ifneq ($(strip $(EXT)),) # Only make the directories if EXT has been set by a target
+$(info $(shell mkdir -p $(MKDIRS)))
+endif
diff --git a/gbdk/gbdk-lib/examples/cross-platform/pong/Makefile.targets b/gbdk/gbdk-lib/examples/cross-platform/pong/Makefile.targets
new file mode 100644
index 00000000..c502f12f
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/pong/Makefile.targets
@@ -0,0 +1,50 @@
+
+# Platform specific flags for compiling (only populate if they're both present)
+ifneq ($(strip $(PORT)),)
+ifneq ($(strip $(PLAT)),)
+CFLAGS += -m$(PORT):$(PLAT)
+endif
+endif
+
+# Called by the individual targets below to build a ROM
+build-target: $(BINS)
+
+clean-target:
+ rm -rf $(OBJDIR)
+ rm -rf $(BINDIR)
+
+gb-clean:
+ ${MAKE} clean-target EXT=gb
+gb:
+ ${MAKE} build-target PORT=sm83 PLAT=gb EXT=gb
+
+
+gbc-clean:
+ ${MAKE} clean-target EXT=gbc
+gbc:
+ ${MAKE} build-target PORT=sm83 PLAT=gb EXT=gbc
+
+
+pocket-clean:
+ ${MAKE} clean-target EXT=pocket
+pocket:
+ ${MAKE} build-target PORT=sm83 PLAT=ap EXT=pocket
+
+
+megaduck-clean:
+ ${MAKE} clean-target EXT=duck
+megaduck:
+ ${MAKE} build-target PORT=sm83 PLAT=duck EXT=duck
+
+
+sms-clean:
+ ${MAKE} clean-target EXT=sms
+sms:
+ ${MAKE} build-target PORT=z80 PLAT=sms EXT=sms
+
+
+gg-clean:
+ ${MAKE} clean-target EXT=gg
+gg:
+ ${MAKE} build-target PORT=z80 PLAT=gg EXT=gg
+
diff --git a/gbdk/gbdk-lib/examples/cross-platform/pong/src/pong.c b/gbdk/gbdk-lib/examples/cross-platform/pong/src/pong.c
new file mode 100644
index 00000000..c1c78699
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/pong/src/pong.c
@@ -0,0 +1,143 @@
+#include <gbdk/platform.h>
+#include <gbdk/console.h>
+
+#include <stdint.h>
+#include <stdio.h>
+
+uint8_t sprite_data[] = {
+ 0x3C,0x3C,0x42,0x7E,0x99,0xFF,0xA9,0xFF,0x89,0xFF,0x89,0xFF,0x42,0x7E,0x3C,0x3C,
+ 0x3C,0x3C,0x42,0x7E,0xB9,0xFF,0x89,0xFF,0x91,0xFF,0xB9,0xFF,0x42,0x7E,0x3C,0x3C,
+ 0x3C,0x3C,0x42,0x7E,0x99,0xFF,0x89,0xFF,0x99,0xFF,0x89,0xFF,0x5A,0x7E,0x3C,0x3C,
+ 0x3C,0x3C,0x42,0x7E,0xA9,0xFF,0xA9,0xFF,0xB9,0xFF,0x89,0xFF,0x42,0x7E,0x3C,0x3C
+
+};
+
+// initializes sprites for pad. every pad uses 3 sprites which id's are aligned by 4
+void init_pad(uint8_t n) {
+ set_sprite_tile(n << 2, n);
+ set_sprite_tile((n << 2) + 1, n);
+ set_sprite_tile((n << 2) + 2, n);
+}
+
+// inline function for moving pads; code of this function will be inlined with the code of main()
+inline void draw_pad(uint8_t n, uint8_t x, uint8_t y) {
+ move_sprite(n << 2, x, y);
+ move_sprite((n << 2) + 1, x, y + 8);
+ move_sprite((n << 2) + 2, x, y + 16);
+}
+
+joypads_t joypads;
+
+// absolute Y coordinates of player 1 & 2
+uint8_t player1, player2;
+uint16_t player1_score, player2_score;
+
+// player constraints
+#define YMIN 28
+#define YMAX 100
+#define PLAYER1_X DEVICE_SPRITE_PX_OFFSET_X
+#define PLAYER2_X (uint8_t)(DEVICE_SPRITE_PX_OFFSET_X + DEVICE_SCREEN_PX_WIDTH - 8)
+
+// coordinates and speeds of ball
+uint8_t ballX, ballY;
+int8_t spd_ballX, spd_ballY;
+
+#define INITBALLX 80 + 4
+#define INITBALLY 64 + 8
+
+const unsigned char HUD[] = " p1: %d p2: %d";
+
+// main funxction
+void main(void) {
+ // init palettes
+// BGP_REG = OBP0_REG = OBP1_REG = 0xE4;
+
+ // load tile data into VRAM
+ set_sprite_data(0, 4, sprite_data);
+
+ // init pad sprites
+ init_pad(0);
+ init_pad(1);
+
+ // init ball sprite
+ set_sprite_tile(3, 2);
+
+ // show bkg and sprites
+ SHOW_BKG; SHOW_SPRITES;
+
+ // init 2 joypads
+ if (joypad_init(2, &joypads) != 2) {
+ printf("Device must support\nat least two joypads");
+ return;
+ }
+
+ // init players
+ player1 = 64, player2 = 64;
+ player1_score = player2_score = 0;
+
+ // draw score
+ printf(HUD, player1_score, player2_score);
+
+ // init ball
+ ballX = INITBALLX, ballY = INITBALLY;
+ spd_ballX = 1, spd_ballY = 1;
+
+ while(1) {
+ // poll joypads
+ joypad_ex(&joypads);
+
+ // player 1
+ if (joypads.joy0 & J_UP) {
+ player1 -= 2;
+ if (player1 < YMIN) player1 = YMIN;
+ } else if (joypads.joy0 & J_DOWN) {
+ player1 += 2;
+ if (player1 > YMAX) player1 = YMAX;
+ }
+ draw_pad(0, PLAYER1_X, player1);
+
+ // player 2
+ if (joypads.joy1 & J_UP) {
+ player2 -= 2;
+ if (player2 < YMIN) player2 = YMIN;
+ } else if (joypads.joy1 & J_DOWN) {
+ player2 += 2;
+ if (player2 > YMAX) player2 = YMAX;
+ }
+ draw_pad(1, PLAYER2_X, player2);
+
+ // move ball
+ ballX += spd_ballX, ballY += spd_ballY;
+ // check bounce from limits
+ if ((ballY < YMIN) || (ballY > (YMAX + 24))) {
+ spd_ballY = -spd_ballY;
+ }
+ // check bounce from bats
+ if (ballX < (PLAYER1_X + 8)) {
+ if ((ballY > player1) && (ballY < (player1 + 24)) && (spd_ballX < 0))
+ spd_ballX = -spd_ballX;
+ } else if (ballX > (PLAYER2_X - 8)) {
+ if ((ballY > player2) && (ballY < (player2 + 24)) && (spd_ballX > 0))
+ spd_ballX = -spd_ballX;
+ }
+ // check player1 or 2 wins, update scores, start from center
+ if (ballX <= PLAYER1_X) {
+ // player2 wins
+ ballX = INITBALLX, ballY = INITBALLY;
+ spd_ballX = -spd_ballX;
+ player2_score++;
+ gotoxy(0, 0); printf(HUD, player1_score, player2_score);
+ } else if (ballX > PLAYER2_X) {
+ // player1 wins
+ ballX = INITBALLX, ballY = INITBALLY;
+ spd_ballX = -spd_ballX;
+ player1_score++;
+ gotoxy(0, 0); printf(HUD, player1_score, player2_score);
+ }
+ // move ball sprite
+ move_sprite(3, ballX, ballY);
+
+ // wait for VBlank to slow down everything
+ wait_vbl_done();
+ }
+} \ No newline at end of file
diff --git a/gbdk/gbdk-lib/examples/cross-platform/randtest/Makefile b/gbdk/gbdk-lib/examples/cross-platform/randtest/Makefile
new file mode 100644
index 00000000..bf2ae0c4
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/randtest/Makefile
@@ -0,0 +1,78 @@
+# If you move this project you can change the directory
+# to match your GBDK root directory (ex: GBDK_HOME = "C:/GBDK/"
+GBDK_HOME = ../../../
+LCC = $(GBDK_HOME)bin/lcc
+
+# Set platforms to build here, spaced separated. (These are in the separate Makefile.targets)
+# They can also be built/cleaned individually: "make gg" and "make gg-clean"
+# Possible are: gb gbc pocket megaduck sms gg
+TARGETS=gb pocket megaduck sms gg
+
+# Configure platform specific LCC flags here:
+LCCFLAGS_gb = -Wl-yt0x1B # Set an MBC for banking (1B-ROM+MBC5+RAM+BATT)
+LCCFLAGS_pocket = -Wl-yt0x1B # Usually the same as required for .gb
+LCCFLAGS_duck = -Wl-yt0x1B # Usually the same as required for .gb
+LCCFLAGS_gbc = -Wl-yt0x1B -Wm-yc # Same as .gb with: -Wm-yc (gb & gbc) or Wm-yC (gbc exclusive)
+LCCFLAGS_sms =
+LCCFLAGS_gg =
+
+LCCFLAGS += $(LCCFLAGS_$(EXT)) # This adds the current platform specific LCC Flags
+
+LCCFLAGS += -Wl-j -Wm-yoA -Wm-ya4 -autobank -Wb-ext=.rel -Wb-v # MBC + Autobanking related flags
+# LCCFLAGS += -debug # Uncomment to enable debug output
+# LCCFLAGS += -v # Uncomment for lcc verbose output
+
+# You can set the name of the ROM file here
+PROJECTNAME = testrand
+
+# EXT?=gb # Only sets extension to default (game boy .gb) if not populated
+SRCDIR = src
+OBJDIR = obj/$(EXT)
+RESDIR = res
+BINDIR = build/$(EXT)
+MKDIRS = $(OBJDIR) $(BINDIR) # See bottom of Makefile for directory auto-creation
+
+BINS = $(OBJDIR)/$(PROJECTNAME).$(EXT)
+CSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.c))) $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.c)))
+ASMSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.s)))
+OBJS = $(CSOURCES:%.c=$(OBJDIR)/%.o) $(ASMSOURCES:%.s=$(OBJDIR)/%.o)
+
+# Builds all targets sequentially
+all: $(TARGETS)
+
+# Compile .c files in "src/" to .o object files
+$(OBJDIR)/%.o: $(SRCDIR)/%.c
+ $(LCC) $(CFLAGS) -c -o $@ $<
+
+# Compile .c files in "res/" to .o object files
+$(OBJDIR)/%.o: $(RESDIR)/%.c
+ $(LCC) $(CFLAGS) -c -o $@ $<
+
+# Compile .s assembly files in "src/" to .o object files
+$(OBJDIR)/%.o: $(SRCDIR)/%.s
+ $(LCC) $(CFLAGS) -c -o $@ $<
+
+# If needed, compile .c files i n"src/" to .s assembly files
+# (not required if .c is compiled directly to .o)
+$(OBJDIR)/%.s: $(SRCDIR)/%.c
+ $(LCC) $(CFLAGS) -S -o $@ $<
+
+# Link the compiled object files into a .gb ROM file
+$(BINS): $(OBJS)
+ $(LCC) $(LCCFLAGS) $(CFLAGS) -o $(BINDIR)/$(PROJECTNAME).$(EXT) $(OBJS)
+
+clean:
+ @echo Cleaning
+ @for target in $(TARGETS); do \
+ $(MAKE) $$target-clean; \
+ done
+
+# Include available build targets
+include Makefile.targets
+
+
+# create necessary directories after Makefile is parsed but before build
+# info prevents the command from being pasted into the makefile
+ifneq ($(strip $(EXT)),) # Only make the directories if EXT has been set by a target
+$(info $(shell mkdir -p $(MKDIRS)))
+endif
diff --git a/gbdk/gbdk-lib/examples/cross-platform/randtest/Makefile.targets b/gbdk/gbdk-lib/examples/cross-platform/randtest/Makefile.targets
new file mode 100644
index 00000000..c502f12f
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/randtest/Makefile.targets
@@ -0,0 +1,50 @@
+
+# Platform specific flags for compiling (only populate if they're both present)
+ifneq ($(strip $(PORT)),)
+ifneq ($(strip $(PLAT)),)
+CFLAGS += -m$(PORT):$(PLAT)
+endif
+endif
+
+# Called by the individual targets below to build a ROM
+build-target: $(BINS)
+
+clean-target:
+ rm -rf $(OBJDIR)
+ rm -rf $(BINDIR)
+
+gb-clean:
+ ${MAKE} clean-target EXT=gb
+gb:
+ ${MAKE} build-target PORT=sm83 PLAT=gb EXT=gb
+
+
+gbc-clean:
+ ${MAKE} clean-target EXT=gbc
+gbc:
+ ${MAKE} build-target PORT=sm83 PLAT=gb EXT=gbc
+
+
+pocket-clean:
+ ${MAKE} clean-target EXT=pocket
+pocket:
+ ${MAKE} build-target PORT=sm83 PLAT=ap EXT=pocket
+
+
+megaduck-clean:
+ ${MAKE} clean-target EXT=duck
+megaduck:
+ ${MAKE} build-target PORT=sm83 PLAT=duck EXT=duck
+
+
+sms-clean:
+ ${MAKE} clean-target EXT=sms
+sms:
+ ${MAKE} build-target PORT=z80 PLAT=sms EXT=sms
+
+
+gg-clean:
+ ${MAKE} clean-target EXT=gg
+gg:
+ ${MAKE} build-target PORT=z80 PLAT=gg EXT=gg
+
diff --git a/gbdk/gbdk-lib/examples/cross-platform/randtest/src/testrand.c b/gbdk/gbdk-lib/examples/cross-platform/randtest/src/testrand.c
new file mode 100644
index 00000000..22ebf810
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/randtest/src/testrand.c
@@ -0,0 +1,26 @@
+/*
+ fonts.c
+ Simple example of how to use multiple fonts on the GB
+ Michael Hope, 1999.
+*/
+
+#include <stdio.h>
+#include <rand.h>
+
+#include <gbdk/platform.h>
+
+#include <gbdk/console.h>
+
+void main(void)
+{
+ while(TRUE) {
+ puts("press A...");
+ waitpad(J_A);
+ initarand(sys_time);
+ for (uint8_t i = 0; i != 16; i++)
+ printf("rand=%hx arand=%hx\n", (uint8_t)rand(), (uint8_t)arand());
+ }
+}
+
+
+
diff --git a/gbdk/gbdk-lib/examples/cross-platform/rle_map/Makefile b/gbdk/gbdk-lib/examples/cross-platform/rle_map/Makefile
new file mode 100644
index 00000000..e9219f17
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/rle_map/Makefile
@@ -0,0 +1,92 @@
+SHELL := /bin/bash
+
+# If you move this project you can change the directory
+# to match your GBDK root directory (ex: GBDK_HOME = "C:/GBDK/"
+GBDK_HOME = ../../../
+LCC = $(GBDK_HOME)bin/lcc
+
+# Set platforms to build here, spaced separated. (These are in the separate Makefile.targets)
+# They can also be built/cleaned individually: "make gg" and "make gg-clean"
+# Possible are: gb gbc pocket megaduck sms gg
+#TARGETS=gb pocket sms gg
+TARGETS=gb gg
+
+# Configure platform specific LCC flags here:
+LCCFLAGS_gb = -Wl-yt0x19 -Wl-yo4 -Wm-yS -Wm-yn"$(PROJECTNAME)"
+LCCFLAGS_pocket = -Wl-yt0x19 -Wl-yo4 -Wm-yS -Wm-yn"$(PROJECTNAME)"
+LCCFLAGS_duck = -Wl-yt0x19 -Wl-yo4 -Wm-yS -Wm-yn"$(PROJECTNAME)"
+LCCFLAGS_sms = -Wl-yo4 -Wm-yS
+LCCFLAGS_gg = -Wl-yo4 -Wm-yS
+
+LCCFLAGS += $(LCCFLAGS_$(EXT)) # This adds the current platform specific LCC Flags
+
+# LCCFLAGS += -Wl-j -Wm-yoA -Wm-ya4 -autobank -Wb-ext=.rel -Wb-v # MBC + Autobanking related flags
+LCCFLAGS += -Wl-j
+# LCCFLAGS += -debug # Uncomment to enable debug output
+# LCCFLAGS += -v # Uncomment for lcc verbose output
+
+CFLAGS = -Wf-Iinclude
+
+# You can set the name of the ROM file here
+PROJECTNAME = rledecompress
+
+# EXT?=gb # Only sets extension to default (game boy .gb) if not populated
+SRCDIR = src
+SRCPLAT = src/$(PORT)
+OBJDIR = obj/$(EXT)
+RESDIR = res
+BINDIR = build/$(EXT)
+MKDIRS = $(OBJDIR) $(BINDIR) # See bottom of Makefile for directory auto-creation
+
+BINS = $(OBJDIR)/$(PROJECTNAME).$(EXT)
+CSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.c))) $(foreach dir,$(SRCPLAT),$(notdir $(wildcard $(dir)/*.c))) $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.c)))
+ASMSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.s))) $(foreach dir,$(SRCPLAT),$(notdir $(wildcard $(dir)/*.s)))
+OBJS = $(CSOURCES:%.c=$(OBJDIR)/%.o) $(ASMSOURCES:%.s=$(OBJDIR)/%.o)
+
+# Builds all targets sequentially
+all: $(TARGETS)
+
+# Compile .c files in "src/" to .o object files
+$(OBJDIR)/%.o: $(SRCDIR)/%.c
+ $(LCC) $(CFLAGS) -c -o $@ $<
+
+# Compile .c files in "src/<target>/" to .o object files
+$(OBJDIR)/%.o: $(SRCPLAT)/%.c
+ $(LCC) $(CFLAGS) -c -o $@ $<
+
+# Compile .c files in "res/" to .o object files
+$(OBJDIR)/%.o: $(RESDIR)/%.c
+ $(LCC) $(CFLAGS) -c -o $@ $<
+
+# Compile .s assembly files in "src/<target>/" to .o object files
+$(OBJDIR)/%.o: $(SRCPLAT)/%.s
+ $(LCC) $(CFLAGS) -c -o $@ $<
+
+# Compile .s assembly files in "src/" to .o object files
+$(OBJDIR)/%.o: $(SRCDIR)/%.s
+ $(LCC) $(CFLAGS) -c -o $@ $<
+
+# If needed, compile .c files i n"src/" to .s assembly files
+# (not required if .c is compiled directly to .o)
+$(OBJDIR)/%.s: $(SRCDIR)/%.c
+ $(LCC) $(CFLAGS) -S -o $@ $<
+
+# Link the compiled object files into a .gb ROM file
+$(BINS): $(OBJS)
+ $(LCC) $(LCCFLAGS) $(CFLAGS) -o $(BINDIR)/$(PROJECTNAME).$(EXT) $(OBJS)
+
+clean:
+ @echo Cleaning
+ @for target in $(TARGETS); do \
+ $(MAKE) $$target-clean; \
+ done
+
+# Include available build targets
+include Makefile.targets
+
+
+# create necessary directories after Makefile is parsed but before build
+# info prevents the command from being pasted into the makefile
+ifneq ($(strip $(EXT)),) # Only make the directories if EXT has been set by a target
+$(info $(shell mkdir -p $(MKDIRS)))
+endif
diff --git a/gbdk/gbdk-lib/examples/cross-platform/rle_map/Makefile.targets b/gbdk/gbdk-lib/examples/cross-platform/rle_map/Makefile.targets
new file mode 100644
index 00000000..c502f12f
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/rle_map/Makefile.targets
@@ -0,0 +1,50 @@
+
+# Platform specific flags for compiling (only populate if they're both present)
+ifneq ($(strip $(PORT)),)
+ifneq ($(strip $(PLAT)),)
+CFLAGS += -m$(PORT):$(PLAT)
+endif
+endif
+
+# Called by the individual targets below to build a ROM
+build-target: $(BINS)
+
+clean-target:
+ rm -rf $(OBJDIR)
+ rm -rf $(BINDIR)
+
+gb-clean:
+ ${MAKE} clean-target EXT=gb
+gb:
+ ${MAKE} build-target PORT=sm83 PLAT=gb EXT=gb
+
+
+gbc-clean:
+ ${MAKE} clean-target EXT=gbc
+gbc:
+ ${MAKE} build-target PORT=sm83 PLAT=gb EXT=gbc
+
+
+pocket-clean:
+ ${MAKE} clean-target EXT=pocket
+pocket:
+ ${MAKE} build-target PORT=sm83 PLAT=ap EXT=pocket
+
+
+megaduck-clean:
+ ${MAKE} clean-target EXT=duck
+megaduck:
+ ${MAKE} build-target PORT=sm83 PLAT=duck EXT=duck
+
+
+sms-clean:
+ ${MAKE} clean-target EXT=sms
+sms:
+ ${MAKE} build-target PORT=z80 PLAT=sms EXT=sms
+
+
+gg-clean:
+ ${MAKE} clean-target EXT=gg
+gg:
+ ${MAKE} build-target PORT=z80 PLAT=gg EXT=gg
+
diff --git a/gbdk/gbdk-lib/examples/cross-platform/rle_map/Readme.md b/gbdk/gbdk-lib/examples/cross-platform/rle_map/Readme.md
new file mode 100644
index 00000000..ae73ba46
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/rle_map/Readme.md
@@ -0,0 +1,21 @@
+
+RLE Decompress
+============
+
+Demonstrates using rle_decompress to load a compressed tile map into vram.
+
+## Map Data encoding
+The Tile Map is exported in binary format (one map entry per byte) and encoded in sequential **columns** 20 tiles high.
+
+The data is compressed using the `gbcompress` utility using the `--alg=rle` argument.
+
+`gbcompress --alg=rle map.bin map.bin.rle`
+
+## Display
+As the program scrolls, a new column is drawn once for every 8 pixels scrolled. The Tile Map data is decoded 20 tiles at a time (column height) and rendered to the next (just barely off-screen) column on the right.
+
+## Graphics
+The tileset graphics are by GrafxKid under CC0 license:
+
+https://opengameart.org/content/cave-tileset-4
+
diff --git a/gbdk/gbdk-lib/examples/cross-platform/rle_map/res/asset_sources/map.bin b/gbdk/gbdk-lib/examples/cross-platform/rle_map/res/asset_sources/map.bin
new file mode 100644
index 00000000..dbda31fa
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/rle_map/res/asset_sources/map.bin
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/cross-platform/rle_map/res/asset_sources/map.gbm b/gbdk/gbdk-lib/examples/cross-platform/rle_map/res/asset_sources/map.gbm
new file mode 100644
index 00000000..ee0c5513
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/rle_map/res/asset_sources/map.gbm
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/cross-platform/rle_map/res/asset_sources/map.png b/gbdk/gbdk-lib/examples/cross-platform/rle_map/res/asset_sources/map.png
new file mode 100644
index 00000000..106d5ee6
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/rle_map/res/asset_sources/map.png
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/cross-platform/rle_map/res/asset_sources/map_tiles.gbr b/gbdk/gbdk-lib/examples/cross-platform/rle_map/res/asset_sources/map_tiles.gbr
new file mode 100644
index 00000000..3a00cfc2
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/rle_map/res/asset_sources/map_tiles.gbr
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/cross-platform/rle_map/res/map.bin.rle b/gbdk/gbdk-lib/examples/cross-platform/rle_map/res/map.bin.rle
new file mode 100644
index 00000000..f9ff0aa7
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/rle_map/res/map.bin.rle
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/cross-platform/rle_map/res/map_tiles.bin b/gbdk/gbdk-lib/examples/cross-platform/rle_map/res/map_tiles.bin
new file mode 100644
index 00000000..d259f426
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/rle_map/res/map_tiles.bin
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/cross-platform/rle_map/src/main.c b/gbdk/gbdk-lib/examples/cross-platform/rle_map/src/main.c
new file mode 100644
index 00000000..7cc81b5b
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/rle_map/src/main.c
@@ -0,0 +1,81 @@
+#include <gbdk/platform.h>
+#include <gbdk/incbin.h>
+#include <stdbool.h>
+
+#include <gbdk/rledecompress.h>
+
+// The Tile data is not compressed
+INCBIN(map_tiles, "res/map_tiles.bin")
+INCBIN_EXTERN(map_tiles)
+
+// The Map data is compressed using: gbcompress --alg=rle
+// The map is ordered in sequential columns 18 tiles high
+// so it's easy to load one entire screen column worth at a time.
+#define MAP_DATA_HEIGHT 18
+INCBIN(map_compressed, "res/map.bin.rle")
+INCBIN_EXTERN(map_compressed)
+
+uint8_t data[32][MAP_DATA_HEIGHT]; // Collision map buffer
+uint8_t scrollpos = 0; // Scroll position in pixels
+uint8_t datapos = 0; // x position in tiles inside the collision map
+
+void main() {
+
+ SHOW_BKG;
+
+ // Load Tile data
+ set_bkg_data(0, INCBIN_SIZE(map_tiles) >> 4, map_tiles);
+
+ // Initialize decompressor with Map data
+ rle_init(map_compressed);
+
+ // To get started, decompress and display a whole screen worth,
+ // + 1 additional column in the direction being scrolled (to
+ // avoid screen tearing from drawing a column right as it scrolls into view)
+ uint8_t * data_ptr = &data[0][0];
+ for (uint8_t i = 0; (rle_decompress(data_ptr, MAP_DATA_HEIGHT)) && (i != DEVICE_SCREEN_WIDTH + 1); i++) {
+ // pre-process column here
+ // ...
+
+ // Draw current column starting at row 0
+ set_bkg_tiles(i, 0, 1, MAP_DATA_HEIGHT, data_ptr);
+ }
+
+ // main game loop
+ datapos = scrollpos = 0;
+ while(TRUE) {
+
+ wait_vbl_done();
+
+ // Scroll one pixel to the right
+ // (This should be done as close to wait_vbl_done and before
+ // the map drawing below to avoid tearing at the top of the screen)
+ scrollpos++;
+ move_bkg(scrollpos, 0);
+
+ // Once for every 8 pixels scrolled: draw a
+ // new column of tiles on the right-most edge
+ // ( == 1 is used here so it triggers on the very first pass)
+ if ((scrollpos & 0x07u) == 1) {
+
+ // Get hardware map tile X column from scroll position / 8
+ // Then + 1 since there's a 1 tile column buffer on the right edge
+ datapos = (scrollpos >> 3) + 1;
+ uint8_t map_x_column = (datapos + DEVICE_SCREEN_WIDTH) & 31;
+
+ // Decompress a column worth of data
+ data_ptr = &data[map_x_column][0];
+ // If the end of compressed data is reached, reset decompression
+ // and resume at the start (to make infinite scrolling)
+ if (!rle_decompress(data_ptr, MAP_DATA_HEIGHT)) {
+ rle_init(map_compressed);
+ rle_decompress(data_ptr, MAP_DATA_HEIGHT);
+ }
+ // pre-process column here
+ // ...
+
+ // Display column
+ set_bkg_tiles(map_x_column, 0, 1, MAP_DATA_HEIGHT, data_ptr);
+ }
+ }
+}
diff --git a/gbdk/gbdk-lib/examples/cross-platform/scroller/Makefile b/gbdk/gbdk-lib/examples/cross-platform/scroller/Makefile
new file mode 100644
index 00000000..0e0111d7
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/scroller/Makefile
@@ -0,0 +1,78 @@
+# If you move this project you can change the directory
+# to match your GBDK root directory (ex: GBDK_HOME = "C:/GBDK/"
+GBDK_HOME = ../../../
+LCC = $(GBDK_HOME)bin/lcc
+
+# Set platforms to build here, spaced separated. (These are in the separate Makefile.targets)
+# They can also be built/cleaned individually: "make gg" and "make gg-clean"
+# Possible are: gb gbc pocket megaduck sms gg
+TARGETS=gb pocket megaduck sms gg
+
+# Configure platform specific LCC flags here:
+LCCFLAGS_gb = -Wl-yt0x1B # Set an MBC for banking (1B-ROM+MBC5+RAM+BATT)
+LCCFLAGS_pocket = -Wl-yt0x1B # Usually the same as required for .gb
+LCCFLAGS_duck = -Wl-yt0x1B # Usually the same as required for .gb
+LCCFLAGS_gbc = -Wl-yt0x1B -Wm-yc # Same as .gb with: -Wm-yc (gb & gbc) or Wm-yC (gbc exclusive)
+LCCFLAGS_sms =
+LCCFLAGS_gg =
+
+LCCFLAGS += $(LCCFLAGS_$(EXT)) # This adds the current platform specific LCC Flags
+
+LCCFLAGS += -Wl-j -Wm-yS -Wm-yoA -Wm-ya4 -autobank -Wb-ext=.rel -Wb-v # MBC + Autobanking related flags
+# LCCFLAGS += -debug # Uncomment to enable debug output
+# LCCFLAGS += -v # Uncomment for lcc verbose output
+
+# You can set the name of the ROM file here
+PROJECTNAME = scroller
+
+# EXT?=gb # Only sets extension to default (game boy .gb) if not populated
+SRCDIR = src
+OBJDIR = obj/$(EXT)
+RESDIR = res
+BINDIR = build/$(EXT)
+MKDIRS = $(OBJDIR) $(BINDIR) # See bottom of Makefile for directory auto-creation
+
+BINS = $(OBJDIR)/$(PROJECTNAME).$(EXT)
+CSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.c))) $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.c)))
+ASMSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.s)))
+OBJS = $(CSOURCES:%.c=$(OBJDIR)/%.o) $(ASMSOURCES:%.s=$(OBJDIR)/%.o)
+
+# Builds all targets sequentially
+all: $(TARGETS)
+
+# Compile .c files in "src/" to .o object files
+$(OBJDIR)/%.o: $(SRCDIR)/%.c
+ $(LCC) $(CFLAGS) -c -o $@ $<
+
+# Compile .c files in "res/" to .o object files
+$(OBJDIR)/%.o: $(RESDIR)/%.c
+ $(LCC) $(CFLAGS) -c -o $@ $<
+
+# Compile .s assembly files in "src/" to .o object files
+$(OBJDIR)/%.o: $(SRCDIR)/%.s
+ $(LCC) $(CFLAGS) -c -o $@ $<
+
+# If needed, compile .c files i n"src/" to .s assembly files
+# (not required if .c is compiled directly to .o)
+$(OBJDIR)/%.s: $(SRCDIR)/%.c
+ $(LCC) $(CFLAGS) -S -o $@ $<
+
+# Link the compiled object files into a .gb ROM file
+$(BINS): $(OBJS)
+ $(LCC) $(LCCFLAGS) $(CFLAGS) -o $(BINDIR)/$(PROJECTNAME).$(EXT) $(OBJS)
+
+clean:
+ @echo Cleaning
+ @for target in $(TARGETS); do \
+ $(MAKE) $$target-clean; \
+ done
+
+# Include available build targets
+include Makefile.targets
+
+
+# create necessary directories after Makefile is parsed but before build
+# info prevents the command from being pasted into the makefile
+ifneq ($(strip $(EXT)),) # Only make the directories if EXT has been set by a target
+$(info $(shell mkdir -p $(MKDIRS)))
+endif
diff --git a/gbdk/gbdk-lib/examples/cross-platform/scroller/Makefile.targets b/gbdk/gbdk-lib/examples/cross-platform/scroller/Makefile.targets
new file mode 100644
index 00000000..c502f12f
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/scroller/Makefile.targets
@@ -0,0 +1,50 @@
+
+# Platform specific flags for compiling (only populate if they're both present)
+ifneq ($(strip $(PORT)),)
+ifneq ($(strip $(PLAT)),)
+CFLAGS += -m$(PORT):$(PLAT)
+endif
+endif
+
+# Called by the individual targets below to build a ROM
+build-target: $(BINS)
+
+clean-target:
+ rm -rf $(OBJDIR)
+ rm -rf $(BINDIR)
+
+gb-clean:
+ ${MAKE} clean-target EXT=gb
+gb:
+ ${MAKE} build-target PORT=sm83 PLAT=gb EXT=gb
+
+
+gbc-clean:
+ ${MAKE} clean-target EXT=gbc
+gbc:
+ ${MAKE} build-target PORT=sm83 PLAT=gb EXT=gbc
+
+
+pocket-clean:
+ ${MAKE} clean-target EXT=pocket
+pocket:
+ ${MAKE} build-target PORT=sm83 PLAT=ap EXT=pocket
+
+
+megaduck-clean:
+ ${MAKE} clean-target EXT=duck
+megaduck:
+ ${MAKE} build-target PORT=sm83 PLAT=duck EXT=duck
+
+
+sms-clean:
+ ${MAKE} clean-target EXT=sms
+sms:
+ ${MAKE} build-target PORT=z80 PLAT=sms EXT=sms
+
+
+gg-clean:
+ ${MAKE} clean-target EXT=gg
+gg:
+ ${MAKE} build-target PORT=z80 PLAT=gg EXT=gg
+
diff --git a/gbdk/gbdk-lib/examples/cross-platform/scroller/src/text_scroller.c b/gbdk/gbdk-lib/examples/cross-platform/scroller/src/text_scroller.c
new file mode 100644
index 00000000..8fe36d49
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/cross-platform/scroller/src/text_scroller.c
@@ -0,0 +1,87 @@
+#include <gbdk/platform.h>
+#include <stdint.h>
+#include <stdio.h>
+
+const uint8_t scanline_offsets_tbl[] = {0, 1, 2, 3, 3, 2, 1, 0, 0, 1, 2, 3, 3, 2, 1, 0};
+const uint8_t * scanline_offsets = scanline_offsets_tbl;
+
+#define SCROLL_POS 15
+#define SCROLL_POS_PIX_START ((SCROLL_POS + DEVICE_SCREEN_Y_OFFSET) * 8) - 1
+#define SCROLL_POS_PIX_END ((SCROLL_POS + DEVICE_SCREEN_X_OFFSET + 1) * 8) - 1
+
+uint8_t scroller_x = 0;
+void scanline_isr() {
+#if defined(NINTENDO)
+ switch (LYC_REG) {
+ case 0:
+ SCX_REG = 0;
+ LYC_REG = SCROLL_POS_PIX_START;
+ break;
+ case SCROLL_POS_PIX_START:
+ SCX_REG = scroller_x;
+ LYC_REG = SCROLL_POS_PIX_END;
+ break;
+ case SCROLL_POS_PIX_END:
+ SCX_REG = LYC_REG = 0;
+ break;
+ }
+#elif defined(SEGA)
+ if (VCOUNTER == (SCROLL_POS_PIX_START - 8)) {
+ while (VCOUNTER != SCROLL_POS_PIX_START);
+ VDP_CMD = -scroller_x; VDP_CMD = VDP_RSCX;
+ while (VCOUNTER != SCROLL_POS_PIX_START + 8);
+ } else {
+ VDP_CMD = 0; VDP_CMD = VDP_RSCX;
+ }
+#endif
+}
+
+const uint8_t scroller_text[] = "This is a text scroller demo for GBDK-2020. You can use ideas, that are "\
+"shown in this demo, to make different parallax effects, scrolling of tilemaps which are larger than 32x32 "\
+"tiles and TEXT SCROLLERS, of course! Need to write something else to make this text longer than 256 characters. "\
+"The quick red fox jumps over the lazy brown dog. 0123456789. ";
+
+const uint8_t * scroller_next_char = scroller_text;
+uint8_t * scroller_vram_addr;
+uint8_t * base, * limit;
+
+void main() {
+ printf(" Scrolling %d chars", sizeof(scroller_text) - 1);
+
+ CRITICAL {
+ add_LCD(scanline_isr);
+#if defined(NINTENDO)
+ STAT_REG |= STATF_LYC; LYC_REG = 0;
+#endif
+ }
+#if defined(SEGA)
+ __WRITE_VDP_REG(VDP_R10, 0x07);
+#endif
+ set_interrupts(VBL_IFLAG | LCD_IFLAG);
+
+ HIDE_LEFT_COLUMN;
+ base = (uint8_t *)((uint16_t)get_bkg_xy_addr(0, SCROLL_POS) & (DEVICE_SCREEN_MAP_ENTRY_SIZE==1?0xffe0:0xffc0));
+ limit = base + (DEVICE_SCREEN_BUFFER_WIDTH * DEVICE_SCREEN_MAP_ENTRY_SIZE);
+
+ scroller_vram_addr = base + ((DEVICE_SCREEN_X_OFFSET + DEVICE_SCREEN_WIDTH) * DEVICE_SCREEN_MAP_ENTRY_SIZE);
+ if (scroller_vram_addr >= limit) scroller_vram_addr = base;
+
+ set_vram_byte(scroller_vram_addr, *scroller_next_char - 0x20);
+
+ while (1) {
+ scroller_x++;
+ if ((scroller_x & 0x07) == 0) {
+ // next letter
+ scroller_next_char++;
+ if (*scroller_next_char == 0) scroller_next_char = scroller_text;
+
+ // next vram position
+ scroller_vram_addr += DEVICE_SCREEN_MAP_ENTRY_SIZE;
+ if (scroller_vram_addr >= limit) scroller_vram_addr = base;
+
+ // put next char
+ set_vram_byte(scroller_vram_addr, *scroller_next_char - 0x20);
+ }
+ wait_vbl_done();
+ }
+} \ No newline at end of file
diff --git a/gbdk/gbdk-lib/examples/gb/Makefile b/gbdk/gbdk-lib/examples/gb/Makefile
new file mode 100644
index 00000000..f891d672
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/Makefile
@@ -0,0 +1,17 @@
+# Register all subdirectories in the project's root directory.
+SUBDIRS := $(wildcard */.)
+
+# Top-level phony targets.
+all clean compile.bat: $(SUBDIRS) FORCE
+# Similar to:
+# .PHONY: all clean
+# all clean: $(SUBDIRS)
+# GNU's .PHONY target is more efficient in that it explicitly declares non-files.
+
+# Recurse `make` into each subdirectory
+# Pass along targets specified at command-line (if any).
+$(SUBDIRS): FORCE
+ $(MAKE) -C $@ $(MAKECMDGOALS)
+
+# Force targets.
+FORCE: \ No newline at end of file
diff --git a/gbdk/gbdk-lib/examples/gb/banks/Makefile b/gbdk/gbdk-lib/examples/gb/banks/Makefile
new file mode 100644
index 00000000..658030c5
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/banks/Makefile
@@ -0,0 +1,63 @@
+CC = ../../../bin/lcc -Wa-l -Wl-m -Wl-j
+
+BINS = banks.gb \
+
+all: $(BINS)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+%.o: %.c
+ $(CC) -c -o $@ $<
+
+%.s: %.c
+ $(CC) -S -o $@ $<
+
+%.o: %.s
+ $(CC) -c -o $@ $<
+
+%.gb: %.o
+ $(CC) -o $@ $<
+
+clean:
+ rm -f *.o *.lst *.map *.gb *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi
+
+############################################################
+# Multiple bank example
+
+# Compile bank 0 (no ROM)
+# RAM bank 0 : -Wf-ba0
+#
+bank_0.o: bank_0.c
+ $(CC) -Wf-ba0 -c -o $@ $<
+
+# Compile bank 1 (ROM+RAM)
+# ROM bank 1 : -Wf-bo1
+# RAM bank 1 : -Wf-ba1
+#
+bank_1.o: bank_1.c
+ $(CC) -Wf-bo1 -Wf-ba1 -c -o $@ $<
+
+# Compile bank 2 (ROM+RAM)
+# ROM bank 2 : -Wf-bo2
+# RAM bank 2 : -Wf-ba2
+#
+bank_2.o: bank_2.c
+ $(CC) -Wf-bo2 -Wf-ba2 -c -o $@ $<
+
+# Compile bank 3 (ROM+RAM)
+# ROM bank 3 : -Wf-bo3
+# RAM bank 3 : -Wf-ba3
+#
+bank_3.o: bank_3.c
+ $(CC) -Wf-bo3 -Wf-ba3 -c -o $@ $<
+
+# Link banks
+# MBC5+ROM+RAM : -Wl-yt0x19
+# 4 ROM banks : -Wl-yo4
+# 4 RAM banks : -Wl-ya4
+#
+banks.gb: banks.o bank_0.o bank_1.o bank_2.o bank_3.o
+ $(CC) -Wl-yt0x1A -Wl-yo4 -Wl-ya4 -o $@ banks.o bank_0.o bank_1.o bank_2.o bank_3.o
+
diff --git a/gbdk/gbdk-lib/examples/gb/banks/bank_0.c b/gbdk/gbdk-lib/examples/gb/banks/bank_0.c
new file mode 100644
index 00000000..2f58d10f
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/banks/bank_0.c
@@ -0,0 +1,4 @@
+#include <gb/gb.h>
+#include <stdint.h>
+
+int var_0; /* In external RAM bank 0 */
diff --git a/gbdk/gbdk-lib/examples/gb/banks/bank_1.c b/gbdk/gbdk-lib/examples/gb/banks/bank_1.c
new file mode 100644
index 00000000..9dd452b0
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/banks/bank_1.c
@@ -0,0 +1,10 @@
+#include <gb/gb.h>
+#include <stdint.h>
+#include <stdio.h>
+
+int var_1; /* In external RAM bank 1 */
+
+void bank_1() BANKED /* In ROM bank 1 */
+{
+ puts("I'm in ROM bank 1");
+}
diff --git a/gbdk/gbdk-lib/examples/gb/banks/bank_2.c b/gbdk/gbdk-lib/examples/gb/banks/bank_2.c
new file mode 100644
index 00000000..61ea18fc
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/banks/bank_2.c
@@ -0,0 +1,10 @@
+#include <gb/gb.h>
+#include <stdint.h>
+#include <stdio.h>
+
+int var_2; /* In external RAM bank 2 */
+
+void bank_2() BANKED /* In ROM bank 2 */
+{
+ puts("I'm in ROM bank 2");
+}
diff --git a/gbdk/gbdk-lib/examples/gb/banks/bank_3.c b/gbdk/gbdk-lib/examples/gb/banks/bank_3.c
new file mode 100644
index 00000000..166abdca
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/banks/bank_3.c
@@ -0,0 +1,10 @@
+#include <gb/gb.h>
+#include <stdint.h>
+#include <stdio.h>
+
+int var_3; /* In external RAM bank 3 */
+
+void bank_3() BANKED /* In ROM bank 3 */
+{
+ puts("I'm in ROM bank 3");
+}
diff --git a/gbdk/gbdk-lib/examples/gb/banks/banks.c b/gbdk/gbdk-lib/examples/gb/banks/banks.c
new file mode 100644
index 00000000..0eb8413d
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/banks/banks.c
@@ -0,0 +1,61 @@
+/** Note that this example is a bit old. Try BANKED and NONBANKED
+ as in banked/
+ */
+#include <gb/gb.h>
+#include <stdint.h>
+#include <stdio.h>
+
+int var_internal; /* In internal RAM */
+extern int var_0; /* In external RAM bank 0 */
+extern int var_1; /* In external RAM bank 1 */
+extern int var_2; /* In external RAM bank 2 */
+extern int var_3; /* In external RAM bank 3 */
+
+void bank_1() BANKED;
+void bank_2() BANKED;
+void bank_3() BANKED;
+
+void bank_fixed(void) NONBANKED
+{
+ puts("I'm in fixed ROM");
+}
+
+void print_var(uint8_t bank)
+{
+ SWITCH_RAM(bank);
+ printf("Var_%u is %u\n");
+}
+
+void main(void)
+{
+ puts("Program Start...");
+
+ ENABLE_RAM;
+
+ var_internal = 1;
+ SWITCH_RAM(0);
+ var_0 = 2;
+ SWITCH_RAM(1);
+ var_1 = 3;
+ SWITCH_RAM(2);
+ var_2 = 4;
+ SWITCH_RAM(3);
+ var_3 = 5;
+
+ bank_fixed();
+ bank_1();
+ bank_2();
+ bank_3();
+
+ printf("Var is %u\n", var_internal);
+ SWITCH_RAM(0);
+ printf("Var_0 is %u\n", var_0);
+ SWITCH_RAM(1);
+ printf("Var_1 is %u\n", var_1);
+ SWITCH_RAM(2);
+ printf("Var_2 is %u\n", var_2);
+ SWITCH_RAM(3);
+ printf("Var_3 is %u\n", var_3);
+
+ puts("The End...");
+}
diff --git a/gbdk/gbdk-lib/examples/gb/bcd/Makefile b/gbdk/gbdk-lib/examples/gb/bcd/Makefile
new file mode 100644
index 00000000..1ae00c77
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/bcd/Makefile
@@ -0,0 +1,17 @@
+CC = ../../../bin/lcc -Wa-l -Wl-m -Wl-j
+
+BINS = bcd.gb
+
+all: $(BINS)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+# Compile and link single file in one pass
+%.gb: %.c
+ $(CC) -o $@ $<
+
+clean:
+ rm -f *.o *.lst *.map *.gb *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi
+
diff --git a/gbdk/gbdk-lib/examples/gb/bcd/bcd.c b/gbdk/gbdk-lib/examples/gb/bcd/bcd.c
new file mode 100644
index 00000000..c4d57766
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/bcd/bcd.c
@@ -0,0 +1,36 @@
+#include <stdint.h>
+#include <stdio.h>
+
+#include <gbdk/platform.h>
+#include <gbdk/font.h>
+#include <gbdk/bcd.h>
+
+BCD bcd = MAKE_BCD(10203040);
+BCD bcd2 = MAKE_BCD(05060708);
+BCD bcd3 = MAKE_BCD(11111111);
+
+uint8_t len = 0;
+unsigned char buf[10];
+
+void main() {
+ font_init();
+ font_set(font_load(font_spect));
+
+ len = bcd2text(&bcd, 0x10, buf);
+ set_bkg_tiles(5, 5, len, 1, buf);
+
+ bcd_add(&bcd, &bcd2);
+
+ len = bcd2text(&bcd, 0x10, buf);
+ set_bkg_tiles(5, 6, len, 1, buf);
+
+ bcd_sub(&bcd, &bcd3);
+
+ len = bcd2text(&bcd, 0x10, buf);
+ set_bkg_tiles(5, 7, len, 1, buf);
+
+ uint2bcd(12345, &bcd);
+
+ len = bcd2text(&bcd, 0x10, buf);
+ set_bkg_tiles(5, 8, len, 1, buf);
+} \ No newline at end of file
diff --git a/gbdk/gbdk-lib/examples/gb/colorbar/Makefile b/gbdk/gbdk-lib/examples/gb/colorbar/Makefile
new file mode 100644
index 00000000..cd0e8663
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/colorbar/Makefile
@@ -0,0 +1,30 @@
+CC = ../../../bin/lcc -Wa-l -Wl-m
+
+# CFLAGS =
+
+BINS = colorbar.gb
+
+all: $(BINS)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+%.o: %.c
+ $(CC) $(CFLAGS) -c -o $@ $<
+
+%.o: %.s
+ $(CC) $(CFLAGS) -c -o $@ $<
+
+%.s: %.c
+ $(CC) $(CFLAGS) -S -o $@ $<
+
+%.gb: %.o
+ $(CC) -o $@ $<
+
+clean:
+ rm -f *.o *.lst *.map *.gb *.ihx *.sym *.cdb *.adb *.asm
+
+# Link file, and write 0x80 at position 0x143 in header
+colorbar.gb: colorbar.o
+ $(CC) $(CFLAGS) -Wm-yC -o colorbar.gb colorbar.o
diff --git a/gbdk/gbdk-lib/examples/gb/colorbar/bar_c.c b/gbdk/gbdk-lib/examples/gb/colorbar/bar_c.c
new file mode 100644
index 00000000..959253d7
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/colorbar/bar_c.c
@@ -0,0 +1,102 @@
+/*
+
+ BAR_C.C
+
+ Tile Source File.
+
+ Info:
+ Form : All tiles as one unit.
+ Format : Gameboy 4 color.
+ Compression : None.
+ Counter : None.
+ Tile size : 8 x 8
+ Tiles : 0 to 31
+
+ Palette colors : Included.
+ SGB Palette : None.
+ CGB Palette : 1 Byte per entry.
+
+ Convert to metatiles : No.
+
+ This file was generated by GBTD v1.6
+
+*/
+
+/* CGBpalette entries. */
+const unsigned char bar_cCGB[] =
+{
+ 0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,
+ 0x02,0x02,0x02,0x02,0x03,0x03,0x03,0x03,
+ 0x04,0x04,0x04,0x04,0x05,0x05,0x05,0x05,
+ 0x06,0x06,0x06,0x06,0x07,0x07,0x07,0x07
+};
+/* Start of tile array. */
+const unsigned char bar_c[] =
+{
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,
+ 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,
+ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
+ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,
+ 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,
+ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
+ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,
+ 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,
+ 0xFF,0x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FF,0xFF,0xFF,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,
+ 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,
+ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
+ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,
+ 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,
+ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
+ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF
+};
+
+/* End of BAR_C.C */
diff --git a/gbdk/gbdk-lib/examples/gb/colorbar/bar_c.gbr b/gbdk/gbdk-lib/examples/gb/colorbar/bar_c.gbr
new file mode 100644
index 00000000..5274487d
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/colorbar/bar_c.gbr
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/gb/colorbar/bar_c.h b/gbdk/gbdk-lib/examples/gb/colorbar/bar_c.h
new file mode 100644
index 00000000..50db73b8
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/colorbar/bar_c.h
@@ -0,0 +1,105 @@
+/*
+
+ BAR_C.H
+
+ Include File.
+
+ Info:
+ Form : All tiles as one unit.
+ Format : Gameboy 4 color.
+ Compression : None.
+ Counter : None.
+ Tile size : 8 x 8
+ Tiles : 0 to 31
+
+ Palette colors : Included.
+ SGB Palette : None.
+ CGB Palette : 1 Byte per entry.
+
+ Convert to metatiles : No.
+
+ This file was generated by GBTD v1.6
+
+*/
+
+
+/* Bank of tiles. */
+#define bar_cBank 0
+
+/* Super Gameboy palette 0 */
+#define bar_cSGBPal0c0 0
+#define bar_cSGBPal0c1 0
+#define bar_cSGBPal0c2 0
+#define bar_cSGBPal0c3 0
+
+/* Super Gameboy palette 1 */
+#define bar_cSGBPal1c0 25368
+#define bar_cSGBPal1c1 0
+#define bar_cSGBPal1c2 4104
+#define bar_cSGBPal1c3 6
+
+/* Super Gameboy palette 2 */
+#define bar_cSGBPal2c0 0
+#define bar_cSGBPal2c1 0
+#define bar_cSGBPal2c2 4104
+#define bar_cSGBPal2c3 6
+
+/* Super Gameboy palette 3 */
+#define bar_cSGBPal3c0 0
+#define bar_cSGBPal3c1 0
+#define bar_cSGBPal3c2 4104
+#define bar_cSGBPal3c3 6
+
+/* Gameboy Color palette 0 */
+#define bar_cCGBPal0c0 32767
+#define bar_cCGBPal0c1 25368
+#define bar_cCGBPal0c2 19026
+#define bar_cCGBPal0c3 0
+
+/* Gameboy Color palette 1 */
+#define bar_cCGBPal1c0 18
+#define bar_cCGBPal1c1 24
+#define bar_cCGBPal1c2 31
+#define bar_cCGBPal1c3 12
+
+/* Gameboy Color palette 2 */
+#define bar_cCGBPal2c0 384
+#define bar_cCGBPal2c1 576
+#define bar_cCGBPal2c2 768
+#define bar_cCGBPal2c3 992
+
+/* Gameboy Color palette 3 */
+#define bar_cCGBPal3c0 12288
+#define bar_cCGBPal3c1 18432
+#define bar_cCGBPal3c2 24576
+#define bar_cCGBPal3c3 31744
+
+/* Gameboy Color palette 4 */
+#define bar_cCGBPal4c0 792
+#define bar_cCGBPal4c1 1023
+#define bar_cCGBPal4c2 396
+#define bar_cCGBPal4c3 594
+
+/* Gameboy Color palette 5 */
+#define bar_cCGBPal5c0 24600
+#define bar_cCGBPal5c1 31775
+#define bar_cCGBPal5c2 12300
+#define bar_cCGBPal5c3 18450
+
+/* Gameboy Color palette 6 */
+#define bar_cCGBPal6c0 19008
+#define bar_cCGBPal6c1 25344
+#define bar_cCGBPal6c2 32736
+#define bar_cCGBPal6c3 12672
+
+/* Gameboy Color palette 7 */
+#define bar_cCGBPal7c0 32767
+#define bar_cCGBPal7c1 25368
+#define bar_cCGBPal7c2 19026
+#define bar_cCGBPal7c3 12684
+/* CGBpalette entries. */
+extern const unsigned char bar_cCGB[];
+/* Start of tile array. */
+extern const unsigned char bar_c[];
+
+/* End of BAR_C.H */
diff --git a/gbdk/gbdk-lib/examples/gb/colorbar/bar_m.c b/gbdk/gbdk-lib/examples/gb/colorbar/bar_m.c
new file mode 100644
index 00000000..b31920ad
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/colorbar/bar_m.c
@@ -0,0 +1,62 @@
+/*
+
+ BAR_M.C
+
+ Map Source File.
+
+ Info:
+ Section :
+ Bank : 0
+ Map size : 20 x 18
+ Tile set : C:\SDK\gb-gb\tmp\bar_c.gbr
+ Plane count : 1 plane (8 bits)
+ Plane order : Tiles are continues
+
+ This file was generated by GBMB v0.8
+
+*/
+
+#define bar_mWidth 20
+#define bar_mHeight 18
+
+const unsigned char bar_m[] =
+{
+ 0x1F,0x1F,0x12,0x12,0x12,0x1B,0x1B,0x1B,0x08,0x08,
+ 0x08,0x16,0x16,0x16,0x07,0x07,0x07,0x0C,0x0C,0x0C,
+ 0x1E,0x1E,0x13,0x13,0x13,0x18,0x18,0x18,0x09,0x09,
+ 0x09,0x17,0x17,0x17,0x04,0x04,0x04,0x0D,0x0D,0x0D,
+ 0x1D,0x1D,0x10,0x10,0x10,0x19,0x19,0x19,0x0A,0x0A,
+ 0x0A,0x14,0x14,0x14,0x05,0x05,0x05,0x0E,0x0E,0x0E,
+ 0x1C,0x1C,0x11,0x11,0x11,0x1A,0x1A,0x1A,0x0B,0x0B,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x0F,0x0F,0x0F,
+ 0x0F,0x0F,0x03,0x03,0x03,0x15,0x15,0x15,0x03,0x03,
+ 0x03,0x1A,0x1A,0x1A,0x03,0x03,0x03,0x1C,0x1C,0x1C,
+ 0x0D,0x0D,0x0D,0x0D,0x00,0x00,0x00,0x00,0x16,0x16,
+ 0x16,0x16,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
+ 0x0D,0x0D,0x0D,0x0D,0x00,0x00,0x00,0x00,0x16,0x16,
+ 0x16,0x16,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
+ 0x0D,0x0D,0x0D,0x0D,0x00,0x00,0x00,0x00,0x16,0x16,
+ 0x16,0x16,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
+};
+
+/* End of BAR_M.C */
diff --git a/gbdk/gbdk-lib/examples/gb/colorbar/bar_m.gbm b/gbdk/gbdk-lib/examples/gb/colorbar/bar_m.gbm
new file mode 100644
index 00000000..bea96c12
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/colorbar/bar_m.gbm
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/gb/colorbar/bar_m.h b/gbdk/gbdk-lib/examples/gb/colorbar/bar_m.h
new file mode 100644
index 00000000..0d42d703
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/colorbar/bar_m.h
@@ -0,0 +1,24 @@
+/*
+
+ BAR_M.H
+
+ Map Include File.
+
+ Info:
+ Section :
+ Bank : 0
+ Map size : 20 x 18
+ Tile set : C:\SDK\gb-gb\tmp\bar_c.gbr
+ Plane count : 1 plane (8 bits)
+ Plane order : Tiles are continues
+
+ This file was generated by GBMB v0.8
+
+*/
+
+#define bar_mWidth 20
+#define bar_mHeight 18
+
+extern const unsigned char bar_m[];
+
+/* End of BAR_M.H */
diff --git a/gbdk/gbdk-lib/examples/gb/colorbar/colorbar.c b/gbdk/gbdk-lib/examples/gb/colorbar/colorbar.c
new file mode 100644
index 00000000..14ad1bb0
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/colorbar/colorbar.c
@@ -0,0 +1,73 @@
+#include <gb/gb.h>
+#include <gb/cgb.h>
+#include <stdint.h>
+
+#include "bar_c.h"
+#include "bar_c.c"
+#include "bar_m.c"
+
+const uint16_t bar_p[] =
+{
+ bar_cCGBPal0c0,bar_cCGBPal0c1,bar_cCGBPal0c2,bar_cCGBPal0c3,
+ bar_cCGBPal1c0,bar_cCGBPal1c1,bar_cCGBPal1c2,bar_cCGBPal1c3,
+ bar_cCGBPal2c0,bar_cCGBPal2c1,bar_cCGBPal2c2,bar_cCGBPal2c3,
+ bar_cCGBPal3c0,bar_cCGBPal3c1,bar_cCGBPal3c2,bar_cCGBPal3c3,
+ bar_cCGBPal4c0,bar_cCGBPal4c1,bar_cCGBPal4c2,bar_cCGBPal4c3,
+ bar_cCGBPal5c0,bar_cCGBPal5c1,bar_cCGBPal5c2,bar_cCGBPal5c3,
+ bar_cCGBPal6c0,bar_cCGBPal6c1,bar_cCGBPal6c2,bar_cCGBPal6c3,
+ bar_cCGBPal7c0,bar_cCGBPal7c1,bar_cCGBPal7c2,bar_cCGBPal7c3
+};
+
+const unsigned char bar_a[] =
+{
+ 7,7,4,4,4,6,6,6,2,2,2,5,5,5,1,1,1,3,3,3,
+ 7,7,4,4,4,6,6,6,2,2,2,5,5,5,1,1,1,3,3,3,
+ 7,7,4,4,4,6,6,6,2,2,2,5,5,5,1,1,1,3,3,3,
+ 7,7,4,4,4,6,6,6,2,2,2,5,5,5,1,1,1,3,3,3,
+ 7,7,4,4,4,6,6,6,2,2,2,5,5,5,1,1,1,3,3,3,
+ 7,7,4,4,4,6,6,6,2,2,2,5,5,5,1,1,1,3,3,3,
+ 7,7,4,4,4,6,6,6,2,2,2,5,5,5,1,1,1,3,3,3,
+ 7,7,4,4,4,6,6,6,2,2,2,5,5,5,1,1,1,3,3,3,
+ 7,7,4,4,4,6,6,6,2,2,2,5,5,5,1,1,1,3,3,3,
+ 7,7,4,4,4,6,6,6,2,2,2,5,5,5,1,1,1,3,3,3,
+ 7,7,4,4,4,6,6,6,2,2,2,5,5,5,1,1,1,3,3,3,
+ 7,7,4,4,4,6,6,6,2,2,2,5,5,5,1,1,1,3,3,3,
+ 7,7,4,4,4,6,6,6,2,2,2,5,5,5,1,1,1,3,3,3,
+ 7,7,4,4,4,6,6,6,2,2,2,5,5,5,1,1,1,3,3,3,
+ 3,3,0,0,0,5,5,5,0,0,0,6,6,6,0,0,0,7,7,7,
+ 3,3,3,3,0,0,0,0,5,5,5,5,0,0,0,0,0,0,0,0,
+ 3,3,3,3,0,0,0,0,5,5,5,5,0,0,0,0,0,0,0,0,
+ 3,3,3,3,0,0,0,0,5,5,5,5,0,0,0,0,0,0,0,0
+};
+
+int main(void)
+{
+ /* Transfer color palettes */
+ set_bkg_palette( 7, 1, &bar_p[0] );
+ set_bkg_palette( 6, 1, &bar_p[4] );
+ set_bkg_palette( 5, 1, &bar_p[8] );
+ set_bkg_palette( 4, 1, &bar_p[12] );
+ set_bkg_palette( 3, 1, &bar_p[16] );
+ set_bkg_palette( 2, 1, &bar_p[20] );
+ set_bkg_palette( 1, 1, &bar_p[24] );
+ set_bkg_palette( 0, 1, &bar_p[28] );
+
+ /* CHR code transfer */
+ set_bkg_data( 0x0, 32, bar_c );
+
+ /* Select VRAM bank 1 */
+ VBK_REG = 1;
+ /* Set attributes */
+ set_bkg_tiles( 0, 0, bar_mWidth, bar_mHeight, bar_a );
+
+ /* Select VRAM bank 0 */
+ VBK_REG = 0;
+ /* Set data */
+ set_bkg_tiles( 0, 0, bar_mWidth, bar_mHeight, bar_m );
+
+ SHOW_BKG;
+ enable_interrupts();
+ DISPLAY_ON;
+
+ return 0;
+}
diff --git a/gbdk/gbdk-lib/examples/gb/comm/Makefile b/gbdk/gbdk-lib/examples/gb/comm/Makefile
new file mode 100644
index 00000000..b4fd4d22
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/comm/Makefile
@@ -0,0 +1,17 @@
+CC = ../../../bin/lcc -Wa-l -Wl-m -Wl-j
+
+BINS = comm.gb
+
+all: $(BINS)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+# Compile and link single file in one pass
+%.gb: %.c
+ $(CC) -o $@ $<
+
+clean:
+ rm -f *.o *.lst *.map *.gb *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi
+
diff --git a/gbdk/gbdk-lib/examples/gb/comm/comm.c b/gbdk/gbdk-lib/examples/gb/comm/comm.c
new file mode 100644
index 00000000..f3928016
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/comm/comm.c
@@ -0,0 +1,90 @@
+#include <gb/gb.h>
+#include <stdint.h>
+#include <stdio.h>
+
+unsigned char str[] = "Hello World!";
+unsigned char buffer[32];
+
+void main(void)
+{
+ uint8_t i, n = 0;
+ unsigned char *s;
+
+ puts("Byte");
+ puts(" A : Send");
+ puts(" B : Receive");
+ puts("String");
+ puts(" START : Send");
+ puts(" SELECT : Receive");
+
+ CRITICAL {
+ add_SIO(nowait_int_handler); // disable waiting VRAM state before return
+ }
+ set_interrupts(SIO_IFLAG); // disable other interrupts. note: this disables sprite movement
+
+ while(1) {
+ i = waitpad(J_A | J_B | J_START | J_SELECT);
+ waitpadup();
+
+ if (i == J_A) {
+ /* Send 1 byte */
+ printf("Sending b... ");
+ _io_out = n++;
+ send_byte();
+ /* Wait for IO completion... */
+ while((_io_status == IO_SENDING) && (joypad() == 0));
+ if(_io_status == IO_IDLE)
+ printf("OK\n");
+ else
+ printf("#%d\n", _io_status);
+ } else if (i == J_B) {
+ /* Receive 1 byte */
+ printf("Receiving b... ");
+ receive_byte();
+ /* Wait for IO completion... */
+ while((_io_status == IO_RECEIVING) && (joypad() == 0));
+ if(_io_status == IO_IDLE)
+ printf("OK\n%d\n", _io_in);
+ else
+ printf("#%d\n", _io_status);
+ } else if (i == J_START) {
+ /* Send a string */
+ printf("Sending s... ");
+ s = str;
+ while(1) {
+ _io_out = *s;
+ do {
+ send_byte();
+ /* Wait for IO completion... */
+ while((_io_status == IO_SENDING) && (joypad() == 0));
+ } while((_io_status != IO_IDLE) && (joypad() == 0));
+ if(_io_status != IO_IDLE) {
+ printf("#%d\n", _io_status);
+ break;
+ }
+ if(*s == 0) break;
+ s++;
+ }
+ if(_io_status == IO_IDLE) printf("OK\n");
+ } else if (i == J_SELECT) {
+ /* Receive a string */
+ printf("Receiving s... ");
+ s = buffer;
+ while(1) {
+ receive_byte();
+ /* Wait for IO completion... */
+ while((_io_status == IO_RECEIVING) && (joypad() == 0));
+ if(_io_status != IO_IDLE) {
+ printf("#%d\n", _io_status);
+ break;
+ }
+ *s = _io_in;
+ if(*s == 0) break;
+ s++;
+ }
+ if(_io_status == IO_IDLE) printf("OK\n%s\n", buffer);
+ }
+ /* In case of user cancellation */
+ waitpadup();
+ }
+}
diff --git a/gbdk/gbdk-lib/examples/gb/crash/Makefile b/gbdk/gbdk-lib/examples/gb/crash/Makefile
new file mode 100644
index 00000000..dcec7fd5
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/crash/Makefile
@@ -0,0 +1,17 @@
+CC = ../../../bin/lcc -Wa-l -Wl-m -Wl-j
+
+BINS = crash.gb
+
+all: $(BINS)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+# Compile and link single file in one pass
+%.gb: %.c
+ $(CC) -o $@ $<
+
+clean:
+ rm -f *.o *.lst *.map *.gb *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi
+
diff --git a/gbdk/gbdk-lib/examples/gb/crash/crash.c b/gbdk/gbdk-lib/examples/gb/crash/crash.c
new file mode 100644
index 00000000..995b6f69
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/crash/crash.c
@@ -0,0 +1,7 @@
+#include <gb/crash_handler.h>
+
+typedef void (*somefunc_t)(void);
+
+void main() {
+ ((somefunc_t)0x3000)(); // call something in the middle of nowhere
+} \ No newline at end of file
diff --git a/gbdk/gbdk-lib/examples/gb/dscan/Makefile b/gbdk/gbdk-lib/examples/gb/dscan/Makefile
new file mode 100644
index 00000000..be6e5916
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/dscan/Makefile
@@ -0,0 +1,24 @@
+CC = ../../../bin/lcc -Wm-yc
+
+BINS = dscan.gb
+
+all: $(BINS)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+%.o: %.c
+ $(CC) -c -o $@ $<
+
+%.s: %.c
+ $(CC) -S -o $@ $<
+
+%.o: %.s
+ $(CC) -c -o $@ $<
+
+%.gb: %.o
+ $(CC) -o $@ $<
+
+clean:
+ rm -f *.o *.lst *.map *.gb *.ihx *.sym *.cdb *.adb *.asm
diff --git a/gbdk/gbdk-lib/examples/gb/dscan/bkg.c b/gbdk/gbdk-lib/examples/gb/dscan/bkg.c
new file mode 100644
index 00000000..97397a58
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/dscan/bkg.c
@@ -0,0 +1,238 @@
+/*
+
+ BKG.C
+
+ Tile Source File.
+
+ Info:
+ Form : All tiles as one unit.
+ Format : Gameboy 4 color.
+ Compression : None.
+ Counter : None.
+ Tile size : 8 x 8
+ Tiles : 0 to 95
+
+ Palette colors : Included.
+ SGB Palette : None.
+ CGB Palette : 1 Byte per entry.
+
+ Convert to metatiles : No.
+
+ This file was generated by GBTD v1.6
+
+*/
+
+/* CGBpalette entries. */
+const unsigned char bkgCGB[] =
+{
+ 0x00,0x00,0x00,0x00,0x01,0x02,0x03,0x04,
+ 0x01,0x02,0x03,0x04,0x01,0x02,0x03,0x04,
+ 0x05,0x06,0x05,0x06,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+};
+/* Start of tile array. */
+const unsigned char bkg[] =
+{
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,
+ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
+ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,
+ 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,
+ 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,
+ 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,
+ 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,
+ 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,
+ 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,
+ 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0x00,0xFF,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
+ 0x10,0x10,0x00,0x00,0x10,0x10,0x00,0x00,
+ 0x6C,0x6C,0x24,0x24,0x48,0x48,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x44,0x44,0xFE,0xFE,0x44,0x44,0x44,0x44,
+ 0x44,0x44,0xFE,0xFE,0x44,0x44,0x00,0x00,
+ 0x28,0x28,0x7E,0x7E,0xA8,0xA8,0x7C,0x7C,
+ 0x2A,0x2A,0xFC,0xFC,0x28,0x28,0x00,0x00,
+ 0x40,0x40,0xA4,0xA4,0x48,0x48,0x10,0x10,
+ 0x24,0x24,0x4A,0x4A,0x04,0x04,0x00,0x00,
+ 0x70,0x70,0x88,0x88,0x50,0x50,0x64,0x64,
+ 0x94,0x94,0x88,0x88,0x76,0x76,0x00,0x00,
+ 0x18,0x18,0x08,0x08,0x10,0x10,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x08,0x08,0x10,0x10,0x20,0x20,0x20,0x20,
+ 0x20,0x20,0x10,0x10,0x08,0x08,0x00,0x00,
+ 0x20,0x20,0x10,0x10,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x10,0x10,0x20,0x20,0x00,0x00,
+ 0x10,0x10,0x54,0x54,0x38,0x38,0x10,0x10,
+ 0x38,0x38,0x54,0x54,0x10,0x10,0x00,0x00,
+ 0x00,0x00,0x10,0x10,0x10,0x10,0x7C,0x7C,
+ 0x10,0x10,0x10,0x10,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x18,0x18,0x08,0x08,0x10,0x10,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x7C,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x08,0x08,0x00,0x00,
+ 0x00,0x00,0x04,0x04,0x08,0x08,0x10,0x10,
+ 0x20,0x20,0x40,0x40,0x00,0x00,0x00,0x00,
+ 0x7C,0x7C,0x82,0x82,0x82,0x82,0x82,0x82,
+ 0x82,0x82,0x82,0x82,0x7C,0x7C,0x00,0x00,
+ 0x10,0x10,0x30,0x30,0x10,0x10,0x10,0x10,
+ 0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00,
+ 0x7C,0x7C,0x82,0x82,0x82,0x82,0x0C,0x0C,
+ 0x30,0x30,0xC0,0xC0,0xFE,0xFE,0x00,0x00,
+ 0x7C,0x7C,0x82,0x82,0x02,0x02,0x1C,0x1C,
+ 0x02,0x02,0x82,0x82,0x7C,0x7C,0x00,0x00,
+ 0x0C,0x0C,0x14,0x14,0x24,0x24,0x44,0x44,
+ 0x84,0x84,0xFE,0xFE,0x04,0x04,0x00,0x00,
+ 0xFE,0xFE,0x80,0x80,0xFC,0xFC,0x02,0x02,
+ 0x02,0x02,0x82,0x82,0x7C,0x7C,0x00,0x00,
+ 0x7C,0x7C,0x82,0x82,0x80,0x80,0xFC,0xFC,
+ 0x82,0x82,0x82,0x82,0x7C,0x7C,0x00,0x00,
+ 0xFE,0xFE,0x82,0x82,0x04,0x04,0x08,0x08,
+ 0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00,
+ 0x7C,0x7C,0x82,0x82,0x82,0x82,0x7C,0x7C,
+ 0x82,0x82,0x82,0x82,0x7C,0x7C,0x00,0x00,
+ 0x7C,0x7C,0x82,0x82,0x82,0x82,0x7E,0x7E,
+ 0x02,0x02,0x82,0x82,0x7C,0x7C,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,
+ 0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,
+ 0x18,0x18,0x08,0x08,0x10,0x10,0x00,0x00,
+ 0x08,0x08,0x10,0x10,0x20,0x20,0x40,0x40,
+ 0x20,0x20,0x10,0x10,0x08,0x08,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x7C,0x7C,0x00,0x00,
+ 0x7C,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x40,0x40,0x20,0x20,0x10,0x10,0x08,0x08,
+ 0x10,0x10,0x20,0x20,0x40,0x40,0x00,0x00,
+ 0x7C,0x7C,0x82,0x82,0x82,0x82,0x0C,0x0C,
+ 0x10,0x10,0x00,0x00,0x10,0x10,0x00,0x00,
+ 0x7C,0x7C,0x82,0x82,0xBA,0xBA,0xAA,0xAA,
+ 0xBE,0xBE,0x80,0x80,0x7E,0x7E,0x00,0x00,
+ 0x38,0x38,0x44,0x44,0x82,0x82,0x82,0x82,
+ 0xFE,0xFE,0x82,0x82,0x82,0x82,0x00,0x00,
+ 0xFC,0xFC,0x82,0x82,0x82,0x82,0xFC,0xFC,
+ 0x82,0x82,0x82,0x82,0xFC,0xFC,0x00,0x00,
+ 0x3C,0x3C,0x42,0x42,0x80,0x80,0x80,0x80,
+ 0x80,0x80,0x42,0x42,0x3C,0x3C,0x00,0x00,
+ 0xF8,0xF8,0x84,0x84,0x82,0x82,0x82,0x82,
+ 0x82,0x82,0x84,0x84,0xF8,0xF8,0x00,0x00,
+ 0xFE,0xFE,0x80,0x80,0x80,0x80,0xFC,0xFC,
+ 0x80,0x80,0x80,0x80,0xFE,0xFE,0x00,0x00,
+ 0xFE,0xFE,0x80,0x80,0x80,0x80,0xFC,0xFC,
+ 0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,
+ 0x3C,0x3C,0x42,0x42,0x80,0x80,0x80,0x80,
+ 0x8E,0x8E,0x42,0x42,0x3E,0x3E,0x00,0x00,
+ 0x82,0x82,0x82,0x82,0x82,0x82,0xFE,0xFE,
+ 0x82,0x82,0x82,0x82,0x82,0x82,0x00,0x00,
+ 0x38,0x38,0x10,0x10,0x10,0x10,0x10,0x10,
+ 0x10,0x10,0x10,0x10,0x38,0x38,0x00,0x00,
+ 0x3C,0x3C,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x48,0x48,0x30,0x30,0x00,0x00,
+ 0x84,0x84,0x88,0x88,0x90,0x90,0xE0,0xE0,
+ 0x90,0x90,0x88,0x88,0x84,0x84,0x00,0x00,
+ 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,
+ 0x40,0x40,0x40,0x40,0x7E,0x7E,0x00,0x00,
+ 0xC6,0xC6,0xC6,0xC6,0xAA,0xAA,0xAA,0xAA,
+ 0x92,0x92,0x92,0x92,0x82,0x82,0x00,0x00,
+ 0xC2,0xC2,0xC2,0xC2,0xA2,0xA2,0x92,0x92,
+ 0x8A,0x8A,0x86,0x86,0x86,0x86,0x00,0x00,
+ 0x7C,0x7C,0x82,0x82,0x82,0x82,0x82,0x82,
+ 0x82,0x82,0x82,0x82,0x7C,0x7C,0x00,0x00,
+ 0xFC,0xFC,0x82,0x82,0x82,0x82,0x82,0x82,
+ 0xFC,0xFC,0x80,0x80,0x80,0x80,0x00,0x00,
+ 0x7C,0x7C,0x82,0x82,0x82,0x82,0x82,0x82,
+ 0xBA,0xBA,0xC4,0xC4,0x7A,0x7A,0x00,0x00,
+ 0xFC,0xFC,0x82,0x82,0x82,0x82,0x82,0x82,
+ 0xFC,0xFC,0x84,0x84,0x82,0x82,0x00,0x00,
+ 0x7C,0x7C,0x82,0x82,0x80,0x80,0x7C,0x7C,
+ 0x02,0x02,0x82,0x82,0x7C,0x7C,0x00,0x00,
+ 0xFE,0xFE,0x10,0x10,0x10,0x10,0x10,0x10,
+ 0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00,
+ 0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,
+ 0x82,0x82,0x82,0x82,0x7C,0x7C,0x00,0x00,
+ 0x82,0x82,0x82,0x82,0x44,0x44,0x44,0x44,
+ 0x28,0x28,0x28,0x28,0x10,0x10,0x00,0x00,
+ 0x82,0x82,0x82,0x82,0x82,0x82,0x92,0x92,
+ 0x92,0x92,0x92,0x92,0x6C,0x6C,0x00,0x00,
+ 0x82,0x82,0x44,0x44,0x28,0x28,0x10,0x10,
+ 0x28,0x28,0x44,0x44,0x82,0x82,0x00,0x00,
+ 0x82,0x82,0x44,0x44,0x28,0x28,0x10,0x10,
+ 0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00,
+ 0xFE,0xFE,0x02,0x02,0x0C,0x0C,0x10,0x10,
+ 0x60,0x60,0x80,0x80,0xFE,0xFE,0x00,0x00,
+ 0x38,0x38,0x20,0x20,0x20,0x20,0x20,0x20,
+ 0x20,0x20,0x20,0x20,0x38,0x38,0x00,0x00,
+ 0x00,0x00,0x40,0x40,0x20,0x20,0x10,0x10,
+ 0x08,0x08,0x04,0x04,0x00,0x00,0x00,0x00,
+ 0x38,0x38,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x38,0x38,0x00,0x00,
+ 0x7C,0x7C,0x82,0x82,0xBA,0xBA,0xA2,0xA2,
+ 0xBA,0xBA,0x82,0x82,0x7C,0x7C,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x7E,0x7E,0x00,0x00
+};
+
+/* End of BKG.C */
diff --git a/gbdk/gbdk-lib/examples/gb/dscan/bkg.gbr b/gbdk/gbdk-lib/examples/gb/dscan/bkg.gbr
new file mode 100644
index 00000000..754bfbd4
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/dscan/bkg.gbr
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/gb/dscan/bkg.h b/gbdk/gbdk-lib/examples/gb/dscan/bkg.h
new file mode 100644
index 00000000..9ad52052
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/dscan/bkg.h
@@ -0,0 +1,105 @@
+/*
+
+ BKG.H
+
+ Include File.
+
+ Info:
+ Form : All tiles as one unit.
+ Format : Gameboy 4 color.
+ Compression : None.
+ Counter : None.
+ Tile size : 8 x 8
+ Tiles : 0 to 95
+
+ Palette colors : Included.
+ SGB Palette : None.
+ CGB Palette : 1 Byte per entry.
+
+ Convert to metatiles : No.
+
+ This file was generated by GBTD v1.6
+
+*/
+
+
+/* Bank of tiles. */
+#define bkgBank 0
+
+/* Super Gameboy palette 0 */
+#define bkgSGBPal0c0 0
+#define bkgSGBPal0c1 0
+#define bkgSGBPal0c2 0
+#define bkgSGBPal0c3 0
+
+/* Super Gameboy palette 1 */
+#define bkgSGBPal1c0 4104
+#define bkgSGBPal1c1 6
+#define bkgSGBPal1c2 0
+#define bkgSGBPal1c3 0
+
+/* Super Gameboy palette 2 */
+#define bkgSGBPal2c0 4104
+#define bkgSGBPal2c1 6
+#define bkgSGBPal2c2 0
+#define bkgSGBPal2c3 0
+
+/* Super Gameboy palette 3 */
+#define bkgSGBPal3c0 4104
+#define bkgSGBPal3c1 6
+#define bkgSGBPal3c2 0
+#define bkgSGBPal3c3 0
+
+/* Gameboy Color palette 0 */
+#define bkgCGBPal0c0 32767
+#define bkgCGBPal0c1 25368
+#define bkgCGBPal0c2 16912
+#define bkgCGBPal0c3 0
+
+/* Gameboy Color palette 1 */
+#define bkgCGBPal1c0 31744
+#define bkgCGBPal1c1 25600
+#define bkgCGBPal1c2 15360
+#define bkgCGBPal1c3 31
+
+/* Gameboy Color palette 2 */
+#define bkgCGBPal2c0 29696
+#define bkgCGBPal2c1 21504
+#define bkgCGBPal2c2 13312
+#define bkgCGBPal2c3 31
+
+/* Gameboy Color palette 3 */
+#define bkgCGBPal3c0 27648
+#define bkgCGBPal3c1 19456
+#define bkgCGBPal3c2 11264
+#define bkgCGBPal3c3 31
+
+/* Gameboy Color palette 4 */
+#define bkgCGBPal4c0 23552
+#define bkgCGBPal4c1 17408
+#define bkgCGBPal4c2 9216
+#define bkgCGBPal4c3 31
+
+/* Gameboy Color palette 5 */
+#define bkgCGBPal5c0 16896
+#define bkgCGBPal5c1 25344
+#define bkgCGBPal5c2 0
+#define bkgCGBPal5c3 31
+
+/* Gameboy Color palette 6 */
+#define bkgCGBPal6c0 21120
+#define bkgCGBPal6c1 29568
+#define bkgCGBPal6c2 31744
+#define bkgCGBPal6c3 31
+
+/* Gameboy Color palette 7 */
+#define bkgCGBPal7c0 32767
+#define bkgCGBPal7c1 32736
+#define bkgCGBPal7c2 0
+#define bkgCGBPal7c3 31744
+/* CGBpalette entries. */
+extern const unsigned char bkgCGB[];
+/* Start of tile array. */
+extern const unsigned char bkg[];
+
+/* End of BKG.H */
diff --git a/gbdk/gbdk-lib/examples/gb/dscan/bkg_c.c b/gbdk/gbdk-lib/examples/gb/dscan/bkg_c.c
new file mode 100644
index 00000000..e02e2957
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/dscan/bkg_c.c
@@ -0,0 +1,62 @@
+/*
+
+ BKG_C.C
+
+ Map Source File.
+
+ Info:
+ Section :
+ Bank : 0
+ Map size : 20 x 18
+ Tile set : C:\SDK\gb-gb\2-0-15\examples\dscan\bkg.gbr
+ Plane count : 1 plane (8 bits)
+ Plane order : Tiles are continues
+
+ This file was generated by GBMB v0.8
+
+*/
+
+#define bkg_cWidth 20
+#define bkg_cHeight 18
+
+const unsigned char bkg_c[] =
+{
+ 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
+ 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,
+ 0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,
+ 0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,
+ 0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,
+ 0x02,0x02,0x02,0x02,0x02,0x04,0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04,0x04,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x04,0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04,0x04,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x05,0x05,0x05,0x05,0x05,
+ 0x05,0x05,0x05,0x05,0x05,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x07,0x07,0x07,0x07,0x07,
+ 0x07,0x07,0x07,0x07,0x07,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x09,0x09,0x09,0x09,0x09,
+ 0x09,0x09,0x09,0x09,0x09,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x0A,0x0A,0x0A,0x0A,0x0A,
+ 0x0A,0x0A,0x0A,0x0A,0x0A,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x0B,0x0B,0x0B,0x0B,0x0B,
+ 0x0B,0x0B,0x0B,0x0B,0x0B,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x0C,0x0C,0x0C,0x0C,0x0C,
+ 0x0C,0x0C,0x0C,0x0C,0x0C,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x0D,0x0D,0x0D,0x0D,0x0D,
+ 0x0D,0x0D,0x0D,0x0D,0x0D,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x0E,0x0E,0x0E,0x0E,0x0E,
+ 0x0E,0x0E,0x0E,0x0E,0x0E,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x0F,0x0F,0x0F,0x0F,0x0F,
+ 0x0F,0x0F,0x0F,0x0F,0x0F,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
+};
+
+/* End of BKG_C.C */
diff --git a/gbdk/gbdk-lib/examples/gb/dscan/bkg_c.gbm b/gbdk/gbdk-lib/examples/gb/dscan/bkg_c.gbm
new file mode 100644
index 00000000..aab831a5
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/dscan/bkg_c.gbm
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/gb/dscan/bkg_m.c b/gbdk/gbdk-lib/examples/gb/dscan/bkg_m.c
new file mode 100644
index 00000000..6eb9178c
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/dscan/bkg_m.c
@@ -0,0 +1,62 @@
+/*
+
+ BKG_M.C
+
+ Map Source File.
+
+ Info:
+ Section :
+ Bank : 0
+ Map size : 20 x 18
+ Tile set : C:\SDK\gb-gb\2-0-15\examples\dscan\bkg.gbr
+ Plane count : 1 plane (8 bits)
+ Plane order : Tiles are continues
+
+ This file was generated by GBMB v0.8
+
+*/
+
+#define bkg_mWidth 20
+#define bkg_mHeight 18
+
+const unsigned char bkg_m[] =
+{
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
+ 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
+ 0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x02,
+ 0x02,0x02,0x02,0x02,0x02,0x01,0x01,0x01,0x01,0x01,
+ 0x01,0x01,0x01,0x01,0x01,0x02,0x02,0x02,0x02,0x02,
+};
+
+/* End of BKG_M.C */
diff --git a/gbdk/gbdk-lib/examples/gb/dscan/bkg_m.gbm b/gbdk/gbdk-lib/examples/gb/dscan/bkg_m.gbm
new file mode 100644
index 00000000..a910fe48
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/dscan/bkg_m.gbm
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/gb/dscan/dscan.c b/gbdk/gbdk-lib/examples/gb/dscan/dscan.c
new file mode 100644
index 00000000..4a08fe9a
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/dscan/dscan.c
@@ -0,0 +1,751 @@
+/********************************************************************
+ * Color Deep Scan *
+ * by *
+ * Mr. N.U. of TeamKNOx *
+ ********************************************************************/
+
+#include <gb/gb.h>
+#include <gb/cgb.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <rand.h>
+
+/* bitmaps */
+#include "bkg.h"
+#include "bkg.c"
+#include "bkg_m.c"
+#include "bkg_c.c"
+#include "fore.h"
+#include "fore.c"
+
+/* ************************************************************ */
+
+const uint16_t bkg_p[] =
+{
+ bkgCGBPal0c0,bkgCGBPal0c1,bkgCGBPal0c2,bkgCGBPal0c3,
+ bkgCGBPal1c0,bkgCGBPal1c1,bkgCGBPal1c2,bkgCGBPal1c3,
+ bkgCGBPal2c0,bkgCGBPal2c1,bkgCGBPal2c2,bkgCGBPal2c3,
+ bkgCGBPal3c0,bkgCGBPal3c1,bkgCGBPal3c2,bkgCGBPal3c3,
+ bkgCGBPal4c0,bkgCGBPal4c1,bkgCGBPal4c2,bkgCGBPal4c3,
+ bkgCGBPal5c0,bkgCGBPal5c1,bkgCGBPal5c2,bkgCGBPal5c3,
+ bkgCGBPal6c0,bkgCGBPal6c1,bkgCGBPal6c2,bkgCGBPal6c3,
+ bkgCGBPal7c0,bkgCGBPal7c1,bkgCGBPal7c2,bkgCGBPal7c3
+};
+
+const uint16_t obj_p[] =
+{
+ foreCGBPal0c0,foreCGBPal0c1,foreCGBPal0c2,foreCGBPal0c3,
+ foreCGBPal1c0,foreCGBPal1c1,foreCGBPal1c2,foreCGBPal1c3,
+ foreCGBPal2c0,foreCGBPal2c1,foreCGBPal2c2,foreCGBPal2c3,
+ foreCGBPal3c0,foreCGBPal3c1,foreCGBPal3c2,foreCGBPal3c3,
+ foreCGBPal4c0,foreCGBPal4c1,foreCGBPal4c2,foreCGBPal4c3,
+ foreCGBPal5c0,foreCGBPal5c1,foreCGBPal5c2,foreCGBPal5c3,
+ foreCGBPal6c0,foreCGBPal6c1,foreCGBPal6c2,foreCGBPal6c3,
+ foreCGBPal7c0,foreCGBPal7c1,foreCGBPal7c2,foreCGBPal7c3
+};
+
+/* screen size */
+#define MIN_SX 5U /* min x (char) */
+#define MAX_SX (20U-MIN_SX) /* max x (char) */
+#define MIN_SY 5U /* min y (char) */
+#define MAX_SY (MIN_SY+13U) /* max y (char) */
+
+#define DEF_SP 30U /* sprite null char code */
+
+/* player */
+#define MIN_PX (MIN_SX*8U+8U) /* min x (dot) */
+#define MAX_PX (MAX_SX*8U-8U) /* max x (dot) */
+#define DEF_PX 80U /* ship x pos (dot) */
+#define DEF_PY (MIN_SY*8U) /* ship y pos (dot) */
+#define DEF_PC0 14U
+#define DEF_PC1 15U
+#define DEF_PF 8U
+
+/* bomb */
+#define MAX_TT 6U /* number */
+#define DEF_TS 2U /* sprite tile id */
+#define DEF_TC 2U /* sprite data id */
+#define DEF_TX (80U-6U) /* bomb x pos (dot) */
+#define DEF_TY (DEF_PY-14U) /* bomb y pos (dot) */
+#define MAX_TY (MAX_SY*8U) /* max y pos (dot) */
+
+/* enemy */
+#define MAX_ET 10U /* number */
+#define DEF_ES0 (DEF_TS+MAX_TT) /* sprite tile id */
+#define DEF_ES1 (DEF_ES0+1U)
+#define DEF_1EC0 32U
+#define DEF_1EC1 48U
+#define DEF_2EC0 64U
+#define DEF_2EC1 80U
+#define DEF_XEC0 96U /* sprite data(X) id */
+#define DEF_XEC1 112U /* sprite data(X) id */
+#define DEF_EY (DEF_PY+12U)
+#define DEF_EH 10U
+#define SUB_EX0 20U
+#define SUB_EX1 (SUB_EX0-8U)
+#define MIN_EX (SUB_EX0-16U)
+#define MAX_EX (SUB_EX0+180U)
+#define SPEED_EY (DEF_EY+DEF_EH*3U)
+#define DEF_BC1 4U
+#define DEF_BC2 5U
+
+/* kirai */
+#define MAX_KT 12U
+#define DEF_KS (DEF_ES0+MAX_ET*2U) /* sprite tile id */
+#define DEF_KC 4U /* sprite data id */
+#define DEF_KX 0U /* bomb x pos (default_dot) */
+#define DEF_KY 0U /* bomb y pos (default_dot) */
+#define MIN_KY (DEF_PY+1U) /* min y pos (dot) */
+
+unsigned char msg_tile[64];
+
+const unsigned char * const msg_1up = "1UP";
+const unsigned char * const msg_lv = "LV";
+
+const unsigned char * const msg_gover = "GAMEOVER";
+const unsigned char * const msg_pause = " PAUSE! ";
+const unsigned char * const msg_start = " ";
+
+uint8_t pf, px, pp, pl;
+uint16_t pw;
+uint16_t ps;
+uint8_t tf[MAX_TT];
+uint8_t tx[MAX_TT], ty[MAX_TT];
+uint8_t ef[MAX_ET], ex[MAX_ET], ey[MAX_ET];
+uint8_t kf[MAX_KT], kx[MAX_KT], ky[MAX_KT];
+uint8_t rnd_enemy, rnd_kirai;
+uint8_t k_right, k_left;
+
+void set_sprite_attrb( uint8_t nb, uint8_t tile )
+{
+ if(DEVICE_SUPPORTS_COLOR) {
+ set_sprite_prop( nb, tile );
+ }
+}
+
+
+void set_bkg_attr( uint8_t x, uint8_t y, uint8_t sx, uint8_t sy, unsigned char *d )
+{
+ uint8_t xx, yy;
+
+ VBK_REG = 1; /* select palette bank */
+ for( yy=0; yy<sy; yy++ ) {
+ for( xx=0; xx<sx; xx++ ) {
+ msg_tile[xx] = bkgCGB[(unsigned int)*d];
+ d++;
+ }
+ set_bkg_tiles( x, y+yy, sx, 1, msg_tile );
+ }
+ VBK_REG = 0; /* select data bank */
+}
+
+uint8_t make_rnd( uint8_t i )
+{
+ return( arand()%(i+1) );
+}
+
+void show_score( uint16_t s )
+{
+ uint16_t m;
+ uint8_t i, n, f;
+ unsigned char score[6];
+
+ f = 0; m = 10000;
+ for( i=0; i<5; i++ ) {
+ n = s/m; s = s%m; m = m/10;
+ if( (n==0)&&(f==0) ) {
+ score[i] = 0x20; /* ' ' */
+ } else {
+ f = 1;
+ score[i] = 0x30+n; /* '0' - '9' */
+ }
+ }
+ score[5] = 0x30; /* '0' */
+ set_bkg_tiles( 4, 0, 6, 1, score );
+}
+
+void set_level( uint8_t i )
+{
+ /* level */
+ if( i < 9 ) {
+ rnd_enemy = 100-(i*12); /* 1% - */
+ rnd_kirai = 50-(i*6); /* 2% - */
+ } else {
+ rnd_enemy = 0; /* 100 % */
+ rnd_kirai = 0; /* 100 % */
+ }
+}
+
+void show_level( uint8_t i )
+{
+ unsigned char level[2];
+
+ if( i < 9 ) {
+ level[0] = 0x31+i;
+ } else {
+ level[0] = 0x41+i-9;
+ }
+ set_bkg_tiles( 19, 0, 1, 1, level );
+ set_level( i );
+}
+
+void show_gover()
+{
+ set_bkg_tiles( 6, 9, 8, 1, (unsigned char *)msg_gover );
+ pf = DEF_PF;
+}
+
+void show_pause()
+{
+ set_bkg_tiles( 6, 9, 8, 1, (unsigned char *)msg_pause );
+}
+
+void hide_msg()
+{
+ set_bkg_tiles( 6, 9, 8, 1, (unsigned char *)msg_start );
+}
+
+void init_score()
+{
+ ps = 0;
+ show_score( ps );
+ pp = 0; pl = 0;
+ show_level( pl );
+}
+
+void init_screen()
+{
+ uint8_t n;
+
+ if(DEVICE_SUPPORTS_COLOR) {
+ /* Transfer color palette */
+ set_bkg_palette( 0, 1, &bkg_p[0] );
+ set_bkg_palette( 1, 1, &bkg_p[4] );
+ set_bkg_palette( 2, 1, &bkg_p[8] );
+ set_bkg_palette( 3, 1, &bkg_p[12] );
+ set_bkg_palette( 4, 1, &bkg_p[16] );
+ set_bkg_palette( 5, 1, &bkg_p[20] );
+ set_bkg_palette( 6, 1, &bkg_p[24] );
+ set_bkg_palette( 7, 1, &bkg_p[28] );
+ set_sprite_palette( 0, 1, &obj_p[0] );
+ set_sprite_palette( 1, 1, &obj_p[4] );
+ set_sprite_palette( 2, 1, &obj_p[8] );
+ set_sprite_palette( 3, 1, &obj_p[12] );
+ set_sprite_palette( 4, 1, &obj_p[16] );
+ set_sprite_palette( 5, 1, &obj_p[20] );
+ set_sprite_palette( 6, 1, &obj_p[24] );
+ set_sprite_palette( 7, 1, &obj_p[28] );
+
+ /* set attributes */
+ set_bkg_attr( 0, 0, 20, 18, bkg_c );
+ set_bkg_tiles( 0, 0, 20, 18, bkg_c );
+ } else {
+ set_bkg_tiles( 0, 0, 20, 18, bkg_m );
+ }
+
+ pw = 50;
+ set_bkg_data( 0, 96, bkg );
+ set_bkg_tiles( 0, 0, 3, 1, (unsigned char *)msg_1up );
+ set_bkg_tiles( 16, 0, 2, 1, (unsigned char *)msg_lv );
+ SHOW_BKG;
+ SPRITES_8x8;
+ set_sprite_data( 0, 128, fore );
+ SHOW_SPRITES;
+ for( n=0; n<40; n++ ) {
+ set_sprite_tile( n, DEF_SP );
+ move_sprite( n, 0, 0 );
+ }
+}
+
+void init_player()
+{
+ pf = 0; px = DEF_PX;
+ set_sprite_tile( 0, 0 );
+ set_sprite_attrb( 0, foreCGB[0] );
+ move_sprite( 0, px, DEF_PY );
+ set_sprite_tile( 1, 1 );
+ set_sprite_attrb( 1, foreCGB[1] );
+ move_sprite( 1, px+8, DEF_PY );
+}
+
+void init_tama()
+{
+ uint8_t i;
+
+ for( i=0; i<MAX_TT; i++ ) {
+ tf[i] = 0;
+ tx[i] = i*4+DEF_TX;
+ ty[i] = DEF_TY;
+ set_sprite_tile( i+DEF_TS, tf[i]+DEF_TC );
+ set_sprite_attrb( i+DEF_TS, foreCGB[tf[i]+DEF_TC] );
+ move_sprite( i+DEF_TS, tx[i], ty[i] );
+ }
+}
+
+void init_enemy()
+{
+ uint8_t i;
+
+ for( i=0; i<MAX_ET; i++ ) {
+ ef[i] = 0;
+ ex[i] = 0;
+ ey[i] = 0;
+ set_sprite_tile( i*2+DEF_ES0, DEF_SP );
+ set_sprite_tile( i*2+DEF_ES1, DEF_SP );
+ move_sprite( i*2+DEF_ES0, ex[i], ey[i] );
+ move_sprite( i*2+DEF_ES1, ex[i], ey[i] );
+ }
+}
+
+void init_kirai()
+{
+ uint8_t i;
+
+ for( i=0; i<MAX_KT; i++ ) {
+ kf[i] = 0;
+ kx[i] = DEF_KX;
+ ky[i] = DEF_KY;
+ set_sprite_tile( i+DEF_KS, DEF_SP );
+ move_sprite( i+DEF_KS, kx[i], ky[i] );
+ }
+}
+
+/* player */
+void player()
+{
+ uint8_t key;
+ uint8_t i;
+ uint16_t seed;
+
+ key = joypad();
+ /* pause */
+ if( key & J_START ) {
+ if( pf == DEF_PF ) {
+ /* Initialize the random number generator */
+ seed = DIV_REG;
+ waitpadup();
+ seed |= ((uint16_t)DIV_REG << 8);
+ initarand(seed);
+ hide_msg();
+ init_score();
+ init_player();
+ init_tama();
+ init_enemy();
+ init_kirai();
+ delay( 500 );
+ } else {
+ show_pause();
+ waitpadup();
+ key = joypad();
+ while( !(key & J_START) ) {
+ key = joypad();
+ if( key & J_DOWN ) {
+ if(pl > 0)
+ pl--;
+ show_level( pl );
+ waitpadup();
+ } else if( key & J_UP ) {
+ if(pl < 8)
+ pl++;
+ show_level( pl );
+ waitpadup();
+ } else if( key & J_LEFT ) {
+ while( joypad() & J_LEFT ) {
+ if(pw > 0)
+ pw--;
+ show_score( pw );
+ delay( 250 );
+ }
+ show_score( ps );
+ } else if( key & J_RIGHT ) {
+ while( joypad() & J_RIGHT ) {
+ if(pw < 99)
+ pw++;
+ show_score( pw );
+ delay( 250 );
+ }
+ show_score( ps );
+ } else if( key & J_SELECT ) {
+ i = k_right;
+ k_right = k_left;
+ k_left = i;
+ waitpadup();
+ }
+ }
+ waitpadup();
+ hide_msg();
+ delay( 500 );
+ }
+ return;
+ }
+
+ /* dead */
+ if( pf > 1 ) {
+ if( pf < DEF_PF ) {
+ set_sprite_tile( 0, pf*2+DEF_PC0 );
+ set_sprite_attrb( 0, foreCGB[pf*2+DEF_PC0] );
+ set_sprite_tile( 1, pf*2+DEF_PC1 );
+ set_sprite_attrb( 1, foreCGB[pf*2+DEF_PC1] );
+ pf++;
+ } else {
+ set_sprite_tile( 0, DEF_SP );
+ set_sprite_tile( 1, DEF_SP );
+ show_gover();
+ }
+ return;
+ }
+
+ /* move */
+ if( (key&J_LEFT)&&(px>MIN_PX) ) {
+ px--;
+ move_sprite( 0, px, DEF_PY ); move_sprite( 1, px+8, DEF_PY );
+ } else if( (key&J_RIGHT)&&(px<MAX_PX) ) {
+ px++;
+ move_sprite( 0, px, DEF_PY ); move_sprite( 1, px+8, DEF_PY );
+ }
+ /* shot */
+ if( key & k_left ) { /* change J_B to J_A */
+ if( pf == 0 ) {
+ pf = 1;
+ for( i=0; i<MAX_TT; i++ ) {
+ if( tf[i] == 0 ) {
+ tf[i] = 1; tx[i] = px-4; ty[i] = DEF_PY;
+ break;
+ }
+ }
+ }
+ } else if( key & k_right ) { /* change J_A to J_B */
+ if( pf == 0 ) {
+ pf = 1;
+ for( i=0; i<MAX_TT; i++ ) {
+ if( tf[i] == 0 ) {
+ tf[i] = 1; tx[i] = px+12; ty[i] = DEF_PY;
+ break;
+ }
+ }
+ }
+ } else if( pf == 1 ) {
+ pf = 0;
+ }
+}
+
+/* bombs */
+void bombs()
+{
+ uint8_t i;
+
+ for( i=0; i<MAX_TT; i++ ) {
+ if( tf[i] != 0 ) {
+ ty[i]++;
+ if( ty[i] > MAX_TY ) {
+ tf[i] = 0; tx[i] = i*4+DEF_TX; ty[i] = DEF_TY;
+ } else {
+ tf[i] = 3-tf[i];
+ }
+ set_sprite_tile( i+DEF_TS, tf[i]+DEF_TC );
+ set_sprite_attrb( i+DEF_TS, foreCGB[tf[i]+DEF_TC] );
+ move_sprite( i+DEF_TS, tx[i], ty[i] );
+ }
+ }
+}
+
+/* enemys */
+void enemys()
+{
+ uint8_t i, j;
+
+ for( i=0; i<MAX_ET; i++ ) {
+ if( ef[i] == 1 ) {
+ /* move right to left */
+ ex[i]--;
+ if( (pl>0)&&(ey[i]<SPEED_EY) ) ex[i]--;
+ if( ex[i] <= MIN_EX ) {
+ ef[i] = 0;
+ set_sprite_tile( i*2+DEF_ES0, DEF_SP );
+ set_sprite_tile( i*2+DEF_ES1, DEF_SP );
+ } else {
+ /* new */
+ if( ex[i]<MIN_SX*8+13 ) {
+ set_sprite_tile( i*2+DEF_ES0, DEF_1EC0 );
+ set_sprite_tile( i*2+DEF_ES1, DEF_1EC1 );
+ } else if( ex[i]<MIN_SX*8+20 ) {
+ set_sprite_tile( i*2+DEF_ES0, DEF_1EC0 );
+ set_sprite_tile( i*2+DEF_ES1, DEF_1EC1+(ex[i]-MIN_SX*8-13) );
+ } else if( ex[i]<MIN_SX*8+28 ) {
+ set_sprite_tile( i*2+DEF_ES0, DEF_1EC0+(ex[i]-MIN_SX*8-20) );
+ set_sprite_tile( i*2+DEF_ES1, DEF_1EC1+8 );
+ } else if( ex[i]<MAX_SX*8+13 ) {
+ set_sprite_tile( i*2+DEF_ES0, DEF_1EC0+8 );
+ set_sprite_tile( i*2+DEF_ES1, DEF_1EC1+8 );
+ } else if( ex[i]<MAX_SX*8+20 ) {
+ set_sprite_tile( i*2+DEF_ES0, DEF_1EC0+8 );
+ set_sprite_tile( i*2+DEF_ES1, DEF_1EC1+(ex[i]-MAX_SX*8-12)+7 );
+ } else if( ex[i]<MAX_SX*8+28 ) {
+ set_sprite_tile( i*2+DEF_ES0, DEF_1EC0+(ex[i]-MAX_SX*8-20)+8 );
+ set_sprite_tile( i*2+DEF_ES1, DEF_1EC1 );
+ } else {
+ set_sprite_tile( i*2+DEF_ES0, DEF_1EC0 );
+ set_sprite_tile( i*2+DEF_ES1, DEF_1EC1 );
+ }
+ /* new */
+ move_sprite( i*2+DEF_ES0, ex[i]-SUB_EX0, ey[i] );
+ move_sprite( i*2+DEF_ES1, ex[i]-SUB_EX1, ey[i] );
+ /* check bomb */
+ for( j=0; j<MAX_TT; j++ ) {
+ if( tf[j] != 0 ) {
+ if( (ty[j]>ey[i]-2)&&(ty[j]<ey[i]+2) ) {
+ if( (tx[j]>(ex[i]-SUB_EX0-5))&&(tx[j]<(ex[i]-SUB_EX1+5)) ) {
+ /* hit */
+ tf[j] = 0; tx[j] = j*4+DEF_TX; ty[j] = DEF_TY;
+ set_sprite_tile( j+DEF_TS, tf[j]+DEF_TC );
+ set_sprite_attrb( j+DEF_TS, foreCGB[tf[j]+DEF_TC] );
+ move_sprite( j+DEF_TS, tx[j], ty[j] );
+ ef[i] = 3;
+ set_sprite_tile( i*2+DEF_ES0, ef[i]*2+DEF_BC1 );
+ set_sprite_attrb( i*2+DEF_ES0, foreCGB[ef[i]*2+DEF_BC1] );
+ set_sprite_tile( i*2+DEF_ES1, ef[i]*2+DEF_BC2 );
+ set_sprite_attrb( i*2+DEF_ES1, foreCGB[ef[i]*2+DEF_BC2] );
+ }
+ }
+ }
+ }
+ if( make_rnd(rnd_kirai) == 0 ) {
+ if( ((ex[i]-SUB_EX0)>MIN_PX)&&((ex[i]-SUB_EX0)<MAX_PX) ) {
+ if( kf[i] == 0 ) {
+ /* shot kirai */
+ kf[i] = 1;
+ kx[i] = ex[i]-SUB_EX0+4;
+ ky[i] = ey[i]-4;
+ } else if( kf[i+1] == 0 ) {
+ /* shot kirai */
+ kf[i+1] = 1;
+ kx[i+1] = ex[i]-SUB_EX0+4;
+ ky[i+1] = ey[i]-4;
+ } else if( kf[i+2] == 0 ) {
+ /* shot kirai */
+ kf[i+2] = 1;
+ kx[i+2] = ex[i]-SUB_EX0+4;
+ ky[i+2] = ey[i]-4;
+ }
+ }
+ }
+ }
+ } else if( ef[i] == 2 ) {
+ /* move left to right */
+ ex[i]++;
+ if( (pl>0)&&(ey[i]<SPEED_EY) ) ex[i]++;
+ if( ex[i] >= MAX_EX ) {
+ ef[i] = 0;
+ set_sprite_tile( i*2+DEF_ES0, DEF_SP );
+ set_sprite_tile( i*2+DEF_ES1, DEF_SP );
+ } else {
+ /* new */
+ if( i==9 ) {
+ if( ex[i]<MIN_SX*8+13 ) {
+ set_sprite_tile( i*2+DEF_ES0, DEF_XEC0 );
+ set_sprite_tile( i*2+DEF_ES1, DEF_XEC1 );
+ } else if( ex[i]<MIN_SX*8+20 ) {
+ set_sprite_tile( i*2+DEF_ES0, DEF_XEC0 );
+ set_sprite_tile( i*2+DEF_ES1, DEF_XEC1+(ex[i]-MIN_SX*8-13) );
+ } else if( ex[i]<MIN_SX*8+28 ) {
+ set_sprite_tile( i*2+DEF_ES0, DEF_XEC0+(ex[i]-MIN_SX*8-20) );
+ set_sprite_tile( i*2+DEF_ES1, DEF_XEC1+8 );
+ } else if( ex[i]<MAX_SX*8+13 ) {
+ set_sprite_tile( i*2+DEF_ES0, DEF_XEC0+8 );
+ set_sprite_tile( i*2+DEF_ES1, DEF_XEC1+8 );
+ } else if( ex[i]<MAX_SX*8+20 ) {
+ set_sprite_tile( i*2+DEF_ES0, DEF_XEC0+8 );
+ set_sprite_tile( i*2+DEF_ES1, DEF_XEC1+(ex[i]-MAX_SX*8-12)+7 );
+ } else if( ex[i]<MAX_SX*8+28 ) {
+ set_sprite_tile( i*2+DEF_ES0, DEF_XEC0+(ex[i]-MAX_SX*8-20)+8 );
+ set_sprite_tile( i*2+DEF_ES1, DEF_XEC1 );
+ } else {
+ set_sprite_tile( i*2+DEF_ES0, DEF_XEC0 );
+ set_sprite_tile( i*2+DEF_ES1, DEF_XEC1 );
+ }
+ } else {
+ if( ex[i]<MIN_SX*8+13 ) {
+ set_sprite_tile( i*2+DEF_ES0, DEF_2EC0 );
+ set_sprite_tile( i*2+DEF_ES1, DEF_2EC1 );
+ } else if( ex[i]<MIN_SX*8+20 ) {
+ set_sprite_tile( i*2+DEF_ES0, DEF_2EC0 );
+ set_sprite_tile( i*2+DEF_ES1, DEF_2EC1+(ex[i]-MIN_SX*8-13) );
+ } else if( ex[i]<MIN_SX*8+28 ) {
+ set_sprite_tile( i*2+DEF_ES0, DEF_2EC0+(ex[i]-MIN_SX*8-20) );
+ set_sprite_tile( i*2+DEF_ES1, DEF_2EC1+8 );
+ } else if( ex[i]<MAX_SX*8+13 ) {
+ set_sprite_tile( i*2+DEF_ES0, DEF_2EC0+8 );
+ set_sprite_tile( i*2+DEF_ES1, DEF_2EC1+8 );
+ } else if( ex[i]<MAX_SX*8+20 ) {
+ set_sprite_tile( i*2+DEF_ES0, DEF_2EC0+8 );
+ set_sprite_tile( i*2+DEF_ES1, DEF_2EC1+(ex[i]-MAX_SX*8-12)+7 );
+ } else if( ex[i]<MAX_SX*8+28 ) {
+ set_sprite_tile( i*2+DEF_ES0, DEF_2EC0+(ex[i]-MAX_SX*8-20)+8 );
+ set_sprite_tile( i*2+DEF_ES1, DEF_2EC1 );
+ } else {
+ set_sprite_tile( i*2+DEF_ES0, DEF_2EC0 );
+ set_sprite_tile( i*2+DEF_ES1, DEF_2EC1 );
+ }
+ }
+ /* new */
+ move_sprite( i*2+DEF_ES0, ex[i]-SUB_EX0, ey[i] );
+ move_sprite( i*2+DEF_ES1, ex[i]-SUB_EX1, ey[i] );
+ /* check bomb */
+ for( j=0; j<MAX_TT; j++ ) {
+ if( tf[j] != 0 ) {
+ if( (ty[j]>ey[i]-2)&&(ty[j]<ey[i]+2) ) {
+ if( (tx[j]>(ex[i]-SUB_EX0-5))&&(tx[j]<(ex[i]-SUB_EX1+5)) ) {
+ /* hit */
+ tf[j] = 0; tx[j] = j*4+DEF_TX; ty[j] = DEF_TY;
+ set_sprite_tile( j+DEF_TS, tf[j]+DEF_TC );
+ set_sprite_attrb( j+DEF_TS, foreCGB[tf[j]+DEF_TC] );
+ move_sprite( j+DEF_TS, tx[j], ty[j] );
+ ef[i] = 3;
+ set_sprite_tile( i*2+DEF_ES0, ef[i]*2+DEF_BC1 );
+ set_sprite_attrb( i*2+DEF_ES0, foreCGB[ef[i]*2+DEF_BC1] );
+ set_sprite_tile( i*2+DEF_ES1, ef[i]*2+DEF_BC2 );
+ set_sprite_attrb( i*2+DEF_ES1, foreCGB[ef[i]*2+DEF_BC2] );
+ }
+ }
+ }
+ }
+ if( make_rnd(rnd_kirai) == 0 ) {
+ if( ((ex[i]-SUB_EX0)>MIN_PX)&&((ex[i]-SUB_EX0)<MAX_PX) ) {
+ if( kf[i] == 0 ) {
+ /* shot kirai */
+ kf[i] = 1;
+ kx[i] = ex[i]-SUB_EX0+4;
+ ky[i] = ey[i]-4;
+ } else if( kf[i+1] == 0 ) {
+ /* shot kirai */
+ kf[i+1] = 1;
+ kx[i+1] = ex[i]-SUB_EX0+4;
+ ky[i+1] = ey[i]-4;
+ } else if( kf[i+2] == 0 ) {
+ /* shot kirai */
+ kf[i+2] = 1;
+ kx[i+2] = ex[i]-SUB_EX0+4;
+ ky[i+2] = ey[i]-4;
+ }
+ }
+ }
+ }
+ } else if( ef[i] >= 3 ) {
+ if( ef[i] > 4 ) {
+ ef[i] = 0;
+ set_sprite_tile( i*2+DEF_ES0, DEF_SP );
+ set_sprite_tile( i*2+DEF_ES1, DEF_SP );
+ if( i == 9 ) {
+ ps += 100; show_score( ps ); pp++;
+ set_level( pl-1 );
+ } else {
+ ps += (i+1); show_score( ps ); pp++;
+ }
+ } else {
+ set_sprite_tile( i*2+DEF_ES0, ef[i]*2+DEF_BC1 );
+ set_sprite_attrb( i*2+DEF_ES0, foreCGB[ef[i]*2+DEF_BC1] );
+ set_sprite_tile( i*2+DEF_ES1, ef[i]*2+DEF_BC2 );
+ set_sprite_attrb( i*2+DEF_ES1, foreCGB[ef[i]*2+DEF_BC2] );
+ ef[i]++;
+ }
+ } else if( i == 9 ) {
+ if( pp > 20 ) {
+ pp = 0;
+ pl++; show_level( pl );
+ /* X */
+ ey[i] = i*DEF_EH+DEF_EY;
+ ef[i] = i%2+1;
+ ex[i] = MIN_EX;
+ set_sprite_tile( i*2+DEF_ES0, DEF_XEC0 );
+ set_sprite_attrb( i*2+DEF_ES0, foreCGB[DEF_XEC0] );
+ set_sprite_tile( i*2+DEF_ES1, DEF_XEC1 );
+ set_sprite_attrb( i*2+DEF_ES1, foreCGB[DEF_XEC1] );
+ move_sprite( i*2+DEF_ES0, ex[i]-SUB_EX0, ey[i] );
+ move_sprite( i*2+DEF_ES1, ex[i]-SUB_EX1, ey[i] );
+ }
+ } else if( make_rnd(rnd_enemy) == 0 ) {
+ if( !((pl<4)&&(i==0)) ) {
+ /* create */
+ ey[i] = i*DEF_EH+DEF_EY;
+ ef[i] = i%2+1;
+ if( ef[i] == 1 ) {
+ ex[i] = MAX_EX;
+ set_sprite_tile( i*2+DEF_ES0, DEF_1EC0 );
+ set_sprite_attrb( i*2+DEF_ES0, foreCGB[DEF_1EC0] );
+ set_sprite_tile( i*2+DEF_ES1, DEF_1EC1 );
+ set_sprite_attrb( i*2+DEF_ES1, foreCGB[DEF_1EC1] );
+ } else {
+ ex[i] = MIN_EX;
+ set_sprite_tile( i*2+DEF_ES0, DEF_2EC0 );
+ set_sprite_attrb( i*2+DEF_ES0, foreCGB[DEF_2EC0] );
+ set_sprite_tile( i*2+DEF_ES1, DEF_2EC1 );
+ set_sprite_attrb( i*2+DEF_ES1, foreCGB[DEF_2EC1] );
+ }
+ move_sprite( i*2+DEF_ES0, ex[i]-SUB_EX0, ey[i] );
+ move_sprite( i*2+DEF_ES1, ex[i]-SUB_EX1, ey[i] );
+ }
+ }
+ }
+}
+
+/* kirai */
+void kirai()
+{
+ uint8_t i;
+
+ for( i=0; i<MAX_KT; i++ ) {
+ if( kf[i] != 0 ) {
+ ky[i]--;
+ if( kf[i] >=3 ) {
+ kf[i]++;
+ if( (kx[i]>(px-5))&&(kx[i]<(px+12)) ) {
+ if( pf < 2 ) {
+ /* out!! */
+ pf = 2;
+ }
+ }
+ if( kf[i] >= 6 ) {
+ kf[i] = 0; kx[i] = DEF_KX; ky[i] = DEF_KY;
+ }
+ } else if( ky[i] <= MIN_KY ) {
+ kf[i] = 3;
+ } else {
+ kf[i] = 3-kf[i];
+ }
+ set_sprite_tile( i+DEF_KS, kf[i]+DEF_KC );
+ set_sprite_attrb( i+DEF_KS, foreCGB[kf[i]+DEF_KC] );
+ move_sprite( i+DEF_KS, kx[i], ky[i] );
+ }
+ }
+}
+
+/*--------------------------------------------------------------------------*
+ | main program |
+ *--------------------------------------------------------------------------*/
+void main()
+{
+ disable_interrupts();
+ DISPLAY_OFF;
+
+ initarand(((uint16_t)DIV_REG << 8));
+
+ init_screen();
+ init_score();
+ init_player();
+ init_tama();
+ init_enemy();
+ init_kirai();
+ show_gover();
+ k_right = J_A;
+ k_left = J_B;
+ DISPLAY_ON;
+ enable_interrupts();
+
+ while(1) {
+ delay( pw );
+ player();
+ bombs();
+ enemys();
+ kirai();
+ }
+}
diff --git a/gbdk/gbdk-lib/examples/gb/dscan/fore.c b/gbdk/gbdk-lib/examples/gb/dscan/fore.c
new file mode 100644
index 00000000..24ac988d
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/dscan/fore.c
@@ -0,0 +1,306 @@
+/*
+
+ FORE.C
+
+ Tile Source File.
+
+ Info:
+ Form : All tiles as one unit.
+ Format : Gameboy 4 color.
+ Compression : None.
+ Counter : None.
+ Tile size : 8 x 8
+ Tiles : 0 to 127
+
+ Palette colors : Included.
+ SGB Palette : None.
+ CGB Palette : 1 Byte per entry.
+
+ Convert to metatiles : No.
+
+ This file was generated by GBTD v1.6
+
+*/
+
+/* CGBpalette entries. */
+const unsigned char foreCGB[] =
+{
+ 0x01,0x01,0x02,0x02,0x02,0x02,0x02,0x05,
+ 0x05,0x05,0x01,0x01,0x01,0x01,0x01,0x01,
+ 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
+ 0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,
+ 0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
+ 0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
+ 0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,
+ 0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04
+};
+/* Start of tile array. */
+const unsigned char fore[] =
+{
+ 0x00,0x00,0x01,0x01,0x01,0x01,0x03,0x03,
+ 0x7F,0x7F,0x3F,0x3F,0x1F,0x1F,0x00,0x00,
+ 0x00,0x00,0x80,0x80,0x80,0x80,0xC0,0xC0,
+ 0xFE,0xFE,0xFC,0xFC,0xF8,0xF8,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x18,0x18,0x18,0x18,
+ 0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x10,0x30,0x38,
+ 0x0C,0x1C,0x00,0x08,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x08,0x0C,0x1C,
+ 0x30,0x38,0x00,0x10,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x04,0x04,0x08,0x08,0x14,0x14,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x10,0x10,0x08,0x08,0x14,0x14,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x08,0x08,0x14,0x1C,0x1C,0x14,0x00,0x00,
+ 0x08,0x08,0x08,0x08,0x41,0x41,0x2A,0x2A,
+ 0x2A,0x3E,0x14,0x1C,0x1C,0x14,0x08,0x00,
+ 0x00,0x00,0x00,0x00,0x08,0x08,0x00,0x00,
+ 0x41,0x41,0x00,0x00,0x1C,0x1C,0x22,0x3E,
+ 0x00,0x00,0x08,0x00,0x04,0x00,0x11,0x00,
+ 0x11,0x00,0x04,0x00,0x08,0x00,0x00,0x00,
+ 0x00,0x00,0x10,0x00,0x20,0x00,0x88,0x00,
+ 0x88,0x00,0x20,0x00,0x10,0x00,0x00,0x00,
+ 0x10,0x00,0x08,0x00,0x21,0x00,0x02,0x00,
+ 0x02,0x00,0x21,0x00,0x08,0x00,0x10,0x00,
+ 0x08,0x00,0x10,0x00,0x84,0x00,0x40,0x00,
+ 0x40,0x00,0x84,0x00,0x10,0x00,0x08,0x00,
+ 0x10,0x00,0x01,0x00,0x40,0x00,0x04,0x00,
+ 0x04,0x00,0x40,0x00,0x01,0x00,0x10,0x00,
+ 0x08,0x00,0x80,0x00,0x02,0x00,0x20,0x00,
+ 0x20,0x00,0x02,0x00,0x80,0x00,0x08,0x00,
+ 0x00,0x10,0x01,0x0B,0x01,0x3E,0x64,0x7B,
+ 0x73,0x7C,0x3F,0x38,0x1F,0x1C,0x00,0x00,
+ 0x00,0x08,0x80,0xD0,0x80,0x7C,0x26,0xDE,
+ 0xCE,0x3E,0xFC,0x1C,0xF8,0x38,0x00,0x00,
+ 0x00,0x22,0x05,0x93,0x01,0x7E,0x5E,0x61,
+ 0x1F,0x70,0x2F,0xB0,0x1F,0x30,0x00,0x00,
+ 0x00,0x44,0xA0,0xC9,0x80,0x7E,0x7A,0x86,
+ 0xF8,0x0E,0xF4,0x0D,0xF8,0x0C,0x00,0x00,
+ 0x00,0x21,0x05,0x90,0x06,0x78,0x6A,0x76,
+ 0x10,0x7F,0x20,0xBF,0x18,0x37,0x00,0x00,
+ 0x00,0x84,0xA0,0x09,0x60,0x1E,0x56,0x6E,
+ 0x08,0xFE,0x04,0xFD,0x18,0xEC,0x00,0x00,
+ 0x00,0x00,0x60,0x60,0x70,0x74,0xFE,0xFE,
+ 0xDC,0xFE,0x7E,0x7E,0x37,0x3F,0x00,0x00,
+ 0x00,0x00,0x06,0x06,0x0E,0x2E,0x7F,0x7F,
+ 0x3B,0x7F,0x7E,0x7E,0xEC,0xFC,0x00,0x00,
+ 0x00,0x00,0x00,0x04,0x40,0x40,0x40,0x62,
+ 0xF0,0xF0,0xF4,0xFC,0x7E,0x7E,0x00,0x00,
+ 0x00,0x00,0x00,0x20,0x02,0x02,0x02,0x46,
+ 0x0F,0x0F,0x2F,0x3F,0x7E,0x7E,0x00,0x00,
+ 0x00,0x04,0x00,0x00,0x00,0x20,0x00,0x00,
+ 0x40,0x48,0x40,0x40,0xF0,0xF0,0x00,0x00,
+ 0x00,0x20,0x00,0x00,0x00,0x04,0x00,0x00,
+ 0x02,0x12,0x02,0x02,0x0F,0x0F,0x00,0x00,
+ 0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x40,0x40,0x00,0x00,
+ 0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x02,0x02,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x02,0x00,0x0D,0x00,0x30,
+ 0x00,0x40,0x00,0x40,0x00,0x3F,0x00,0x00,
+ 0x00,0x00,0x00,0x02,0x01,0x0D,0x01,0x31,
+ 0x01,0x41,0x01,0x41,0x01,0x3F,0x00,0x00,
+ 0x00,0x00,0x02,0x02,0x03,0x0F,0x03,0x33,
+ 0x03,0x43,0x03,0x43,0x03,0x3F,0x00,0x00,
+ 0x00,0x00,0x02,0x02,0x07,0x0F,0x07,0x37,
+ 0x07,0x47,0x07,0x47,0x07,0x3F,0x00,0x00,
+ 0x00,0x00,0x02,0x02,0x0F,0x0F,0x0F,0x3F,
+ 0x0F,0x4F,0x0F,0x4F,0x0F,0x3F,0x00,0x00,
+ 0x00,0x00,0x02,0x02,0x0F,0x0F,0x1F,0x3F,
+ 0x1F,0x5F,0x1F,0x5F,0x1F,0x3F,0x00,0x00,
+ 0x00,0x00,0x02,0x02,0x0F,0x0F,0x3F,0x3F,
+ 0x3F,0x7F,0x3F,0x7F,0x3F,0x3F,0x00,0x00,
+ 0x00,0x00,0x02,0x02,0x0F,0x0F,0x3F,0x3F,
+ 0x7F,0x7F,0x7F,0x7F,0x3F,0x3F,0x00,0x00,
+ 0x00,0x00,0x02,0x02,0x0F,0x0F,0x3F,0x3F,
+ 0x7F,0x7F,0x7F,0x7F,0x3F,0x3F,0x00,0x00,
+ 0x00,0x00,0x02,0x02,0x0E,0x0F,0x3E,0x3E,
+ 0x7E,0x7E,0x7E,0x7E,0x3E,0x3F,0x00,0x00,
+ 0x00,0x00,0x00,0x02,0x0C,0x0D,0x3C,0x3C,
+ 0x7C,0x7C,0x7C,0x7C,0x3C,0x3F,0x00,0x00,
+ 0x00,0x00,0x00,0x02,0x08,0x0D,0x38,0x38,
+ 0x78,0x78,0x78,0x78,0x38,0x3F,0x00,0x00,
+ 0x00,0x00,0x00,0x02,0x00,0x0D,0x30,0x30,
+ 0x70,0x70,0x70,0x70,0x30,0x3F,0x00,0x00,
+ 0x00,0x00,0x00,0x02,0x00,0x0D,0x20,0x30,
+ 0x60,0x60,0x60,0x60,0x20,0x3F,0x00,0x00,
+ 0x00,0x00,0x00,0x02,0x00,0x0D,0x00,0x30,
+ 0x40,0x40,0x40,0x40,0x00,0x3F,0x00,0x00,
+ 0x00,0x00,0x00,0x02,0x00,0x0D,0x00,0x30,
+ 0x00,0x40,0x00,0x40,0x00,0x3F,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x72,
+ 0x00,0x0E,0x00,0x12,0x00,0xE0,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x80,0x02,0x72,
+ 0x02,0x0E,0x02,0x12,0x00,0xE0,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x80,0x02,0x72,
+ 0x06,0x0E,0x02,0x12,0x00,0xE0,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x80,0x02,0x72,
+ 0x0E,0x0E,0x02,0x12,0x00,0xE0,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x80,0x12,0x72,
+ 0x1E,0x1E,0x12,0x12,0x00,0xE0,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x80,0x32,0x72,
+ 0x3E,0x3E,0x32,0x32,0x20,0xE0,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x80,0x72,0x72,
+ 0x7E,0x7E,0x72,0x72,0x60,0xE0,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x80,0x80,0xF2,0xF2,
+ 0xFE,0xFE,0xF2,0xF2,0xE0,0xE0,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x80,0x80,0xF2,0xF2,
+ 0xFE,0xFE,0xF2,0xF2,0xE0,0xE0,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x80,0x80,0xF0,0xF2,
+ 0xFC,0xFE,0xF0,0xF2,0xE0,0xE0,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x80,0x80,0xF0,0xF2,
+ 0xF8,0xFE,0xF0,0xF2,0xE0,0xE0,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x80,0x80,0xF0,0xF2,
+ 0xF0,0xFE,0xF0,0xF2,0xE0,0xE0,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x80,0x80,0xE0,0xF2,
+ 0xE0,0xEE,0xE0,0xF2,0xE0,0xE0,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x80,0x80,0xC0,0xF2,
+ 0xC0,0xCE,0xC0,0xD2,0xC0,0xE0,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x80,0x80,0x80,0xF2,
+ 0x80,0x8E,0x80,0x92,0x80,0xE0,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x72,
+ 0x00,0x0E,0x00,0x12,0x00,0xE0,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x4E,
+ 0x00,0x70,0x00,0x48,0x00,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x4F,
+ 0x01,0x71,0x01,0x49,0x01,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x01,0x01,0x03,0x4F,
+ 0x03,0x73,0x03,0x4B,0x03,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x01,0x01,0x07,0x4F,
+ 0x07,0x77,0x07,0x4F,0x07,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x01,0x01,0x0F,0x4F,
+ 0x0F,0x7F,0x0F,0x4F,0x07,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x01,0x01,0x0F,0x4F,
+ 0x1F,0x7F,0x0F,0x4F,0x07,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x01,0x01,0x0F,0x4F,
+ 0x3F,0x7F,0x0F,0x4F,0x07,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x01,0x01,0x4F,0x4F,
+ 0x7F,0x7F,0x4F,0x4F,0x07,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x01,0x01,0x4F,0x4F,
+ 0x7F,0x7F,0x4F,0x4F,0x07,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x01,0x4E,0x4E,
+ 0x7E,0x7E,0x4E,0x4E,0x06,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x01,0x4C,0x4E,
+ 0x7C,0x7C,0x4C,0x4C,0x04,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x01,0x48,0x4E,
+ 0x78,0x78,0x48,0x48,0x00,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x01,0x40,0x4E,
+ 0x70,0x70,0x40,0x48,0x00,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x01,0x40,0x4E,
+ 0x60,0x70,0x40,0x48,0x00,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x01,0x40,0x4E,
+ 0x40,0x70,0x40,0x48,0x00,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x4E,
+ 0x00,0x70,0x00,0x48,0x00,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x40,0x00,0xB0,0x00,0x0C,
+ 0x00,0x02,0x00,0x02,0x00,0xFC,0x00,0x00,
+ 0x00,0x00,0x00,0x40,0x00,0xB0,0x00,0x0C,
+ 0x02,0x02,0x02,0x02,0x00,0xFC,0x00,0x00,
+ 0x00,0x00,0x00,0x40,0x00,0xB0,0x04,0x0C,
+ 0x06,0x06,0x06,0x06,0x04,0xFC,0x00,0x00,
+ 0x00,0x00,0x00,0x40,0x00,0xB0,0x0C,0x0C,
+ 0x0E,0x0E,0x0E,0x0E,0x0C,0xFC,0x00,0x00,
+ 0x00,0x00,0x00,0x40,0x10,0xB0,0x1C,0x1C,
+ 0x1E,0x1E,0x1E,0x1E,0x1C,0xFC,0x00,0x00,
+ 0x00,0x00,0x00,0x40,0x30,0xB0,0x3C,0x3C,
+ 0x3E,0x3E,0x3E,0x3E,0x3C,0xFC,0x00,0x00,
+ 0x00,0x00,0x40,0x40,0x70,0xF0,0x7C,0x7C,
+ 0x7E,0x7E,0x7E,0x7E,0x7C,0xFC,0x00,0x00,
+ 0x00,0x00,0x40,0x40,0xF0,0xF0,0xFC,0xFC,
+ 0xFE,0xFE,0xFE,0xFE,0xFC,0xFC,0x00,0x00,
+ 0x00,0x00,0x40,0x40,0xF0,0xF0,0xFC,0xFC,
+ 0xFE,0xFE,0xFE,0xFE,0xFC,0xFC,0x00,0x00,
+ 0x00,0x00,0x40,0x40,0xF0,0xF0,0xFC,0xFC,
+ 0xFC,0xFE,0xFC,0xFE,0xFC,0xFC,0x00,0x00,
+ 0x00,0x00,0x40,0x40,0xF0,0xF0,0xF8,0xFC,
+ 0xF8,0xFA,0xF8,0xFA,0xF8,0xFC,0x00,0x00,
+ 0x00,0x00,0x40,0x40,0xF0,0xF0,0xF0,0xFC,
+ 0xF0,0xF2,0xF0,0xF2,0xF0,0xFC,0x00,0x00,
+ 0x00,0x00,0x40,0x40,0xE0,0xF0,0xE0,0xEC,
+ 0xE0,0xE2,0xE0,0xE2,0xE0,0xFC,0x00,0x00,
+ 0x00,0x00,0x40,0x40,0xC0,0xF0,0xC0,0xCC,
+ 0xC0,0xC2,0xC0,0xC2,0xC0,0xFC,0x00,0x00,
+ 0x00,0x00,0x00,0x40,0x80,0xB0,0x80,0x8C,
+ 0x80,0x82,0x80,0x82,0x80,0xFC,0x00,0x00,
+ 0x00,0x00,0x00,0x40,0x00,0xB0,0x00,0x0C,
+ 0x00,0x02,0x00,0x02,0x00,0xFC,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,
+ 0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x01,0x01,0x03,0x03,
+ 0x03,0x03,0x03,0x03,0x03,0x03,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x01,0x01,0x07,0x07,
+ 0x07,0x07,0x07,0x07,0x07,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x01,0x01,0x0F,0x0F,
+ 0x0F,0x0F,0x0F,0x0F,0x07,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x01,0x01,0x0F,0x0F,
+ 0x1F,0x1F,0x0F,0x0F,0x07,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x01,0x01,0x0F,0x0F,
+ 0x3F,0x3F,0x0F,0x0F,0x07,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x01,0x01,0x4F,0x4F,
+ 0x7F,0x7F,0x4F,0x4F,0x07,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x01,0x01,0x4F,0x4F,
+ 0x7F,0x7F,0x4F,0x4F,0x07,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x4E,0x4E,
+ 0x7E,0x7E,0x4E,0x4E,0x06,0x06,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x4C,0x4C,
+ 0x7C,0x7C,0x4C,0x4C,0x04,0x04,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x48,0x48,
+ 0x78,0x78,0x48,0x48,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x40,
+ 0x70,0x70,0x40,0x40,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x40,
+ 0x60,0x60,0x40,0x40,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x40,
+ 0x40,0x40,0x40,0x40,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x02,0x02,0x02,0x02,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x04,
+ 0x06,0x06,0x06,0x06,0x04,0x04,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x0C,
+ 0x0E,0x0E,0x0E,0x0E,0x0C,0x0C,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x10,0x10,0x1C,0x1C,
+ 0x1E,0x1E,0x1E,0x1E,0x1C,0x1C,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x30,0x30,0x3C,0x1C,
+ 0x3E,0x3E,0x3E,0x1E,0x3C,0x3C,0x00,0x00,
+ 0x00,0x00,0x40,0x40,0x70,0x70,0x7C,0x5C,
+ 0x7E,0x3E,0x7E,0x5E,0x7C,0x7C,0x00,0x00,
+ 0x00,0x00,0x40,0x40,0xF0,0xF0,0xFC,0x5C,
+ 0xFE,0xBE,0xFE,0x5E,0xFC,0xFC,0x00,0x00,
+ 0x00,0x00,0x40,0x40,0xF0,0xF0,0xFC,0x5C,
+ 0xFE,0xBE,0xFE,0x5E,0xFC,0xFC,0x00,0x00,
+ 0x00,0x00,0x40,0x40,0xF0,0xF0,0xFC,0x5C,
+ 0xFC,0xBC,0xFC,0x5C,0xFC,0xFC,0x00,0x00,
+ 0x00,0x00,0x40,0x40,0xF0,0xF0,0xF8,0x58,
+ 0xF8,0xB8,0xF8,0x58,0xF8,0xF8,0x00,0x00,
+ 0x00,0x00,0x40,0x40,0xF0,0xF0,0xF0,0x50,
+ 0xF0,0xB0,0xF0,0x50,0xF0,0xF0,0x00,0x00,
+ 0x00,0x00,0x40,0x40,0xE0,0xE0,0xE0,0x40,
+ 0xE0,0xA0,0xE0,0x40,0xE0,0xE0,0x00,0x00,
+ 0x00,0x00,0x40,0x40,0xC0,0xC0,0xC0,0x40,
+ 0xC0,0x80,0xC0,0x40,0xC0,0xC0,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x00,
+ 0x80,0x80,0x80,0x00,0x80,0x80,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+};
+
+/* End of FORE.C */
diff --git a/gbdk/gbdk-lib/examples/gb/dscan/fore.gbr b/gbdk/gbdk-lib/examples/gb/dscan/fore.gbr
new file mode 100644
index 00000000..4d905c7a
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/dscan/fore.gbr
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/gb/dscan/fore.h b/gbdk/gbdk-lib/examples/gb/dscan/fore.h
new file mode 100644
index 00000000..3c73215b
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/dscan/fore.h
@@ -0,0 +1,105 @@
+/*
+
+ FORE.H
+
+ Include File.
+
+ Info:
+ Form : All tiles as one unit.
+ Format : Gameboy 4 color.
+ Compression : None.
+ Counter : None.
+ Tile size : 8 x 8
+ Tiles : 0 to 127
+
+ Palette colors : Included.
+ SGB Palette : None.
+ CGB Palette : 1 Byte per entry.
+
+ Convert to metatiles : No.
+
+ This file was generated by GBTD v1.6
+
+*/
+
+
+/* Bank of tiles. */
+#define foreBank 0
+
+/* Super Gameboy palette 0 */
+#define foreSGBPal0c0 0
+#define foreSGBPal0c1 0
+#define foreSGBPal0c2 0
+#define foreSGBPal0c3 18
+
+/* Super Gameboy palette 1 */
+#define foreSGBPal1c0 6108
+#define foreSGBPal1c1 8935
+#define foreSGBPal1c2 6596
+#define foreSGBPal1c3 6368
+
+/* Super Gameboy palette 2 */
+#define foreSGBPal2c0 6108
+#define foreSGBPal2c1 8935
+#define foreSGBPal2c2 6596
+#define foreSGBPal2c3 6368
+
+/* Super Gameboy palette 3 */
+#define foreSGBPal3c0 6108
+#define foreSGBPal3c1 8935
+#define foreSGBPal3c2 6596
+#define foreSGBPal3c3 6368
+
+/* Gameboy Color palette 0 */
+#define foreCGBPal0c0 32767
+#define foreCGBPal0c1 25368
+#define foreCGBPal0c2 19026
+#define foreCGBPal0c3 0
+
+/* Gameboy Color palette 1 */
+#define foreCGBPal1c0 32344
+#define foreCGBPal1c1 31
+#define foreCGBPal1c2 0
+#define foreCGBPal1c3 32767
+
+/* Gameboy Color palette 2 */
+#define foreCGBPal2c0 32344
+#define foreCGBPal2c1 31
+#define foreCGBPal2c2 25368
+#define foreCGBPal2c3 32767
+
+/* Gameboy Color palette 3 */
+#define foreCGBPal3c0 32344
+#define foreCGBPal3c1 32767
+#define foreCGBPal3c2 992
+#define foreCGBPal3c3 1023
+
+/* Gameboy Color palette 4 */
+#define foreCGBPal4c0 32344
+#define foreCGBPal4c1 32767
+#define foreCGBPal4c2 31744
+#define foreCGBPal4c3 31
+
+/* Gameboy Color palette 5 */
+#define foreCGBPal5c0 32344
+#define foreCGBPal5c1 31
+#define foreCGBPal5c2 0
+#define foreCGBPal5c3 31744
+
+/* Gameboy Color palette 6 */
+#define foreCGBPal6c0 32767
+#define foreCGBPal6c1 25368
+#define foreCGBPal6c2 19026
+#define foreCGBPal6c3 0
+
+/* Gameboy Color palette 7 */
+#define foreCGBPal7c0 32767
+#define foreCGBPal7c1 25368
+#define foreCGBPal7c2 19026
+#define foreCGBPal7c3 0
+/* CGBpalette entries. */
+extern const unsigned char foreCGB[];
+/* Start of tile array. */
+extern const unsigned char fore[];
+
+/* End of FORE.H */
diff --git a/gbdk/gbdk-lib/examples/gb/filltest/Makefile b/gbdk/gbdk-lib/examples/gb/filltest/Makefile
new file mode 100644
index 00000000..e2140aa3
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/filltest/Makefile
@@ -0,0 +1,17 @@
+CC = ../../../bin/lcc -Wa-l -Wl-m -Wl-j
+
+BINS = filltest.gb
+
+all: $(BINS)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+# Compile and link single file in one pass
+%.gb: %.c
+ $(CC) -o $@ $<
+
+clean:
+ rm -f *.o *.lst *.map *.gb *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi
+
diff --git a/gbdk/gbdk-lib/examples/gb/filltest/filltest.c b/gbdk/gbdk-lib/examples/gb/filltest/filltest.c
new file mode 100644
index 00000000..628a2c1f
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/filltest/filltest.c
@@ -0,0 +1,60 @@
+/* Sample Program to demonstrate the drawing functions in GBDK */
+/* Jon Fuge jonny@q-continuum.demon.co.uk */
+
+#include <gb/gb.h>
+#include <stdint.h>
+#include <gb/drawing.h>
+
+void linetest(uint8_t x, uint8_t y, uint8_t w) {
+ color(DKGREY,WHITE,SOLID);
+ for (int i = -w; i <= w; i++) line(x,y,x+i,y-w);
+ for (int i = -w; i <= w; i++) line(x,y,x+w,y+i);
+ for (int i = -w; i <= w; i++) line(x,y,x+i,y+w);
+ for (int i = -w; i <= w; i++) line(x,y,x-w,y+i);
+}
+
+void main(void)
+{
+ uint8_t a,b,c,d,e;
+ c=0;
+ /* Draw many characters on the screen with different fg and bg colours */
+ for (a=0; a<=15; a++) {
+ for (b=0; b<=15; b++) {
+ gotogxy(b,a);
+ d=a/4;
+ e=b/4;
+ if (d==e) {
+ d=3-e;
+ }
+ color(d,e,SOLID);
+ gprintf("%c",c++);
+ }
+ }
+
+ /* Draw two circles, a line, and two boxes in different drawing modes */
+ color(LTGREY,WHITE,SOLID);
+ circle(140,20,15,M_FILL);
+ color(BLACK,WHITE,SOLID);
+ circle(140,20,10,M_NOFILL);
+ color(DKGREY,WHITE,XOR);
+ circle(120,40,30,M_FILL);
+ line(0,0,159,143);
+ color(BLACK,LTGREY,SOLID);
+ box(0,130,40,143,M_NOFILL);
+ box(50,130,90,143,M_FILL);
+
+
+ linetest(130, 100, 20);
+
+ /* Scroll the screen using the hardest method imaginable :) */
+ for (c=0; c<=143; c++) {
+ for (b=0; b<=142; b++) {
+ for (a=0; a<=159; a++) {
+ color(getpix(a,b+1),WHITE,SOLID);
+ plot_point(a,b);
+ }
+ color(WHITE,WHITE,SOLID);
+ }
+ line(0,143,159,143);
+ }
+}
diff --git a/gbdk/gbdk-lib/examples/gb/galaxy/Makefile b/gbdk/gbdk-lib/examples/gb/galaxy/Makefile
new file mode 100644
index 00000000..7c20fda4
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/galaxy/Makefile
@@ -0,0 +1,17 @@
+CC = ../../../bin/lcc -Wa-l -Wl-m -Wl-j
+
+BINS = galaxy.gb
+
+all: $(BINS)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+# Compile and link single file in one pass
+%.gb: %.c
+ $(CC) -o $@ $<
+
+clean:
+ rm -f *.o *.lst *.map *.gb *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi
+
diff --git a/gbdk/gbdk-lib/examples/gb/galaxy/galaxy.c b/gbdk/gbdk-lib/examples/gb/galaxy/galaxy.c
new file mode 100644
index 00000000..80f45b79
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/galaxy/galaxy.c
@@ -0,0 +1,632 @@
+/*
+ * C version of the 'space' assembly demo.
+ *
+ * Little demo illustrating how to use the graphical possibilities
+ * of the GB (background, window and animated sprite)
+ * I have used fixed-point values for both the position and
+ * speed of objects to get smooth movements
+ *
+ * OBJ data : 0x8000 -> 0x8FFF (unsigned)
+ * Window data : 0x8800 -> 0x97FF (unsigned)
+ * Background data : 0x8800 -> 0x97FF (signed)
+ *
+ * Tiled 0xFC -> 0xFF are standard tiles (all black -> all white)
+ *
+ * Keys:
+ * Arrow keys : Change the speed (and direction) of the sprite
+ * Arrow keys + A : Change the speed (and direction) of the window
+ * Arrow keys + B : Change the speed (and direction) of the background
+ * START : Open/close the door
+ * SELECT : Basic fading effect
+ *
+ * Note that the window is kept in the lower right part of the screen
+ * since it can't be made transparent
+ */
+
+#include <gb/gb.h>
+#include <stdint.h>
+
+const unsigned char std_data[] = {
+
+ /* Basic tiles (0xFC to 0xFF) */
+ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+};
+
+const unsigned char earth_data[] = {
+
+ /* Tile 0x00 */
+ 0x07,0x07,0x18,0x1F,0x32,0x2D,0x71,0x4E,0x70,0x4F,0xF8,0x87,0xF8,0x87,0xF8,0x87,
+ 0xFC,0x83,0xFE,0x81,0x7F,0x40,0x7F,0x40,0x3F,0x20,0x1F,0x18,0x07,0x07,0x00,0x00,
+ 0xC0,0xC0,0xF0,0x30,0x78,0x88,0x3C,0xC4,0x5C,0xA4,0x9E,0x62,0x3E,0xC2,0x3E,0xC2,
+ 0x5E,0xA2,0x7E,0x82,0x0C,0xF4,0x0C,0xF4,0x98,0x68,0xB0,0x70,0xC0,0xC0,0x00,0x00,
+ 0x07,0x07,0x1F,0x18,0x2F,0x30,0x4F,0x70,0x6F,0x50,0x9F,0xE0,0x9F,0xE0,0xBF,0xC0,
+ 0xFF,0x80,0xB7,0xC8,0x63,0x5C,0x43,0x7C,0x3F,0x20,0x1F,0x18,0x07,0x07,0x00,0x00,
+ 0xC0,0xC0,0xB0,0x70,0x18,0xE8,0x0C,0xF4,0x0C,0xF4,0x82,0x7E,0x82,0x7E,0x86,0x7A,
+ 0xC6,0x3A,0xE6,0x1A,0xF4,0x0C,0xFC,0x04,0xF8,0x08,0xF0,0x30,0xC0,0xC0,0x00,0x00,
+
+ /* Tile 0x08 */
+ 0x07,0x07,0x1E,0x19,0x20,0x3F,0x40,0x7F,0x42,0x7D,0x81,0xFE,0x81,0xFE,0x83,0xFC,
+ 0xD7,0xA8,0xBB,0xC4,0x6E,0x51,0x7C,0x43,0x3F,0x20,0x1F,0x18,0x07,0x07,0x00,0x00,
+ 0xC0,0xC0,0x70,0xB0,0xE8,0x18,0xF4,0x0C,0xF4,0x0C,0xFE,0x02,0xFE,0x02,0xFE,0x02,
+ 0xFE,0x02,0x7E,0x82,0x3C,0xC4,0x3C,0xC4,0xF8,0x08,0xF0,0x30,0xC0,0xC0,0x00,0x00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0x1C,0x1D,0xFC,0xFC,0x1E,0x1F,0x20,
+ 0x21,0x22,0xFC,0x23,0x24,0x25,0xFC,0x26,
+ 0x27,0x13,0x28,0x29,0x2A,0x2B,0x2C,0x11
+};
+
+/*
+ * Image size: 0x10 x 0x70
+ * Number of tiles (total - unique): 0x1C - 0x1C
+ */
+
+const unsigned char earth_tiles[] = {
+ 0x00,0x02,
+ 0x04,0x06,
+ 0x08,0x0A,
+ 0x0C,0x0E,
+ 0x10,0x12,
+ 0x14,0x16,
+ 0x18,0x1A
+};
+
+/*
+ * Image size: 0x80 x 0x50
+ * Number of tiles (total - unique): 0xA0 - 0x15
+ */
+
+const unsigned char frame_tiles[] = {
+ 0x80,0x81,0xFD,0x82,0x83,0x81,0xFD,0x82,0x83,0x81,0xFD,0x82,0x83,0x81,0xFD,0x84,
+ 0x85,0x86,0x87,0x88,0x89,0x8A,0x87,0x88,0x89,0x8A,0x87,0x88,0x89,0x8A,0x8B,0x8C,
+ 0xFD,0x8D,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x8E,0x8F,
+ 0x82,0x8C,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x85,0x90,
+ 0x8E,0x8F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFD,0x8D,
+ 0x85,0x90,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x82,0x8C,
+ 0xFD,0x8D,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x8E,0x8F,
+ 0x82,0x8C,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x85,0x90,
+ 0x8E,0x91,0xFD,0x82,0x83,0x81,0xFD,0x82,0x83,0x81,0xFD,0x82,0x83,0x81,0x92,0x8D,
+ 0x93,0x8A,0x87,0x88,0x89,0x8A,0x87,0x88,0x89,0x8A,0x87,0x88,0x89,0x8A,0x87,0x94
+};
+
+/*
+ * Image size: 0x60 x 0x30
+ * Number of tiles (total - unique): 0x48 - 0x03
+ */
+
+const unsigned char door1_tiles[] = {
+ 0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,
+ 0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,
+ 0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,
+ 0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,
+ 0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,
+ 0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,
+
+ 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,
+ 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,
+ 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,
+ 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,
+ 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,
+ 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC
+};
+
+/*
+ * Image size: 0x60 x 0x30
+ * Number of tiles (total - unique): 0x48 - 0x04
+ */
+
+const unsigned char door2_tiles[] = {
+ 0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98,
+ 0x99,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0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC
+};
+
+/* Should really be const, but sdcc doesnt yet support it. */
+const unsigned char * const film[] = {
+ &door1_tiles[0x0C*0],
+ &door2_tiles[0x0C*0],
+ &door3_tiles[0x0C*0],
+ &door4_tiles[0x0C*0],
+ &door1_tiles[0x0C*1],
+ &door2_tiles[0x0C*1],
+ &door3_tiles[0x0C*1],
+ &door4_tiles[0x0C*1],
+ &door1_tiles[0x0C*2],
+ &door2_tiles[0x0C*2],
+ &door3_tiles[0x0C*2],
+ &door4_tiles[0x0C*2],
+ &door1_tiles[0x0C*3],
+ &door2_tiles[0x0C*3],
+ &door3_tiles[0x0C*3],
+ &door4_tiles[0x0C*3],
+ &door1_tiles[0x0C*4],
+ &door2_tiles[0x0C*4],
+ &door3_tiles[0x0C*4],
+ &door4_tiles[0x0C*4],
+ &door1_tiles[0x0C*5],
+ &door2_tiles[0x0C*5],
+ &door3_tiles[0x0C*5],
+ &door4_tiles[0x0C*5],
+ &door1_tiles[0x0C*6]
+};
+
+#define NBDFRAMES 0x18 /* Nb frames for the door */
+#define NBSFRAMES 0x07 /* Nb frames for the sprite */
+#define WINSZX 0x80 /* Size of the picture in the window */
+#define WINSZY 0x50
+#define MINWINX (MAXWNDPOSX-WINSZX+1) /* Bounds of the window origin */
+#define MINWINY (MAXWNDPOSY-WINSZY+1)
+#define MAXWINX MAXWNDPOSX
+#define MAXWINY MAXWNDPOSY
+#define FADESTEP 0x10 /* Nb steps for the fading effect */
+#define STARTFADE (0x06*FADESTEP) /* Initial value for the fading effect */
+
+#define CLOSED 0x00
+#define OPENING 0x01
+#define OPENED 0x02
+#define CLOSING 0x03
+
+static uint8_t time = 0; /* Global "time" value (counter) */
+uint8_t doorstate = 0; /* State of the door (OPENED, CLOSED...) */
+uint8_t doorpos = 0; /* Current position in the door animation */
+static uint8_t color = 0; /* Current color for fading effect */
+uint8_t sframe = 0; /* Current frame of the sprite */
+fixed bposx, bposy; /* Background position (fixed point) */
+fixed bspx, bspy; /* Background speed (fixed point) */
+fixed wposx, wposy; /* Window position (fixed point) */
+fixed wspx, wspy; /* Window speed (fixed point) */
+fixed sposx, sposy; /* Sprite position (fixed point) */
+fixed sspx, sspy; /* Sprite speed (fixed point) */
+
+void fade();
+void scroll();
+void door();
+void animate_sprite();
+void tile_sprite();
+void place_sprite();
+
+/* Fade the screen (off and on) */
+void fade()
+{
+ if(color == 0)
+ return;
+ switch(color)
+ {
+ case STARTFADE:
+ case STARTFADE-4*FADESTEP:
+ BGP_REG = 0xF9U;
+ break;
+ case STARTFADE-FADESTEP:
+ case STARTFADE-3*FADESTEP:
+ BGP_REG = 0xFEU;
+ break;
+ case STARTFADE-2*FADESTEP:
+ BGP_REG = 0xFFU;
+ break;
+ case STARTFADE-5*FADESTEP:
+ BGP_REG = 0xE4U;
+ break;
+ }
+ color--;
+}
+
+/* Scroll the background, the window and the sprite */
+void scroll()
+{
+ /* Update background */
+ bposx.w += bspx.w;
+ bposy.w += bspy.w;
+ SCX_REG = bposx.b.h;
+ SCY_REG = bposy.b.h;
+
+ /* Update window */
+ wposx.w += wspx.w ;
+ wposy.w += wspy.w ;
+ /* X position */
+ if(wposx.b.h >= MAXWINX) {
+ wposx.b.h = MAXWINX;
+ /* Invert speed */
+ wspx.w = -(int16_t)wspx.w;
+ } else if(wposx.b.h <= MINWINX) {
+ wposx.b.h = MINWINX;
+ /* Invert speed */
+ wspx.w = -(int16_t)wspx.w;
+ }
+ WX_REG = wposx.b.h;
+ /* Y position */
+ if(wposy.b.h >= MAXWINY) {
+ wposy.b.h = MAXWINY;
+ /* Invert speed */
+ wspy.w = -(int16_t)wspy.w;
+ } else if(wposy.b.h <= MINWINY) {
+ wposy.b.h = MINWINY;
+ /* Invert speed */
+ wspy.w = -(int16_t)wspy.w;
+ }
+ WY_REG = wposy.b.h;
+
+ /* Update sprite */
+ sposx.w += sspx.w;
+ sposy.w += sspy.w;
+ place_sprite();
+}
+
+/* Open and close the door */
+void door()
+{
+ if(doorstate == OPENING) {
+ doorpos++;
+ /* Draw the door in the window */
+ set_win_tiles(2, 2, 12, 6, (unsigned char*)film[doorpos]);
+ if(doorpos == NBDFRAMES)
+ doorstate = OPENED;
+ } else if(doorstate == CLOSING) {
+ doorpos--;
+ /* Draw the door in the window */
+ set_win_tiles(2, 2, 12, 6, (unsigned char*)film[doorpos]);
+ if(doorpos == 0)
+ doorstate = CLOSED;
+ }
+}
+
+/* Animate sprite */
+void animate_sprite()
+{
+ if((time&0x07) == 0) {
+ sframe++;
+ if(sframe == NBSFRAMES)
+ sframe = 0;
+ tile_sprite();
+ }
+}
+
+/* Set sprite tiles */
+void tile_sprite()
+{
+ uint8_t s;
+
+ s = sframe<<1;
+ set_sprite_tile(0, earth_tiles[s]);
+ set_sprite_tile(1, earth_tiles[s+1]);
+}
+
+/* Place sprite */
+void place_sprite()
+{
+ move_sprite(0, sposx.b.h, sposy.b.h);
+ move_sprite(1, sposx.b.h+8, sposy.b.h);
+}
+
+void main()
+{
+ uint8_t i, j;
+
+ disable_interrupts();
+ DISPLAY_OFF;
+ LCDC_REG = LCDCF_OFF | LCDCF_WIN9C00 | LCDCF_WINON | LCDCF_BG8800 | LCDCF_BG9800 | LCDCF_OBJ16 | LCDCF_OBJON | LCDCF_BGON;
+ /*
+ * LCD = Off
+ * WindowBank = 0x9C00
+ * Window = On
+ * BG Chr = 0x8800
+ * BG Bank = 0x9800
+ * OBJ = 8x16
+ * OBJ = On
+ * BG = On
+ */
+
+ doorstate = CLOSED;
+
+ /* Set palettes */
+ BGP_REG = OBP0_REG = OBP1_REG = 0xE4U;
+
+ /* Initialize the background */
+ set_bkg_data(0xFC, 0x04, std_data);
+ set_bkg_data(0x00, 0x2D, bkg_data);
+ /*
+ * Draw the background
+ *
+ * Width = 0x100 = 0x20 * 8
+ * Height = 0x100 = 0x20 * 8
+ */
+ for(i = 0; i < 32; i+=8)
+ for(j = 0; j < 32; j+=8)
+ set_bkg_tiles(i, j, 8, 8, bkg_tiles);
+ bposx.w = 0;
+ SCX_REG = 0;
+ bposy.w = 0;
+ SCY_REG = 0;
+ bspx.w = 0xFF00;
+ bspy.w = 0x0080;
+
+ /* Initialize the window */
+ set_win_data(0x80, 0x21, frame_data);
+ /*
+ * Draw the frame in the window
+ *
+ * Width = 0x80 = 0x10 * 8
+ * Height = 0x50 = 0x0A * 8
+ */
+ set_win_tiles(0, 0, 16, 10, frame_tiles);
+ /*
+ * Draw the door in the window
+ *
+ * Width = 0x60 = 0x20 * 12
+ * Height = 0x30 = 0x20 * 6
+ */
+ set_win_tiles(2, 2, 12, 6, door1_tiles);
+ wposx.b.h = MAXWNDPOSX;
+ wposx.b.l = 0;
+ WX_REG = MAXWNDPOSX;
+ wposy.b.h = MAXWNDPOSY;
+ wposy.b.l = 0;
+ WY_REG = MAXWNDPOSY;
+ wspx.w = 0xFF80;
+ wspy.w = 0xFFC0;
+
+ /* Initialize the sprite */
+ set_sprite_data(0x00, 0x1C, earth_data);
+ set_sprite_prop(0, 0x00);
+ set_sprite_prop(1, 0x00);
+ sframe = 0;
+ sposx.w = 0x1000;
+ sposy.w = 0x1000;
+ sspx.w = 0x0040;
+ sspy.w = 0x0040;
+ tile_sprite();
+ place_sprite();
+
+ DISPLAY_ON;
+ enable_interrupts();
+
+ while(1) {
+ /* Skip four VBLs (slow down animation) */
+ for(i = 0; i < 4; i++)
+ wait_vbl_done();
+ time++;
+ fade();
+ door();
+ scroll();
+ animate_sprite();
+ i = joypad();
+ if(i & J_B) {
+ if(i & J_UP)
+ bspy.w -= 0x0010;
+ if(i & J_DOWN)
+ bspy.w += 0x0010;
+ if(i & J_LEFT)
+ bspx.w -= 0x0010;
+ if(i & J_RIGHT)
+ bspx.w += 0x0010;
+ } else if(i & J_A) {
+ if(i & J_UP)
+ wspy.w -= 0x0010;
+ if(i & J_DOWN)
+ wspy.w += 0x0010;
+ if(i & J_LEFT)
+ wspx.w -= 0x0010;
+ if(i & J_RIGHT)
+ wspx.w += 0x0010;
+ } else {
+ if(i & J_SELECT)
+ color = STARTFADE;
+ if(i & J_START)
+ if(doorstate == CLOSED) {
+ doorstate = OPENING;
+ doorpos = 0;
+ } else if(doorstate == OPENED) {
+ doorstate = CLOSING;
+ doorpos = NBDFRAMES;
+ }
+ if(i & J_UP)
+ sspy.w -= 0x0010;
+ if(i & J_DOWN)
+ sspy.w += 0x0010;
+ if(i & J_LEFT)
+ sspx.w -= 0x0010;
+ if(i & J_RIGHT)
+ sspx.w += 0x0010;
+ }
+ }
+}
diff --git a/gbdk/gbdk-lib/examples/gb/gb-dtmf/Makefile b/gbdk/gbdk-lib/examples/gb/gb-dtmf/Makefile
new file mode 100644
index 00000000..c8036d18
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/gb-dtmf/Makefile
@@ -0,0 +1,24 @@
+CC = ../../../bin/lcc -Wa-l -Wl-m
+
+BINS = gb-dtmf.gb
+
+all: $(BINS)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+%.s: %.c
+ $(CC) -S -o $@ $<
+
+%.o: %.c
+ $(CC) -c -o $@ $<
+
+%.o: %.s
+ $(CC) -c -o $@ $<
+
+%.gb: %.o
+ $(CC) -o $@ $<
+
+clean:
+ rm -f *.o *.lst *.map *.gb *.ihx *.sym *.cdb *.adb *.asm
diff --git a/gbdk/gbdk-lib/examples/gb/gb-dtmf/brk_btn.c b/gbdk/gbdk-lib/examples/gb/gb-dtmf/brk_btn.c
new file mode 100644
index 00000000..186e4ba6
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/gb-dtmf/brk_btn.c
@@ -0,0 +1,41 @@
+/*
+
+ BREAK_BTN.C
+
+ Tile Source File.
+
+ Info:
+ Form : All tiles as one unit.
+ Format : Gameboy 4 color.
+ Counter : None.
+ Tile size : 8 x 8
+ Tiles : 0 to 8
+
+ This file was generated by GBTD v0.5
+
+*/
+
+/* Start of tile array. */
+const unsigned char break_btn[] =
+{
+ 0x00,0x00,0x00,0x00,0x3F,0x00,0x3F,0x00,
+ 0x3F,0x00,0x3F,0x00,0x3F,0x00,0x3F,0x00,
+ 0x00,0x00,0x00,0x00,0xFF,0x00,0xFF,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0x00,0x01,0x00,0x03,0xFC,0x03,0xFC,0x03,
+ 0xFC,0x03,0xFC,0x03,0xFC,0x03,0xFC,0x03,
+ 0x3F,0x00,0x3F,0x00,0x3F,0x00,0x3F,0x00,
+ 0x3F,0x00,0x3F,0x00,0x3F,0x00,0x3F,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0xFC,0x03,0xFC,0x03,0xFC,0x03,0xFC,0x03,
+ 0xFC,0x03,0xFC,0x03,0xFC,0x03,0xFC,0x03,
+ 0x3F,0x00,0x3F,0x00,0x3F,0x00,0x3F,0x00,
+ 0x3F,0x00,0x3F,0x00,0x00,0x3F,0x00,0x7F,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0xFF,0x00,0xFF,0x00,0x00,0xFF,0x00,0xFF,
+ 0xFC,0x03,0xFC,0x03,0xFC,0x03,0xFC,0x03,
+ 0xFC,0x03,0xFC,0x03,0x00,0xFF,0x00,0xFF
+};
+
+/* End of BREAK_BTN.C */
diff --git a/gbdk/gbdk-lib/examples/gb/gb-dtmf/brk_btn.gbr b/gbdk/gbdk-lib/examples/gb/gb-dtmf/brk_btn.gbr
new file mode 100644
index 00000000..985131c2
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/gb-dtmf/brk_btn.gbr
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/gb/gb-dtmf/cursor.c b/gbdk/gbdk-lib/examples/gb/gb-dtmf/cursor.c
new file mode 100644
index 00000000..e6151222
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/gb-dtmf/cursor.c
@@ -0,0 +1,39 @@
+/*
+
+ CURSOR.C
+
+ Tile Source File.
+
+ Info:
+ Form : All tiles as one unit.
+ Format : Gameboy 4 color.
+ Counter : None.
+ Tile size : 16 x 16
+ Tiles : 0 to 1
+
+ This file was generated by GBTD v0.5
+
+*/
+
+/* Start of tile array. */
+const unsigned char cursor_data[] =
+{
+ 0x06,0x06,0x09,0x09,0x09,0x09,0x09,0x0F,
+ 0x09,0x0F,0x69,0x6F,0x19,0x3F,0x59,0x7F,
+ 0x49,0x7F,0x49,0x7F,0x40,0x7F,0x40,0x7F,
+ 0x20,0x3F,0x10,0x1F,0x08,0x0F,0x0F,0x0F,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xA8,0xA8,0x54,0xFC,
+ 0x54,0xFC,0x54,0xFC,0x04,0xFC,0x04,0xFC,
+ 0x08,0xF8,0x10,0xF0,0x20,0xE0,0xE0,0xE0,
+ 0x00,0x00,0x06,0x06,0x09,0x09,0x09,0x0F,
+ 0x09,0x0F,0x69,0x6F,0x19,0x3F,0x59,0x7F,
+ 0x49,0x7F,0x49,0x7F,0x40,0x7F,0x40,0x7F,
+ 0x20,0x3F,0x10,0x1F,0x08,0x0F,0x0F,0x0F,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xA8,0xA8,0x54,0xFC,
+ 0x54,0xFC,0x54,0xFC,0x04,0xFC,0x04,0xFC,
+ 0x08,0xF8,0x10,0xF0,0x20,0xE0,0xE0,0xE0
+};
+
+/* End of CURSOR.C */
diff --git a/gbdk/gbdk-lib/examples/gb/gb-dtmf/cursor.gbr b/gbdk/gbdk-lib/examples/gb/gb-dtmf/cursor.gbr
new file mode 100644
index 00000000..9baa76a8
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/gb-dtmf/cursor.gbr
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/gb/gb-dtmf/dtmf_lcd.c b/gbdk/gbdk-lib/examples/gb/gb-dtmf/dtmf_lcd.c
new file mode 100644
index 00000000..c16aa07f
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/gb-dtmf/dtmf_lcd.c
@@ -0,0 +1,123 @@
+/*
+
+ DTMF_LCD.C
+
+ Tile Source File.
+
+ Info:
+ Form : All tiles as one unit.
+ Format : Gameboy 4 color.
+ Counter : None.
+ Tile size : 8 x 16
+ Tiles : 0 to 24
+
+ This file was generated by GBTD v0.5
+
+*/
+
+/* Start of tile array. */
+const unsigned char dtmf_lcd[] =
+{
+ 0x3E,0x3E,0x7F,0x7F,0x63,0x63,0x63,0x63,
+ 0x63,0x63,0x63,0x63,0x63,0x63,0x00,0x00,
+ 0x00,0x00,0x63,0x63,0x63,0x63,0x63,0x63,
+ 0x63,0x63,0x63,0x63,0x7F,0x7F,0x3E,0x3E,
+ 0x3E,0x02,0x7F,0x03,0x63,0x03,0x63,0x03,
+ 0x63,0x03,0x63,0x03,0x63,0x03,0x3C,0x00,
+ 0x3C,0x00,0x63,0x03,0x63,0x03,0x63,0x03,
+ 0x63,0x03,0x63,0x03,0x7F,0x03,0x3E,0x02,
+ 0x3E,0x3E,0x7F,0x7F,0x63,0x03,0x63,0x03,
+ 0x63,0x03,0x63,0x03,0x63,0x03,0x3E,0x3E,
+ 0x3E,0x3E,0x63,0x60,0x63,0x60,0x63,0x60,
+ 0x63,0x60,0x63,0x60,0x7F,0x7F,0x3E,0x3E,
+ 0x3E,0x3E,0x7F,0x7F,0x63,0x03,0x63,0x03,
+ 0x63,0x03,0x63,0x03,0x63,0x03,0x3E,0x3E,
+ 0x3E,0x3E,0x63,0x03,0x63,0x03,0x63,0x03,
+ 0x63,0x03,0x63,0x03,0x7F,0x7F,0x3E,0x3E,
+ 0x3E,0x22,0x7F,0x63,0x63,0x63,0x63,0x63,
+ 0x63,0x63,0x63,0x63,0x63,0x63,0x3E,0x3E,
+ 0x3E,0x3E,0x63,0x03,0x63,0x03,0x63,0x03,
+ 0x63,0x03,0x63,0x03,0x7F,0x03,0x3E,0x02,
+ 0x3E,0x3E,0x7F,0x7F,0x63,0x60,0x63,0x60,
+ 0x63,0x60,0x63,0x60,0x63,0x60,0x3E,0x3E,
+ 0x3E,0x3E,0x63,0x03,0x63,0x03,0x63,0x03,
+ 0x63,0x03,0x63,0x03,0x7F,0x7F,0x3E,0x3E,
+ 0x3E,0x3E,0x7F,0x7F,0x63,0x60,0x63,0x60,
+ 0x63,0x60,0x63,0x60,0x63,0x60,0x3E,0x3E,
+ 0x3E,0x3E,0x63,0x63,0x63,0x63,0x63,0x63,
+ 0x63,0x63,0x63,0x63,0x7F,0x7F,0x3E,0x3E,
+ 0x3E,0x3E,0x7F,0x7F,0x63,0x03,0x63,0x03,
+ 0x63,0x03,0x63,0x03,0x63,0x03,0x3E,0x00,
+ 0x3E,0x00,0x63,0x03,0x63,0x03,0x63,0x03,
+ 0x63,0x03,0x63,0x03,0x7F,0x03,0x3E,0x02,
+ 0x3E,0x3E,0x7F,0x7F,0x63,0x63,0x63,0x63,
+ 0x63,0x63,0x63,0x63,0x63,0x63,0x3E,0x3E,
+ 0x3E,0x3E,0x63,0x63,0x63,0x63,0x63,0x63,
+ 0x63,0x63,0x63,0x63,0x7F,0x7F,0x3E,0x3E,
+ 0x3E,0x3E,0x7F,0x7F,0x63,0x63,0x63,0x63,
+ 0x63,0x63,0x63,0x63,0x63,0x63,0x3E,0x3E,
+ 0x3E,0x3E,0x63,0x03,0x63,0x03,0x63,0x03,
+ 0x63,0x03,0x63,0x03,0x7F,0x7F,0x3E,0x3E,
+ 0x3E,0x3E,0x7F,0x7F,0x63,0x63,0x63,0x63,
+ 0x63,0x63,0x63,0x63,0x63,0x63,0x3E,0x3E,
+ 0x3E,0x3E,0x63,0x63,0x63,0x63,0x63,0x63,
+ 0x63,0x63,0x63,0x63,0x7F,0x63,0x3E,0x00,
+ 0x3E,0x20,0x7F,0x60,0x63,0x60,0x63,0x60,
+ 0x63,0x60,0x63,0x60,0x63,0x60,0x3E,0x3E,
+ 0x3E,0x3E,0x63,0x63,0x63,0x63,0x63,0x63,
+ 0x63,0x63,0x63,0x63,0x7F,0x7F,0x3E,0x3E,
+ 0x3E,0x3E,0x7F,0x7F,0x63,0x60,0x63,0x60,
+ 0x63,0x60,0x63,0x60,0x63,0x60,0x3E,0x20,
+ 0x3E,0x20,0x63,0x60,0x63,0x60,0x63,0x60,
+ 0x63,0x60,0x63,0x60,0x7F,0x7F,0x3E,0x3E,
+ 0x3E,0x02,0x7F,0x03,0x63,0x03,0x63,0x03,
+ 0x63,0x03,0x63,0x03,0x63,0x03,0x3E,0x3E,
+ 0x3E,0x3E,0x63,0x63,0x63,0x63,0x63,0x63,
+ 0x63,0x63,0x63,0x63,0x7F,0x7F,0x3E,0x3E,
+ 0x00,0x00,0x36,0x36,0x36,0x36,0x36,0x36,
+ 0x36,0x36,0x7F,0x7F,0x7F,0x7F,0x36,0x36,
+ 0x36,0x36,0x7F,0x7F,0x7F,0x7F,0x36,0x36,
+ 0x36,0x36,0x36,0x36,0x36,0x36,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x2A,0x2A,0x6B,0x6B,
+ 0x6B,0x6B,0x6B,0x6B,0x3E,0x3E,0x1C,0x1C,
+ 0x3E,0x3E,0x6B,0x6B,0x6B,0x6B,0x6B,0x6B,
+ 0x2A,0x2A,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x3E,0x00,0x7F,0x00,0x63,0x00,0x63,0x00,
+ 0x63,0x00,0x63,0x00,0x63,0x00,0x3E,0x00,
+ 0x3E,0x00,0x63,0x00,0x63,0x00,0x63,0x00,
+ 0x63,0x00,0x63,0x00,0x7F,0x00,0x3E,0x00,
+ 0x3E,0x22,0x7F,0x63,0x63,0x63,0x63,0x63,
+ 0x63,0x63,0x63,0x63,0x63,0x63,0x3E,0x3E,
+ 0x3E,0x3E,0x63,0x03,0x63,0x03,0x63,0x03,
+ 0x63,0x03,0x63,0x03,0x7F,0x7F,0x3E,0x3E,
+ 0x3E,0x22,0x7F,0x63,0x77,0x77,0x77,0x77,
+ 0x77,0x77,0x77,0x77,0x6B,0x6B,0x2A,0x2A,
+ 0x2A,0x2A,0x6B,0x6B,0x63,0x63,0x63,0x63,
+ 0x63,0x63,0x63,0x63,0x7F,0x63,0x3E,0x22,
+ 0x3E,0x22,0x7F,0x63,0x63,0x63,0x63,0x63,
+ 0x63,0x63,0x63,0x63,0x63,0x63,0x3E,0x22,
+ 0x3E,0x22,0x63,0x63,0x63,0x63,0x63,0x63,
+ 0x63,0x63,0x63,0x63,0x7F,0x7F,0x3E,0x3E,
+ 0x3E,0x3E,0x7F,0x7F,0x63,0x60,0x63,0x60,
+ 0x63,0x60,0x63,0x60,0x63,0x60,0x3F,0x27,
+ 0x3F,0x27,0x63,0x63,0x63,0x63,0x63,0x63,
+ 0x63,0x63,0x63,0x63,0x7F,0x7F,0x3E,0x3E,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x3E,
+ 0x3E,0x3E,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x67,0x67,0x67,0x67,0x18,0x18,0x18,0x18,
+ 0x18,0x18,0x18,0x18,0x18,0x18,0x00,0x00,
+ 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
+ 0x18,0x18,0x18,0x18,0x18,0x18,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x0C,0x0C,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,
+ 0x0C,0x0C,0x04,0x04,0x08,0x08,0x00,0x00,
+ 0x3E,0x3E,0x7E,0x7E,0x63,0x60,0x63,0x60,
+ 0x63,0x60,0x63,0x60,0x63,0x60,0x3E,0x3E,
+ 0x3E,0x3E,0x63,0x60,0x63,0x60,0x63,0x60,
+ 0x63,0x60,0x63,0x60,0x7F,0x60,0x3E,0x20
+};
+
+/* End of DTMF_LCD.C */
diff --git a/gbdk/gbdk-lib/examples/gb/gb-dtmf/dtmf_lcd.gbr b/gbdk/gbdk-lib/examples/gb/gb-dtmf/dtmf_lcd.gbr
new file mode 100644
index 00000000..737a8040
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/gb-dtmf/dtmf_lcd.gbr
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/gb/gb-dtmf/frm_lcd.c b/gbdk/gbdk-lib/examples/gb/gb-dtmf/frm_lcd.c
new file mode 100644
index 00000000..4d82262e
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/gb-dtmf/frm_lcd.c
@@ -0,0 +1,41 @@
+/*
+
+ FRAME_LCD.C
+
+ Tile Source File.
+
+ Info:
+ Form : All tiles as one unit.
+ Format : Gameboy 4 color.
+ Counter : None.
+ Tile size : 8 x 8
+ Tiles : 0 to 8
+
+ This file was generated by GBTD v0.5
+
+*/
+
+/* Start of tile array. */
+const unsigned char frame_lcd[] =
+{
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,
+ 0x00,0x1F,0x00,0x18,0x00,0x18,0x00,0x18,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,
+ 0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,
+ 0x00,0xF8,0x00,0x18,0x00,0x18,0x00,0x18,
+ 0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,
+ 0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,
+ 0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,
+ 0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x1F,
+ 0x00,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,
+ 0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x18,0x00,0x18,0x00,0x18,0x00,0xF8,
+ 0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00
+};
+
+/* End of FRAME_LCD.C */
diff --git a/gbdk/gbdk-lib/examples/gb/gb-dtmf/frm_lcd.gbr b/gbdk/gbdk-lib/examples/gb/gb-dtmf/frm_lcd.gbr
new file mode 100644
index 00000000..f89a22e7
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/gb-dtmf/frm_lcd.gbr
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/gb/gb-dtmf/gb-dtmf.c b/gbdk/gbdk-lib/examples/gb/gb-dtmf/gb-dtmf.c
new file mode 100644
index 00000000..0bb92cb9
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/gb-dtmf/gb-dtmf.c
@@ -0,0 +1,715 @@
+/* ---------------------------------------- */
+/* GB-DTMF Ver1.0 */
+/* by */
+/* Osamu Ohashi */
+/* ---------------------------------------- */
+
+#include <gb/gb.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+
+/* BG data */
+#include "frm_lcd.c" /* Back ground pattern */
+#include "brk_btn.c" /* button image when broken */
+#include "prs_btn.c" /* button image when pressed */
+
+#include "dtmf_lcd.c" /* LCD characters */
+
+/* Sprite data */
+#include "key_num.c" /* Sprite pattern for each key pad */
+#include "cursor.c" /* cursor pattern */
+
+/*
+ usage of BG data
+ file name number of BG type of matrix aount
+ -------------------------------------------------
+ frame_lcd.c 9 8 x 8 9
+ break_btn.c 9 8 x 8 9
+ press_btn.c 9 8 x 8 9
+ dtmf_lcd.c 25 8 x 16 50
+ ------------------------------------------------
+ total 77
+
+
+ usage of OBJ data
+ file name number of obj type of matrix amount
+ --------------------------------------------------
+ key_num.c 23 8 x 8 23
+ cursor.c 2 16 x 16 8
+ --------------------------------------------------
+ total 31
+*/
+
+
+/* display */
+#define TITLE " GB-DTMF BY 05AMU "
+
+#define OFFSET 27U
+#define KEY_STEP 24U /* Key matrix size as 24 x 24 */
+#define START_CURSOR_X 24U /* CURSOR position */
+#define START_CURSOR_Y 72U
+
+#define LCD_X 1U /* start position of X */
+#define LCD_Y 2U /* start position of Y */
+#define LCD_WIDTH 18U /* Horizontal size of LCD */
+#define LCD_HIGHT 2U /* Vertical Size of LCD */
+
+
+#define ON 1
+#define OFF 0
+
+/* DTMF */
+#define DTMF_ON 100UL /* Tone on time */
+#define DTMF_OFF 100UL /* Tone off time */
+
+#define MAX_DTMF 30 /* Maximum length of DTMF strings */
+
+/*
+ Frequency setting
+*/
+/*
+ We have to calculate the frequency as following formula
+
+ DTMF has two set frequency, we have to decide Row & Column
+ with each digit('0','1','2'...)
+*/
+
+#define C1 0x94U /* 1209Hz, 1213Hz */
+#define C2 0x9EU /* 1336Hz, 1337Hz */
+#define C3 0xA7U /* 1477Hz, 1472Hz */
+#define C4 0xB0U /* 1633Hz, 1638Hz */
+
+#define R1 0x44U /* 697Hz, 697Hz */
+#define R2 0x56U /* 770Hz, 770Hz */
+#define R3 0x66U /* 852Hz, 851Hz */
+#define R4 0x75U /* 941Hz, 942Hz */
+
+const unsigned char row[4] = {R1,R2,R3,R4}; /* DTMF frequency strage of Row */
+const unsigned char col[4] = {C1,C2,C3,C4}; /* DTMF frequency strage of Col */
+
+/* It is possible to set up initial screen by each BG data. */
+const unsigned char dtmf_tile[] = {
+ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
+
+ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2,
+ 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5,
+ 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5,
+ 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8,
+
+ 4, 9,10,11, 9,10,11, 9,10,11, 9,10,11, 4, 9,10,11, 9,10,11,
+ 4,12,13,14,12,13,14,12,13,14,12,13,14, 4,12,13,14,12,13,14,
+ 4,15,16,17,15,16,17,15,16,17,15,16,17, 4,15,16,17,15,16,17,
+
+ 4, 9,10,11, 9,10,11, 9,10,11, 9,10,11, 4, 9,10,11, 9,10,11,
+ 4,12,13,14,12,13,14,12,13,14,12,13,14, 4,12,13,14,12,13,14,
+ 4,15,16,17,15,16,17,15,16,17,15,16,17, 4,15,16,17,15,16,17,
+
+ 4, 9,10,11, 9,10,11, 9,10,11, 9,10,11, 4, 9,10,11, 9,10,11,
+ 4,12,13,14,12,13,14,12,13,14,12,13,14, 4,12,13,14,12,13,14,
+ 4,15,16,17,15,16,17,15,16,17,15,16,17, 4,15,16,17,15,16,17,
+
+ 4, 9,10,11, 9,10,11, 9,10,11, 9,10,11, 4, 9,10,10,10,10,11,
+ 4,12,13,14,12,13,14,12,13,14,12,13,14, 4,12,13,13,13,13,14,
+ 4,15,16,17,15,16,17,15,16,17,15,16,17, 4,15,16,16,16,16,17,
+
+ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4
+};
+
+/*
+ Button image
+ Normal buttons are created by 3tiles x 3tiles(24pixels x 24pixels)
+ Dialing button is created by 6tiles x 3tiles(48pixels x 24pixels)
+*/
+const unsigned char break_tile[] = {
+ 9,10,11,
+ 12,13,14,
+ 15,16,17
+};
+
+const unsigned char dialing_break[] = {
+ 9,10,10,10,10,11,
+ 12,13,13,13,13,14,
+ 15,16,16,16,16,17
+};
+
+const unsigned char press_tile[] = {
+ 18,19,20,
+ 21,22,23,
+ 24,25,26
+};
+
+
+const unsigned char dialing_press[] = {
+ 18,19,19,19,19,20,
+ 21,22,22,22,22,23,
+ 24,25,25,25,25,26
+};
+
+/*
+ LCD image at initial & AC
+*/
+const unsigned char init_disp[] = {
+ 59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,
+ 60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60
+};
+
+const char pad[4][6] = { /* DTMF Pad assign */
+ {'1','2','3','A','%','P'},
+ {'4','5','6','B','-','F'},
+ {'7','8','9','C',',','?'},
+ {'*','0','#','D','s','s'}
+};
+
+unsigned char disp_tile[MAX_DTMF * 2];
+
+/*
+ Initialize for sound registers
+ ch1, ch2 are used for this routine.
+*/
+void init_dial()
+{
+
+ NR52_REG = 0x83U;
+ NR51_REG = 0x00U;
+ NR50_REG = 0x77U;
+
+ NR24_REG = 0x87U;
+ NR22_REG = 0xffU;
+ NR21_REG = 0xbfU;
+
+ NR14_REG = 0x87U;
+ NR12_REG = 0xffU;
+ NR11_REG = 0xbfU;
+ NR10_REG = 0x04U;
+}
+
+/* sound engine for DTMF */
+void dialtone(uint16_t dtmf_on, uint16_t dtmf_off, char str[20])
+{
+ uint8_t i = 0;
+
+ while(str[i]){
+ switch(str[i]){
+ case '1':
+ NR13_REG = R1;
+ NR23_REG = C1;
+ break;
+ case '2':
+ NR13_REG = R1;
+ NR23_REG = C2;
+ break;
+ case '3':
+ NR13_REG = R1;
+ NR23_REG = C3;
+ break;
+ case 'A':
+ case 'a':
+ NR13_REG = R1;
+ NR23_REG = C4;
+ break;
+ case '4':
+ NR13_REG = R2;
+ NR23_REG = C1;
+ break;
+ case '5':
+ NR13_REG = R2;
+ NR23_REG = C2;
+ break;
+ case '6':
+ NR13_REG = R2;
+ NR23_REG = C3;
+ break;
+ case 'B':
+ case 'b':
+ NR13_REG = R2;
+ NR23_REG = C4;
+ break;
+ case '7':
+ NR13_REG = R3;
+ NR23_REG = C1;
+ break;
+ case '8':
+ NR13_REG = R3;
+ NR23_REG = C2;
+ break;
+ case '9':
+ NR13_REG = R3;
+ NR23_REG = C3;
+ break;
+ case 'C':
+ case 'c':
+ NR13_REG = R3;
+ NR23_REG = C4;
+ break;
+ case '*':
+ NR13_REG = R4;
+ NR23_REG = C1;
+ break;
+ case '0':
+ NR13_REG = R4;
+ NR23_REG = C2;
+ break;
+ case '#':
+ NR13_REG = R4;
+ NR23_REG = C3;
+ break;
+ case 'D':
+ case 'd':
+ NR13_REG = R4;
+ NR23_REG = C4;
+ break;
+ case ',':
+ delay(dtmf_on); /* keep on */
+ delay(dtmf_off); /* keep off */
+
+ default:
+ NR51_REG = 0x00U; /* sound off */
+ goto skip;
+
+ }
+ NR24_REG = 0x87U; /* ch2 tips */
+ NR51_REG = 0x33U; /* sound on */
+ delay(dtmf_on); /* keep on */
+
+ NR51_REG = 0x00U; /* sound off */
+ delay(dtmf_off); /* keep off */
+
+ skip:
+ i++;
+ }
+}
+
+
+/* Display looks like 7-SEGMENT LED */
+void disp_lcd(uint8_t len, char str[MAX_DTMF])
+{
+ uint8_t i,j;
+
+ j = len;
+
+ i=0;
+ while(str[i]){
+ if(str[i] >= '0'||'9' <= str[i]){
+ disp_tile[i] = OFFSET + (str[i] - '0') * 2;
+ disp_tile[i+j] = OFFSET + (str[i] - '0') * 2 + 1;
+ }
+ switch(str[i]){
+ case 'A':
+ disp_tile[i] = OFFSET + 10 * 2;
+ disp_tile[i+j] = OFFSET + 10 * 2 + 1;
+ break;
+ case 'B':
+ disp_tile[i] = OFFSET + 11 * 2;
+ disp_tile[i+j] = OFFSET + 11 * 2 + 1;
+ break;
+ case 'C':
+ disp_tile[i] = OFFSET + 12 * 2;
+ disp_tile[i+j] = OFFSET + 12 * 2 + 1;
+ break;
+ case 'D':
+ disp_tile[i] = OFFSET + 13 * 2;
+ disp_tile[i+j] = OFFSET + 13 * 2 + 1;
+ break;
+ case '#':
+ disp_tile[i] = OFFSET + 14 * 2;
+ disp_tile[i+j] = OFFSET + 14 * 2 + 1;
+ break;
+ case '*':
+ disp_tile[i] = OFFSET + 15 * 2;
+ disp_tile[i+j] = OFFSET + 15 * 2 + 1;
+ break;
+ case ' ':
+ disp_tile[i] = OFFSET + 16 * 2;
+ disp_tile[i+j] = OFFSET + 16 * 2 + 1;
+ break;
+ case 'Y':
+ disp_tile[i] = OFFSET + 17 * 2;
+ disp_tile[i+j] = OFFSET + 17 * 2 + 1;
+ break;
+ case 'M':
+ disp_tile[i] = OFFSET + 18 * 2;
+ disp_tile[i+j] = OFFSET + 18 * 2 + 1;
+ break;
+ case 'U':
+ disp_tile[i] = OFFSET + 19 * 2;
+ disp_tile[i+j] = OFFSET + 19 * 2 + 1;
+ break;
+ case 'G':
+ disp_tile[i] = OFFSET + 20 * 2;
+ disp_tile[i+j] = OFFSET + 20 * 2 + 1;
+ break;
+ case '-':
+ disp_tile[i] = OFFSET + 21 * 2;
+ disp_tile[i+j] = OFFSET + 21 * 2 + 1;
+ break;
+ case 'T':
+ disp_tile[i] = OFFSET + 22 * 2;
+ disp_tile[i+j] = OFFSET + 22 * 2 + 1;
+ break;
+ case ',':
+ disp_tile[i] = OFFSET + 23 * 2;
+ disp_tile[i+j] = OFFSET + 23 * 2 + 1;
+ break;
+ case 'F':
+ disp_tile[i] = OFFSET + 24 * 2;
+ disp_tile[i+j] = OFFSET + 24 * 2 + 1;
+ break;
+ case 'S':
+ disp_tile[i] = OFFSET + ('5' - '0') * 2;
+ disp_tile[i+j] = OFFSET + ('5' - '0') * 2 + 1;
+ break;
+ }
+ i++;
+ }
+}
+
+/* clear display */
+void clr_disp()
+{
+ set_bkg_data(OFFSET, 50, dtmf_lcd);
+ set_bkg_tiles(LCD_X, LCD_Y, LCD_WIDTH, LCD_HIGHT, init_disp);
+}
+
+/*
+ CAUTION: Don't display the NULL code
+*/
+void disp(const char *str)
+{
+ uint8_t no, left_pos;
+ uint8_t i, start_ch, end_ch;
+ char work[MAX_DTMF];
+
+ clr_disp();
+
+ no = 0;
+ while(str[no]){
+ no++;
+ }
+
+ if(no >= LCD_WIDTH){
+ start_ch = no - LCD_WIDTH;
+ end_ch = LCD_WIDTH;
+ }
+ else{
+ start_ch = 0;
+ end_ch = no;
+ }
+ for(i = 0;i < end_ch;i++){
+ work[i] = str[i+start_ch];
+ }
+ work[end_ch] = 0x00;
+
+ disp_lcd(end_ch, work);
+
+ left_pos = 19 - end_ch;
+ set_bkg_tiles(left_pos, 2, end_ch, LCD_HIGHT, disp_tile);
+}
+
+void press_button(uint8_t x, uint8_t y)
+{
+ if(x <= 3 && y <= 3){
+ set_bkg_tiles(x * 3 + 1, y * 3 + 5, 3, 3, press_tile);
+ }
+ if((x == 4 || x == 5) && (y <= 2)){
+ set_bkg_tiles(x * 3 + 2, y * 3 + 5, 3, 3, press_tile);
+ }
+ if((x == 4 || x == 5) && (y == 3)){
+ set_bkg_tiles(14, 14, 6, 3, dialing_press);
+ }
+}
+
+void break_button(uint8_t x, uint8_t y)
+{
+ if(x <= 3 && y <= 3){
+ set_bkg_tiles(x * 3 + 1, y * 3 + 5, 3, 3, break_tile);
+ }
+ if((x == 4 || x == 5) && (y <= 2)){
+ set_bkg_tiles(x * 3 + 2, y * 3 + 5, 3, 3, break_tile);
+ }
+ if((x == 4 || x == 5) && (y == 3)){
+ set_bkg_tiles(14, 14, 6, 3, dialing_break);
+ }
+}
+
+
+void init_key()
+{
+ uint8_t key_x, key_y, i;
+
+ /* To make numeric KeyPad */
+ set_sprite_data(0, 24, key_num);
+
+ /* key pad 1 - 3 */
+ key_y = KEY_STEP + 40;
+ for(i = 1;i <= 3;i++){
+ key_x = i * KEY_STEP;
+ set_sprite_tile(i, i);
+ move_sprite(i, key_x, key_y);
+ }
+
+ /* key pad 4 - 6 */
+ key_y = KEY_STEP * 2 + 40;
+ for(i = 4;i <= 6;i++){
+ key_x = (i - 3) * KEY_STEP;
+ set_sprite_tile(i, i);
+ move_sprite(i, key_x, key_y);
+ }
+
+ /* key pad 7 - 9 */
+ key_y = KEY_STEP * 3 + 40;
+ for(i = 7;i <= 9;i++){
+ key_x = (i - 6) * KEY_STEP;
+ set_sprite_tile(i, i);
+ move_sprite(i, key_x, key_y);
+ }
+
+ /* key pad 'A' - 'D' */
+ key_x = KEY_STEP * 4;
+ for(i = 0;i <= 3;i++){
+ key_y = (i+1) * KEY_STEP + 40;
+ set_sprite_tile(i+10, i+10);
+ move_sprite(i+10, key_x, key_y);
+ }
+
+ /* key pad '*', '0', '#' */
+ set_sprite_tile(15, 15);
+ move_sprite(15, KEY_STEP * 1, KEY_STEP * 4 + 40U);
+ set_sprite_tile(0, 0);
+ move_sprite(0, KEY_STEP * 2, KEY_STEP * 4 + 40U);
+ set_sprite_tile(14, 14);
+ move_sprite(14, KEY_STEP * 3, KEY_STEP * 4 + 40U);
+
+ /* func left */
+ key_x = KEY_STEP * 5 + 8U;
+ for(i = 0;i <= 2;i++){
+ key_y = (i+1) * KEY_STEP + 40;
+ set_sprite_tile(i+16, i+16);
+ move_sprite(i+16, key_x, key_y);
+ }
+
+ /* func right */
+ key_x = KEY_STEP * 6 + 8U;
+ for(i = 0;i <= 2;i++){
+ key_y = (i+1) * KEY_STEP + 40;
+ set_sprite_tile(i+19, i+19);
+ move_sprite(i+19, key_x, key_y);
+ }
+
+ /* dialing button */
+ key_x = KEY_STEP * 5 + 20U;
+ key_y = KEY_STEP * 4 + 40U;
+ set_sprite_tile(22, 22);
+ move_sprite(22, key_x, key_y);
+}
+
+void init_background()
+{
+ /* Initialize the background */
+ set_bkg_data( 0, 9, frame_lcd);
+ set_bkg_data( 9, 9, break_btn);
+ set_bkg_data(18, 9, press_btn);
+
+ set_bkg_tiles(0, 0, 20, 18, dtmf_tile);
+}
+
+void init_cursor()
+{
+ uint8_t i;
+
+ /* Setup the cursor data*/
+ set_sprite_data(23, 8, cursor_data);
+
+ for(i = 23;i <= 30;i++){
+ set_sprite_tile(i, i);
+ }
+}
+
+void move_cursor(uint8_t x, uint8_t y)
+{
+ move_sprite(23, x, y);
+ move_sprite(24, x, y+8);
+ move_sprite(25, x+8, y);
+ move_sprite(26, x+8, y+8);
+}
+
+void main()
+{
+ uint8_t key1, key2, i, j, pos_x, pos_y, ch_pos;
+ uint8_t non_flick = OFF;
+ uint16_t on_time, off_time;
+
+ char str[MAX_DTMF];
+ char str_ms[10];
+
+ /* PENDING: sdcc is broken and needs this to be initalised. */
+ key2 = 0;
+
+ /* default dialling time setting */
+ on_time = DTMF_ON;
+ off_time = DTMF_OFF;
+
+ disable_interrupts();
+
+ SPRITES_8x8; /* sprites are 8x8 */
+
+ init_dial();
+
+ init_background();
+
+ init_key();
+
+ init_cursor();
+
+ disp(TITLE);
+
+ SHOW_BKG;
+ SHOW_SPRITES;
+ DISPLAY_ON;
+
+ enable_interrupts();
+
+ i = j = 0;
+
+ ch_pos = 0;
+
+ while(1) {
+ wait_vbl_done();
+ key1 = joypad();
+
+ if(key1 != key2){
+ pos_x = i * KEY_STEP + START_CURSOR_X;
+ pos_y = j * KEY_STEP + START_CURSOR_Y;
+ move_cursor(pos_x, pos_y);
+ }
+
+ if(key2 & J_A){
+ if(key1 & J_A){
+ /* value set for each sound reg only numeric key pad*/
+ if(i <= 3 && j <= 3){
+ /* frequncy register set up for DTMF */
+ NR13_REG = row[i];
+ NR23_REG = col[j];
+ NR24_REG = 0x87U;
+
+ /* sound output on */
+ NR51_REG = 0x33U;
+ }
+
+ /* '?' button */
+ /* appear the title during press A button */
+ if(i == 5 && j == 0 && !non_flick){
+ disp(TITLE);
+ non_flick = ON;
+ }
+
+ /* incremental button */
+ /* decremental button */
+ /* appear the delay during press A button */
+ if(i == 5 && (j == 1 || j == 2) && !non_flick){
+ sprintf(str_ms, "%u MS", on_time);
+ disp(str_ms);
+ non_flick = ON;
+ }
+ }
+ else{
+ /* sound output off */
+ NR51_REG = 0x00U;
+
+ break_button(i, j);
+
+ /* '?' button */
+ /* incremental button */
+ /* decremental button */
+ /* return to normal display at release the A button */
+ if(i == 5 && (j == 0 || j == 1 || j == 2)){
+ non_flick = OFF;
+ if(ch_pos == 0)
+ clr_disp();
+ else
+ disp(str);
+ }
+ }
+ }
+ else{
+ if(key1 & J_A){
+ /* button display handle */
+ press_button(i, j);
+
+ /* numeric key pad handling */
+ if(i <= 3 && j <= 3){
+ /* string length check */
+ if(ch_pos < MAX_DTMF-1){
+ str[ch_pos] = pad[j][i];
+ ch_pos++;
+ str[ch_pos] = 0x00;
+ disp(str);
+ }
+ }
+
+ /* ',' button */
+ if(i == 4 && j == 2){
+ /* string length check */
+ if(ch_pos < MAX_DTMF-1){
+ str[ch_pos] = pad[j][i];
+ ch_pos++;
+ str[ch_pos] = 0x00;
+ disp(str);
+ }
+ }
+
+ /* all clear button */
+ if(i == 4 && j == 0){
+ ch_pos = 0x00;
+ strcpy(str,"");
+ clr_disp();
+ }
+
+ /* delete button */
+ if(i == 4 && j == 1){
+ if(ch_pos > 0){
+ ch_pos--;
+ str[ch_pos] = 0x00;
+ if(ch_pos == 0)
+ clr_disp();
+ else
+ disp(str);
+ }
+ }
+
+ /* incremental button */
+ if(i == 5 && j == 1){
+ if(on_time >= DTMF_ON / 2){
+ on_time = on_time - 10;
+ off_time = off_time - 10;
+ }
+ }
+
+ /* decremental button */
+ if(i == 5 && j == 2){
+ if(on_time <= DTMF_ON * 2){
+ on_time = on_time + 10;
+ off_time = off_time + 10;
+ }
+ }
+
+ /* dialing button */
+ if((i==4 || i==5) && j==3){
+ dialtone(on_time, off_time, str);
+ }
+ }
+ }
+ if(!(key1 & J_A)){
+ if((key1 & J_UP) && !(key2 & J_UP) && j > 0)
+ j--;
+ else if((key1 & J_DOWN) && !(key2 & J_DOWN) && j < 3)
+ j++;
+
+ if((key1 & J_LEFT) && !(key2 & J_LEFT) && i > 0)
+ i--;
+ else if((key1 & J_RIGHT) && !(key2 & J_RIGHT) && i < 5)
+ i++;
+ }
+ key2 = key1;
+ }
+}
diff --git a/gbdk/gbdk-lib/examples/gb/gb-dtmf/key_num.c b/gbdk/gbdk-lib/examples/gb/gb-dtmf/key_num.c
new file mode 100644
index 00000000..efc56276
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/gb-dtmf/key_num.c
@@ -0,0 +1,69 @@
+/*
+
+ KEY_NUM.C
+
+ Tile Source File.
+
+ Info:
+ Form : All tiles as one unit.
+ Format : Gameboy 4 color.
+ Counter : None.
+ Tile size : 8 x 8
+ Tiles : 0 to 22
+
+ This file was generated by GBTD v0.5
+
+*/
+
+/* Start of tile array. */
+const unsigned char key_num[] =
+{
+ 0xFF,0x3C,0xFF,0x7E,0xFF,0x66,0xFF,0x66,
+ 0xFF,0x66,0xFF,0x66,0xFF,0x7E,0xFF,0x3C,
+ 0xFF,0x18,0xFF,0x38,0xFF,0x38,0xFF,0x18,
+ 0xFF,0x18,0xFF,0x18,0xFF,0x18,0xFF,0x18,
+ 0xFF,0x3C,0xFF,0x66,0xFF,0x6E,0xFF,0x1C,
+ 0xFF,0x38,0xFF,0x70,0xFF,0x7E,0xFF,0x7E,
+ 0xFF,0x7C,0xFF,0x7E,0xFF,0x06,0xFF,0x3E,
+ 0xFF,0x3E,0xFF,0x06,0xFF,0x7E,0xFF,0x7C,
+ 0xFF,0x0C,0xFF,0x1C,0xFF,0x3C,0xFF,0x6C,
+ 0xFF,0x6E,0xFF,0x7E,0xFF,0x0C,0xFF,0x0C,
+ 0xFF,0x7C,0xFF,0x7C,0xFF,0x60,0xFF,0x7C,
+ 0xFF,0x06,0xFF,0x06,0xFF,0x7E,0xFF,0x7C,
+ 0x3C,0x3C,0x62,0x62,0x60,0x60,0x7C,0x7C,
+ 0x7E,0x7E,0x62,0x62,0x62,0x62,0x3C,0x3C,
+ 0x7E,0x7E,0x06,0x06,0x06,0x06,0x0C,0x0C,
+ 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
+ 0x3C,0x3C,0x66,0x66,0x66,0x66,0x3C,0x3C,
+ 0x7E,0x7E,0x66,0x66,0x66,0x66,0x3C,0x3C,
+ 0x3C,0x3C,0x7E,0x7E,0x46,0x46,0x46,0x46,
+ 0x3E,0x3E,0x06,0x06,0x46,0x46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,
+ 0xF2,0xF2,0xF1,0xF1,0x34,0x34,0x12,0x12
+};
+
+/* End of KEY_NUM.C */
diff --git a/gbdk/gbdk-lib/examples/gb/gb-dtmf/key_num.gbr b/gbdk/gbdk-lib/examples/gb/gb-dtmf/key_num.gbr
new file mode 100644
index 00000000..3e075a62
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/gb-dtmf/key_num.gbr
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/gb/gb-dtmf/prs_btn.c b/gbdk/gbdk-lib/examples/gb/gb-dtmf/prs_btn.c
new file mode 100644
index 00000000..ea87af4f
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/gb-dtmf/prs_btn.c
@@ -0,0 +1,41 @@
+/*
+
+ PRESS_BTN.C
+
+ Tile Source File.
+
+ Info:
+ Form : All tiles as one unit.
+ Format : Gameboy 4 color.
+ Counter : None.
+ Tile size : 8 x 8
+ Tiles : 0 to 8
+
+ This file was generated by GBTD v0.5
+
+*/
+
+/* Start of tile array. */
+const unsigned char press_btn[] =
+{
+ 0x00,0xFF,0x00,0xFF,0x3F,0xC0,0x3F,0xC0,
+ 0x3F,0xC0,0x3F,0xC0,0x3F,0xC0,0x3F,0xC0,
+ 0x00,0xFF,0x00,0xFF,0xFF,0x00,0xFF,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0x00,0xFE,0x00,0xFC,0xFC,0x00,0xFC,0x00,
+ 0xFC,0x00,0xFC,0x00,0xFC,0x00,0xFC,0x00,
+ 0x3F,0xC0,0x3F,0xC0,0x3F,0xC0,0x3F,0xC0,
+ 0x3F,0xC0,0x3F,0xC0,0x3F,0xC0,0x3F,0xC0,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0xFC,0x00,0xFC,0x00,0xFC,0x00,0xFC,0x00,
+ 0xFC,0x00,0xFC,0x00,0xFC,0x00,0xFC,0x00,
+ 0x3F,0xC0,0x3F,0xC0,0x3F,0xC0,0x3F,0xC0,
+ 0x3F,0xC0,0x3F,0xC0,0x00,0xC0,0x00,0x80,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0xFF,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,
+ 0xFC,0x00,0xFC,0x00,0xFC,0x00,0xFC,0x00,
+ 0xFC,0x00,0xFC,0x00,0x00,0x00,0x00,0x00
+};
+
+/* End of PRESS_BTN.C */
diff --git a/gbdk/gbdk-lib/examples/gb/gb-dtmf/prs_btn.gbr b/gbdk/gbdk-lib/examples/gb/gb-dtmf/prs_btn.gbr
new file mode 100644
index 00000000..28423a7d
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/gb-dtmf/prs_btn.gbr
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/gb/gbdecompress/Makefile b/gbdk/gbdk-lib/examples/gb/gbdecompress/Makefile
new file mode 100644
index 00000000..085bad01
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/gbdecompress/Makefile
@@ -0,0 +1,33 @@
+#
+# Simple Makefile that compiles all .c and .s files in the same folder
+#
+
+# If you move this project you can change the directory
+# to match your GBDK root directory (ex: GBDK_HOME = "C:/GBDK/"
+GBDK_HOME = ../../../
+
+LCC = $(GBDK_HOME)bin/lcc
+
+# You can uncomment the line below to turn on debug output
+# LCC = $(LCC) -debug
+
+# You can set the name of the .gb ROM file here
+PROJECTNAME = gbdecompress
+
+BINS = $(PROJECTNAME).gb
+CSOURCES := $(wildcard *.c)
+ASMSOURCES := $(wildcard *.s)
+
+all: $(BINS)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+# Compile and link all source files in a single call to LCC
+$(BINS): $(CSOURCES) $(ASMSOURCES)
+ $(LCC) -o $@ $(CSOURCES) $(ASMSOURCES)
+
+clean:
+ rm -f *.o *.lst *.map *.gb *.ihx *.sym *.cdb *.adb *.asm *.noi
+
diff --git a/gbdk/gbdk-lib/examples/gb/gbdecompress/Readme.md b/gbdk/gbdk-lib/examples/gb/gbdecompress/Readme.md
new file mode 100644
index 00000000..7f21a65e
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/gbdecompress/Readme.md
@@ -0,0 +1,8 @@
+
+GBDecompress
+============
+
+Demonstrates using gbdecompress to load a compressed tile set into vram.
+
+The tileset was compressed during export from GBTD by checking the
+GB-compress checkbox in the export settings panel.
diff --git a/gbdk/gbdk-lib/examples/gb/gbdecompress/main.c b/gbdk/gbdk-lib/examples/gb/gbdecompress/main.c
new file mode 100644
index 00000000..e81d81f9
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/gbdecompress/main.c
@@ -0,0 +1,41 @@
+#include <gb/gb.h>
+#include <stdint.h>
+#include <gb/gbdecompress.h>
+#include <stdbool.h>
+
+// Include graphics data
+#include "monalisa_tiles_comp.h"
+#include "monalisa_map.h"
+
+// The map tiles were exported from GBTD with compression enabled
+// using this updated version of GBTD: https://github.com/untoxa/GBTD_GBMB
+// Size was 4096 bytes -> 3493 bytes
+
+void main(void)
+{
+ // Decompress the map tiles into the background tile vram.
+ //
+ // Notice that the number of tiles isn't specified. The amount
+ // of data to decompress is embedded in the compressed data.
+ //
+ // Note: For non-compressed data the equivalent would be: set_bkg_data(0, 253u, monalisa_tiles)
+ //
+ gb_decompress_bkg_data(0, monalisa_tiles_comp); // first tile, pointer to comrpessed data
+
+ // Now set the map and turn the background on
+ set_bkg_tiles(0,0, monalisa_mapWidth, monalisa_mapHeight, monalisa_mapPLN0);
+ SHOW_BKG;
+
+ // Loop forever
+ while(1) {
+
+ // Main loop processing goes here
+
+ // Done processing, yield CPU and wait for start of next frame
+ wait_vbl_done();
+ }
+}
+
+
+
+
diff --git a/gbdk/gbdk-lib/examples/gb/gbdecompress/monalisa.gbm b/gbdk/gbdk-lib/examples/gb/gbdecompress/monalisa.gbm
new file mode 100644
index 00000000..a21dfeeb
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/gbdecompress/monalisa.gbm
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/gb/gbdecompress/monalisa_map.c b/gbdk/gbdk-lib/examples/gb/gbdecompress/monalisa_map.c
new file mode 100644
index 00000000..e2bb80ee
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/gbdecompress/monalisa_map.c
@@ -0,0 +1,66 @@
+/*
+
+ MONALISA_MAP.C
+
+ Map Source File.
+
+ Info:
+ Section :
+ Bank : 0
+ Map size : 20 x 18
+ Tile set : monalisa_tiles.gbr
+ Plane count : 1 plane (8 bits)
+ Plane order : Planes are continues
+ Tile offset : 0
+ Split data : No
+
+ This file was generated by GBMB v1.8
+
+*/
+
+#define monalisa_mapWidth 20
+#define monalisa_mapHeight 18
+#define monalisa_mapBank 0
+
+#define monalisa_map monalisa_mapPLN0
+const unsigned char monalisa_mapPLN0[] =
+{
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02,
+ 0x03,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x06,0x07,
+ 0x08,0x09,0x0A,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x0B,0x0C,0x0D,0x0E,
+ 0x0F,0x10,0x11,0x12,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x13,0x14,0x00,0x00,0x00,0x00,0x15,0x16,0x00,0x17,
+ 0x18,0x19,0x1A,0x1B,0x1C,0x13,0x00,0x00,0x00,0x00,
+ 0x1D,0x1E,0x1F,0x20,0x21,0x00,0x22,0x23,0x24,0x25,
+ 0x26,0x27,0x1A,0x28,0x29,0x2A,0x2B,0x00,0x00,0x00,
+ 0x2C,0x2D,0x2E,0x2F,0x30,0x31,0x32,0x33,0x34,0x35,
+ 0x36,0x37,0x1A,0x38,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A,0xE9,0xEA,0xEB,
+ 0xEC,0xED,0xEE,0xEF,0xF0,0x1A,0x1A,0x1A,0xF1,0xF2,
+ 0x1A,0x1A,0x1A,0xF3,0xF4,0x1A,0x1A,0x1A,0xF5,0xF6,
+ 0xF7,0xF8,0xF9,0xFA,0xFB,0x1A,0x1A,0x1A,0x1A,0x1A,
+ 0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0xFC
+};
+
+/* End of MONALISA_MAP.C */
diff --git a/gbdk/gbdk-lib/examples/gb/gbdecompress/monalisa_map.h b/gbdk/gbdk-lib/examples/gb/gbdecompress/monalisa_map.h
new file mode 100644
index 00000000..f685d267
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/gbdecompress/monalisa_map.h
@@ -0,0 +1,32 @@
+/*
+
+ MONALISA_MAP.H
+
+ Map Include File.
+
+ Info:
+ Section :
+ Bank : 0
+ Map size : 20 x 18
+ Tile set : monalisa_tiles.gbr
+ Plane count : 1 plane (8 bits)
+ Plane order : Planes are continues
+ Tile offset : 0
+ Split data : No
+
+ This file was generated by GBMB v1.8
+
+*/
+#ifndef __monalisa_map_h_INCLUDE
+#define __monalisa_map_h_INCLUDE
+
+#define monalisa_mapWidth 20
+#define monalisa_mapHeight 18
+#define monalisa_mapBank 0
+
+#define monalisa_map monalisa_mapPLN0
+extern const unsigned char monalisa_mapPLN0[];
+
+#endif
+
+/* End of MONALISA_MAP.H */
diff --git a/gbdk/gbdk-lib/examples/gb/gbdecompress/monalisa_tiles.gbr b/gbdk/gbdk-lib/examples/gb/gbdecompress/monalisa_tiles.gbr
new file mode 100644
index 00000000..821f2928
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/gbdecompress/monalisa_tiles.gbr
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/gb/gbdecompress/monalisa_tiles_comp.c b/gbdk/gbdk-lib/examples/gb/gbdecompress/monalisa_tiles_comp.c
new file mode 100644
index 00000000..0a671dda
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/gbdecompress/monalisa_tiles_comp.c
@@ -0,0 +1,467 @@
+/*
+
+ MONALISA_TILES_COMP.C
+
+ Tile Source File.
+
+ Info:
+ Form : All tiles as one unit.
+ Format : Gameboy 4 color.
+ Compression : GB-Compress.
+ Counter : None.
+ Tile size : 8 x 8
+ Tiles : 0 to 252
+
+ Palette colors : Included.
+ SGB Palette : None.
+ CGB Palette : None.
+
+ Convert to metatiles : No.
+
+ This file was generated by GBTD v2.2
+
+*/
+
+/* Start of tile array. */
+const unsigned char monalisa_tiles_comp[] =
+{
+ 0x1D,0x00,0xC1,0x02,0x01,0x8B,0xE0,0xFF,
+ 0xC3,0x10,0x2F,0x11,0xFF,0x8B,0xD0,0xFF,
+ 0xC2,0x0D,0xF2,0x54,0x8C,0xF0,0xFF,0xC2,
+ 0x00,0x00,0xE0,0x89,0xB1,0xFF,0xE9,0x01,
+ 0x02,0x01,0x02,0x07,0x08,0x07,0x02,0x0F,
+ 0x20,0x1F,0x6A,0x3F,0x82,0x7D,0xA1,0xFE,
+ 0xAB,0x54,0x01,0xFE,0xAF,0x50,0xAF,0xFF,
+ 0x0D,0xFF,0x2F,0xFF,0x81,0x7F,0x2A,0xFF,
+ 0xA0,0x5F,0x0A,0xFF,0xA8,0x57,0xFF,0xFF,
+ 0xDD,0x02,0xFF,0xD0,0x57,0xFF,0xFF,0xFF,
+ 0x5D,0xFF,0x3F,0xFF,0x15,0xFF,0xE0,0xF8,
+ 0xDA,0xFC,0xFF,0xFE,0xDF,0x08,0xFF,0x84,
+ 0x60,0xFF,0xCA,0x80,0x80,0x00,0x80,0xE0,
+ 0xD0,0xE0,0xE0,0xF0,0xF0,0xF8,0x8B,0x50,
+ 0xFF,0xD8,0x01,0x00,0x01,0x00,0x1A,0x0F,
+ 0x00,0x1F,0x09,0x3E,0x64,0x18,0xE6,0x38,
+ 0x0C,0x70,0xE8,0x70,0x50,0xE0,0x1E,0xE0,
+ 0xC0,0x00,0x80,0x8A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x5F,0x83,0x98,0xF7,0xC3,0x3F,
+ 0xFF,0xD7,0x7F,0x87,0x10,0xF2,0x8D,0xA0,
+ 0xF2,0xC0,0x07,0x86,0x94,0xF5,0xC0,0xF4,
+ 0x86,0x90,0xF5,0xC0,0xFF,0x84,0xC8,0xFA,
+ 0xC2,0xAF,0xFF,0x05,0x86,0x40,0xFE,0x83,
+ 0xE0,0xFE,0xC8,0xE9,0xFF,0xFB,0xFF,0xC5,
+ 0xFF,0xEF,0xFF,0xCD,0x86,0x60,0xFE,0xC2,
+ 0x29,0xDF,0xAF,0x84,0x20,0xFE,0x85,0x4C,
+ 0xF1,0xC4,0xE0,0xFF,0xC8,0xF7,0xE0,0x84,
+ 0x2C,0xF3,0xC0,0xF4,0x84,0x28,0xFC,0x83,
+ 0xD4,0xF4,0x83,0xD0,0xF8,0xC1,0x14,0xEB,
+ 0x83,0x98,0xF8,0xC4,0x01,0xFF,0x3E,0xFF,
+ 0x0C,0x84,0x48,0xFE,0x85,0x90,0xF7,0xC1,
+ 0x80,0x7F,0x85,0x34,0xF5,0xC6,0x08,0xF7,
+ 0xA2,0xFF,0x01,0xFF,0x2F,0x84,0x28,0xF7,
+ 0xC4,0x0D,0xFF,0xBF,0xFF,0x15,0x8A,0x28,
+ 0xF7,0x85,0xF8,0xFD,0xC6,0xFF,0xFF,0xED,
+ 0xFF,0xFF,0xFF,0x50,0x86,0x88,0xFF,0x83,
+ 0x64,0xF5,0xC6,0x81,0xFF,0xFE,0xFF,0x01,
+ 0xFF,0xA2,0x84,0x4C,0xF8,0xC2,0x50,0xFF,
+ 0xEA,0x83,0xFC,0xFF,0xC2,0xFF,0xD0,0xFF,
+ 0x00
+};
+
+/* End of MONALISA_TILES_COMP.C */
diff --git a/gbdk/gbdk-lib/examples/gb/gbdecompress/monalisa_tiles_comp.h b/gbdk/gbdk-lib/examples/gb/gbdecompress/monalisa_tiles_comp.h
new file mode 100644
index 00000000..a90b1cc3
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/gbdecompress/monalisa_tiles_comp.h
@@ -0,0 +1,107 @@
+/*
+
+ MONALISA_TILES_COMP.H
+
+ Include File.
+
+ Info:
+ Form : All tiles as one unit.
+ Format : Gameboy 4 color.
+ Compression : GB-Compress.
+ Counter : None.
+ Tile size : 8 x 8
+ Tiles : 0 to 252
+
+ Palette colors : Included.
+ SGB Palette : None.
+ CGB Palette : None.
+
+ Convert to metatiles : No.
+
+ This file was generated by GBTD v2.2
+
+*/
+
+#ifndef __monalisa_tiles_comp_h_INCLUDE
+#define __monalisa_tiles_comp_h_INCLUDE
+
+/* Bank of tiles. */
+#define monalisa_tiles_compBank 0
+
+/* Super Gameboy palette 0 */
+#define monalisa_tiles_compSGBPal0c0 0
+#define monalisa_tiles_compSGBPal0c1 0
+#define monalisa_tiles_compSGBPal0c2 18432
+#define monalisa_tiles_compSGBPal0c3 749
+
+/* Super Gameboy palette 1 */
+#define monalisa_tiles_compSGBPal1c0 6076
+#define monalisa_tiles_compSGBPal1c1 8935
+#define monalisa_tiles_compSGBPal1c2 6596
+#define monalisa_tiles_compSGBPal1c3 5344
+
+/* Super Gameboy palette 2 */
+#define monalisa_tiles_compSGBPal2c0 6076
+#define monalisa_tiles_compSGBPal2c1 8935
+#define monalisa_tiles_compSGBPal2c2 6596
+#define monalisa_tiles_compSGBPal2c3 5344
+
+/* Super Gameboy palette 3 */
+#define monalisa_tiles_compSGBPal3c0 6076
+#define monalisa_tiles_compSGBPal3c1 8935
+#define monalisa_tiles_compSGBPal3c2 6596
+#define monalisa_tiles_compSGBPal3c3 5344
+
+/* Gameboy Color palette 0 */
+#define monalisa_tiles_compCGBPal0c0 4228
+#define monalisa_tiles_compCGBPal0c1 11627
+#define monalisa_tiles_compCGBPal0c2 20083
+#define monalisa_tiles_compCGBPal0c3 30653
+
+/* Gameboy Color palette 1 */
+#define monalisa_tiles_compCGBPal1c0 6076
+#define monalisa_tiles_compCGBPal1c1 8935
+#define monalisa_tiles_compCGBPal1c2 6596
+#define monalisa_tiles_compCGBPal1c3 5344
+
+/* Gameboy Color palette 2 */
+#define monalisa_tiles_compCGBPal2c0 6076
+#define monalisa_tiles_compCGBPal2c1 8935
+#define monalisa_tiles_compCGBPal2c2 6596
+#define monalisa_tiles_compCGBPal2c3 5344
+
+/* Gameboy Color palette 3 */
+#define monalisa_tiles_compCGBPal3c0 6076
+#define monalisa_tiles_compCGBPal3c1 8935
+#define monalisa_tiles_compCGBPal3c2 6596
+#define monalisa_tiles_compCGBPal3c3 5344
+
+/* Gameboy Color palette 4 */
+#define monalisa_tiles_compCGBPal4c0 6076
+#define monalisa_tiles_compCGBPal4c1 8935
+#define monalisa_tiles_compCGBPal4c2 6596
+#define monalisa_tiles_compCGBPal4c3 5344
+
+/* Gameboy Color palette 5 */
+#define monalisa_tiles_compCGBPal5c0 6076
+#define monalisa_tiles_compCGBPal5c1 8935
+#define monalisa_tiles_compCGBPal5c2 6596
+#define monalisa_tiles_compCGBPal5c3 5344
+
+/* Gameboy Color palette 6 */
+#define monalisa_tiles_compCGBPal6c0 6076
+#define monalisa_tiles_compCGBPal6c1 8935
+#define monalisa_tiles_compCGBPal6c2 6596
+#define monalisa_tiles_compCGBPal6c3 5344
+
+/* Gameboy Color palette 7 */
+#define monalisa_tiles_compCGBPal7c0 6076
+#define monalisa_tiles_compCGBPal7c1 8935
+#define monalisa_tiles_compCGBPal7c2 6596
+#define monalisa_tiles_compCGBPal7c3 5344
+/* Start of tile array. */
+extern const unsigned char monalisa_tiles_comp[];
+
+#endif
+
+/* End of MONALISA_TILES_COMP.H */
diff --git a/gbdk/gbdk-lib/examples/gb/incbin/Makefile b/gbdk/gbdk-lib/examples/gb/incbin/Makefile
new file mode 100644
index 00000000..cecf205b
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/incbin/Makefile
@@ -0,0 +1,60 @@
+#
+# A Makefile that compiles all .c and .s files in "src" and "res"
+# subdirectories and places the output in a "obj" subdirectory
+#
+
+# If you move this project you can change the directory
+# to match your GBDK root directory (ex: GBDK_HOME = "C:/GBDK/"
+GBDK_HOME = ../../../
+
+LCC = $(GBDK_HOME)bin/lcc
+
+# You can set flags for LCC here
+# For example, you can uncomment the line below to turn on debug output
+LCCFLAGS = -Wl-j -Wm-yS
+
+# You can set the name of the .gb ROM file here
+PROJECTNAME = Example
+
+SRCDIR = src
+OBJDIR = obj
+RESDIR = res
+BINS = $(PROJECTNAME).gb
+CSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.c))) $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.c)))
+ASMSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.s)))
+OBJS = $(CSOURCES:%.c=$(OBJDIR)/%.o) $(ASMSOURCES:%.s=$(OBJDIR)/%.o)
+
+all: prepare $(BINS)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+# Compile .c files in "src/" to .o object files
+$(OBJDIR)/%.o: $(SRCDIR)/%.c
+ $(LCC) $(LCCFLAGS) -c -o $@ $<
+
+# Compile .c files in "res/" to .o object files
+$(OBJDIR)/%.o: $(RESDIR)/%.c
+ $(LCC) $(LCCFLAGS) -c -o $@ $<
+
+# Compile .s assembly files in "src/" to .o object files
+$(OBJDIR)/%.o: $(SRCDIR)/%.s
+ $(LCC) $(LCCFLAGS) -c -o $@ $<
+
+# If needed, compile .c files i n"src/" to .s assembly files
+# (not required if .c is compiled directly to .o)
+$(OBJDIR)/%.s: $(SRCDIR)/%.c
+ $(LCC) $(LCCFLAGS) -S -o $@ $<
+
+# Link the compiled object files into a .gb ROM file
+$(BINS): $(OBJS)
+ $(LCC) $(LCCFLAGS) -o $(BINS) $(OBJS)
+
+prepare:
+ mkdir -p $(OBJDIR)
+
+clean:
+ rm -f *.gb *.ihx *.cdb *.adb *.noi *.map *.sym
+ rm -rf $(OBJDIR)
+
diff --git a/gbdk/gbdk-lib/examples/gb/incbin/Readme.md b/gbdk/gbdk-lib/examples/gb/incbin/Readme.md
new file mode 100644
index 00000000..f5aef6be
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/incbin/Readme.md
@@ -0,0 +1,8 @@
+
+An example project showing how to use 'incbin.h' to include binary files into C source files.
+
+
+The 4 color .png files were exported to .bin format (2bpp gb) using the gimp plugin listed below.
+There are many other tools which can also do the conversion.
+
+https://github.com/bbbbbr/gimp-rom-bin
diff --git a/gbdk/gbdk-lib/examples/gb/incbin/res/blanktile.bin b/gbdk/gbdk-lib/examples/gb/incbin/res/blanktile.bin
new file mode 100644
index 00000000..01d633b2
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/incbin/res/blanktile.bin
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/gb/incbin/res/blanktile.png b/gbdk/gbdk-lib/examples/gb/incbin/res/blanktile.png
new file mode 100644
index 00000000..e364f322
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/incbin/res/blanktile.png
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/gb/incbin/res/gbdk2020.bin b/gbdk/gbdk-lib/examples/gb/incbin/res/gbdk2020.bin
new file mode 100644
index 00000000..84a52fcb
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/incbin/res/gbdk2020.bin
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/gb/incbin/res/gbdk2020.png b/gbdk/gbdk-lib/examples/gb/incbin/res/gbdk2020.png
new file mode 100644
index 00000000..6e13e499
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/incbin/res/gbdk2020.png
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/gb/incbin/res/gbdk2020_map.bin b/gbdk/gbdk-lib/examples/gb/incbin/res/gbdk2020_map.bin
new file mode 100644
index 00000000..36c4ca51
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/incbin/res/gbdk2020_map.bin
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/gb/incbin/src/main.c b/gbdk/gbdk-lib/examples/gb/incbin/src/main.c
new file mode 100644
index 00000000..73549a99
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/incbin/src/main.c
@@ -0,0 +1,58 @@
+#include <gb/gb.h>
+#include <stdint.h>
+
+#include <gbdk/incbin.h>
+
+INCBIN(logo_tiles_data, "res/gbdk2020.bin") // Variable name to use, Path to file
+INCBIN_EXTERN(logo_tiles_data) // Extern declarations for binary data
+
+INCBIN(logo_map, "res/gbdk2020_map.bin")
+INCBIN_EXTERN(logo_map)
+
+INCBIN(blank_tile_data, "res/blanktile.bin")
+INCBIN_EXTERN(blank_tile_data)
+
+
+#define TILE_BYTES 16 // 16 bytes per background tile
+
+
+// Since incbin just includes a binary file (the logo tiles)
+// a map needs to be created for them. For this example
+// the tiles are non-deduplciated, so a array of incrementing
+// values can be used. There are 84 tiles.
+#define LOGO_MAP_WIDTH 7u
+#define LOGO_MAP_HEIGHT 12u
+#define LOGO_MAP_X (20u - LOGO_MAP_WIDTH) / 2u // Center on X axis
+#define LOGO_MAP_Y (18u - LOGO_MAP_HEIGHT) / 2u // Center on Y axis
+
+void init_gfx() {
+ // Load a single clear background tile at location 0x80 and clear/fill the map with it
+ set_bkg_data(0x80u, 1u, blank_tile_data); // The first 0x80u here is the tile ID
+ fill_bkg_rect(0u, 0u, 20u, 18u, 0x80u); // The last 0x80u here is the tile ID
+
+ // Load logo background tiles and map
+ // They start at 0u
+ set_bkg_data(0u, INCBIN_SIZE(logo_tiles_data) / TILE_BYTES, logo_tiles_data);
+ set_bkg_tiles(LOGO_MAP_X, LOGO_MAP_Y,
+ LOGO_MAP_WIDTH, LOGO_MAP_HEIGHT,
+ logo_map);
+
+ // Turn the background map on to make it visible
+ SHOW_BKG;
+}
+
+
+
+void main(void)
+{
+ init_gfx();
+
+ // Loop forever
+ while(1) {
+
+ // Game main loop processing goes here
+
+ // Done processing, yield CPU and wait for start of next frame
+ wait_vbl_done();
+ }
+}
diff --git a/gbdk/gbdk-lib/examples/gb/irq/Makefile b/gbdk/gbdk-lib/examples/gb/irq/Makefile
new file mode 100644
index 00000000..98147ba3
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/irq/Makefile
@@ -0,0 +1,17 @@
+CC = ../../../bin/lcc -Wa-l -Wl-m -Wl-j
+
+BINS = irq.gb
+
+all: $(BINS)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+# Compile and link single file in one pass
+%.gb: %.c
+ $(CC) -o $@ $<
+
+clean:
+ rm -f *.o *.lst *.map *.gb *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi
+
diff --git a/gbdk/gbdk-lib/examples/gb/irq/irq.c b/gbdk/gbdk-lib/examples/gb/irq/irq.c
new file mode 100644
index 00000000..25b0c868
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/irq/irq.c
@@ -0,0 +1,63 @@
+#include <gb/gb.h>
+#include <gbdk/console.h>
+
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+
+// counters are 16-bit so we need a mutual exclusion access
+unsigned int vbl_cnt, tim_cnt;
+
+void vbl()
+{
+ // Upon IRQ, interrupts are automatically disabled
+ vbl_cnt++;
+}
+
+void tim()
+{
+ // Upon IRQ, interrupts are automatically disabled
+ tim_cnt++;
+}
+
+void print_counter()
+{
+ unsigned int cnt;
+
+ // Ensure mutual exclusion
+ CRITICAL {
+ cnt = tim_cnt;
+ }
+
+ printf(" TIM %u", cnt);
+ gotoxy(9, posy());
+
+ // Ensure mutual exclusion
+ CRITICAL {
+ cnt = vbl_cnt;
+ }
+
+ printf("- VBL %u\n", cnt);
+}
+
+void main()
+{
+ // Ensure mutual exclusion
+ CRITICAL {
+ vbl_cnt = tim_cnt = 0;
+ add_VBL(vbl);
+ add_TIM(tim);
+ }
+
+ // Set TMA to divide clock by 0x100
+ TMA_REG = 0x00U;
+ // Set clock to 4096 Hertz
+ TAC_REG = 0x04U;
+ // Handle VBL and TIM interrupts
+ set_interrupts(VBL_IFLAG | TIM_IFLAG);
+
+ while(1) {
+ print_counter();
+ delay(1000UL);
+ }
+}
diff --git a/gbdk/gbdk-lib/examples/gb/isr_vector/Makefile b/gbdk/gbdk-lib/examples/gb/isr_vector/Makefile
new file mode 100644
index 00000000..5662a840
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/isr_vector/Makefile
@@ -0,0 +1,17 @@
+CC = ../../../bin/lcc -Wa-l -Wl-m -Wl-j -Wm-yS
+
+BINS = lcd_isr_wobble.gb
+
+all: $(BINS)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+# Compile and link single file in one pass
+%.gb: %.c
+ $(CC) -o $@ $<
+
+clean:
+ rm -f *.o *.lst *.map *.gb *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi
+
diff --git a/gbdk/gbdk-lib/examples/gb/isr_vector/lcd_isr_wobble.c b/gbdk/gbdk-lib/examples/gb/isr_vector/lcd_isr_wobble.c
new file mode 100644
index 00000000..1c71ea8a
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/isr_vector/lcd_isr_wobble.c
@@ -0,0 +1,22 @@
+#include <gb/gb.h>
+#include <gb/isr.h>
+
+const uint8_t scanline_offsets_tbl[] = {0, 1, 2, 3, 3, 2, 1, 0, 0, 1, 2, 3, 3, 2, 1, 0};
+const uint8_t * scanline_offsets = scanline_offsets_tbl;
+
+void scanline_isr() CRITICAL INTERRUPT {
+ SCX_REG = scanline_offsets[LY_REG & (uint8_t)7];
+}
+ISR_VECTOR(VECTOR_STAT, scanline_isr)
+
+void main() {
+ LCDC_REG |= LCDCF_BG8000;
+ STAT_REG = STATF_MODE00;
+ set_interrupts(VBL_IFLAG | LCD_IFLAG);
+ SHOW_BKG;
+
+ while (TRUE) {
+ wait_vbl_done();
+ scanline_offsets = &scanline_offsets_tbl[(uint8_t)(sys_time >> 2) & 0x07u];
+ }
+} \ No newline at end of file
diff --git a/gbdk/gbdk-lib/examples/gb/large_map/Makefile b/gbdk/gbdk-lib/examples/gb/large_map/Makefile
new file mode 100644
index 00000000..b87c6648
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/large_map/Makefile
@@ -0,0 +1,11 @@
+CC = ../../../bin/lcc
+
+all:
+ $(CC) -o large_map.gb large_map.c bigmap_map.c bigmap_tiles.c
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+clean:
+ rm -f *.o *.lst *.map *.gb *.ihx *.sym *.cdb *.adb *.asm
diff --git a/gbdk/gbdk-lib/examples/gb/large_map/Readme.md b/gbdk/gbdk-lib/examples/gb/large_map/Readme.md
new file mode 100644
index 00000000..5a88c78e
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/large_map/Readme.md
@@ -0,0 +1,14 @@
+
+Large Map
+=========
+
+Shows how to scroll with maps larger than 32 x 32 tiles using set_bkg_submap().
+
+It fills rows and columns at the edges of the visible viewport (of the hardware
+Background Map) with the desired sub-region of the large map as it scrolls.
+
+
+Overworld Map and Tiles are by ArMM1998:
+https://opengameart.org/content/gameboy-tileset
+License(s): CC0
+
diff --git a/gbdk/gbdk-lib/examples/gb/large_map/bigmap_map.c b/gbdk/gbdk-lib/examples/gb/large_map/bigmap_map.c
new file mode 100644
index 00000000..b433c25e
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/large_map/bigmap_map.c
@@ -0,0 +1,1661 @@
+/*
+
+ BIGMAP_MAP.C
+
+ Map Source File.
+
+ Info:
+ Section :
+ Bank : 0
+ Map size : 247 x 66
+ Tile set : bigmap_tiles.gbr
+ Plane count : 1 plane (8 bits)
+ Plane order : Planes are continues
+ Tile offset : 0
+ Split data : No
+
+ This file was generated by GBMB v1.8
+
+*/
+
+#define bigmap_mapWidth 247
+#define bigmap_mapHeight 66
+#define bigmap_mapBank 0
+
+#define bigmap_map bigmap_mapPLN0
+const unsigned char bigmap_mapPLN0[] =
+{
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x03,
+ 0x00,0x01,0x00,0x01,0x04,0x05,0x04,0x05,0x04,0x05,
+ 0x04,0x05,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x06,0x06,0x06,0x06,0x07,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x09,0x06,0x04,0x05,0x06,0x06,0x06,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x02,0x03,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 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B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x1B,0x1C,0x1F,0x1F,
+ 0x1F,0x20,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x10,0x11,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x12,0x13,0x00,0x01,0x00,0x01,0x06,0x06,
+ 0x06,0x06,0x04,0x05,0x04,0x05,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x02,0x03,0x00,0x01,0x00,0x01,0x06,0x06,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x0A,0x0B,0x06,0x06,
+ 0x06,0x06,0x14,0x15,0x16,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x09,0x06,0x06,0x04,0x05,
+ 0x06,0x06,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x30,0x3F,0x40,0x41,0x42,0x9B,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x17,0x18,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x0C,
+ 0x0D,0x0C,0x0D,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x02,0x03,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x0E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x0F,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,0x1F,0x1F,0x1F,0x1F,
+ 0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x20,0x0B,0x0A,0x0B,
+ 0x06,0x04,0x05,0x06,0x06,0x06,0x06,0x06,0x14,0x15,
+ 0x21,0x22,0x16,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x23,0x21,0x22,0x24,0x25,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x02,0x03,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x02,0x03,0x06,0x06,0x00,0x01,0x02,0x03,
+ 0x00,0x01,0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x12,0x13,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x39,0x14,0x15,
+ 0x24,0x25,0x9B,0x03,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x26,
+ 0x27,0x06,0x06,0x06,0x06,0x28,0x26,0x0A,0x0B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0A,0x00,0x01,0x10,0x11,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x12,0x13,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x1A,0x06,0x06,0x06,0x02,0x03,
+ 0x02,0x03,0x02,0x03,0x00,0x01,0x06,0x2B,0x06,0x06,
+ 0x06,0x06,0x2B,0x06,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x02,0x03,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x02,0x03,0x2C,0x06,0x06,0x06,0x12,0x13,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x2D,0x04,0x05,0x04,0x04,0x04,0x04,0x05,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x14,0x15,0x21,0x22,
+ 0x21,0x22,0x21,0x22,0x21,0x22,0x21,0x22,0x24,0x25,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,
+ 0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x02,0x03,0x02,0x03,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,0x06,0x06,
+ 0x00,0x01,0x12,0x13,0x00,0x01,0x12,0x13,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x03,
+ 0x06,0xD8,0xD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A,0x0B,0x0A,0x0B,0x06,0x06,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,0xD8,0xE1,
+ 0xE1,0xE1,0xE1,0xE2,0x06,0x06,0x06,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x00,0x01,0x06,0x06,
+ 0x10,0x11,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x02,0x03,0x02,0x03,0x33,0x19,
+ 0x34,0x06,0x06,0x06,0x06,0x06,0x12,0x13,0x00,0x01,
+ 0x06,0x35,0x36,0x36,0x36,0x36,0x2E,0x06,0x02,0x03,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x1B,0x1C,0x37,0x38,
+ 0x1D,0x1E,0x1D,0x1E,0x1D,0x1E,0x39,0x06,0x06,0x06,
+ 0x02,0x03,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x31,0x06,0x06,0x2D,0x12,0x13,0x04,0x05,0x04,
+ 0x05,0x06,0x06,0x06,0x06,0x05,0x05,0x0D,0x0C,0x05,
+ 0x04,0x06,0x06,0x06,0x06,0x06,0x04,0x05,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x0C,0x0D,0x04,0x05,
+ 0x0C,0x0D,0x04,0x05,0x06,0x06,0x02,0x03,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x02,0x03,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x02,0x03,0x02,0x03,0x06,0x31,
+ 0x06,0x06,0x02,0x03,0x02,0x03,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x12,0x13,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x02,0x03,0x44,0x45,0x06,0xD8,0x80,0x80,0x80,0x80,
+ 0xB6,0x06,0x06,0x06,0x02,0x03,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x0A,0x0B,0x06,0x06,0x17,0x18,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x06,0x06,0x06,0x06,0x3A,0x26,0x3B,0x06,0x06,
+ 0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x06,0x2F,0x36,
+ 0x36,0x36,0x36,0x2E,0x2F,0x06,0x06,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x29,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x3C,0x3D,0x3E,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x31,
+ 0x06,0x32,0x0A,0x0B,0x0C,0x0D,0x0C,0x0D,0x06,0x06,
+ 0x06,0x06,0x0D,0x0D,0x05,0x04,0x0D,0x0C,0x06,0x06,
+ 0x06,0x04,0x05,0x0C,0x0D,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x0C,0x0D,0x06,0x06,0x0C,
+ 0x0D,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,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06,0x06,0x06,0x06,0x48,0x49,0x4A,0x4B,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x04,0x05,0x04,0x05,
+ 0x06,0x06,0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x02,0x03,0x06,0x06,0x06,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,
+ 0x02,0x03,0x00,0x01,0x00,0x01,0x02,0x03,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x06,
+ 0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,
+ 0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x06,0x44,0x45,0x06,0x06,0x46,
+ 0x80,0x80,0x80,0x80,0xB6,0x06,0x06,0x06,0x44,0x45,
+ 0x02,0x03,0x00,0x01,0x02,0x03,0x00,0x0A,0x0B,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x4C,
+ 0x4D,0x4E,0x4F,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,
+ 0x06,0x06,0x2F,0x36,0x36,0x36,0x36,0x36,0x36,0x29,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x50,0x51,0x06,0x06,0x52,0x53,0x30,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x32,0x06,0x06,0x0C,0x0D,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x3F,0x40,0x54,0x55,0x54,0x55,0x54,0x55,
+ 0x55,0x56,0x57,0x58,0x59,0x55,0x55,0x54,0x55,0x54,
+ 0x55,0x41,0x42,0x0C,0x0D,0x0C,0x0D,0x04,0x05,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x06,0x06,0x06,0x06,0x06,0x12,0x13,0x02,0x03,
+ 0x02,0x03,0x02,0x03,0x12,0x13,0x06,0x06,0x06,0x0A,
+ 0x0B,0x0A,0x0B,0x06,0x31,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x06,0x50,0x51,0x06,0x06,0xDD,0xE1,0xE1,0xE1,
+ 0xE1,0xE2,0x06,0x06,0x31,0x50,0x51,0x06,0x06,0x0A,
+ 0x0B,0x06,0x06,0x0A,0x00,0x01,0x12,0x13,0x06,0x06,
+ 0x06,0x06,0x06,0x5A,0x19,0x19,0x19,0x19,0x1A,0x06,
+ 0x06,0x06,0x3F,0x40,0x54,0x55,0x5B,0x08,0x08,0x5C,
+ 0x02,0x03,0x02,0x03,0x02,0x03,0x06,0x06,0x06,0x35,
+ 0x36,0x36,0x36,0x36,0x36,0x36,0x2C,0x06,0x3F,0x40,
+ 0x54,0x55,0x41,0x42,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x2C,0x06,0x06,0x06,
+ 0x06,0x06,0x5D,0x5E,0x5F,0x60,0x61,0x62,0x06,0x06,
+ 0x06,0x06,0x2D,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x05,0x04,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x4C,
+ 0x4D,0x63,0x64,0x63,0x64,0x63,0x64,0x64,0x65,0x66,
+ 0x67,0x68,0x64,0x64,0x63,0x64,0x63,0x64,0x4E,0x09,
+ 0x06,0x06,0x04,0x05,0x0C,0x0D,0x06,0x06,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x03,0x06,0x31,
+ 0x06,0x06,0x06,0x0A,0x0B,0x06,0xA1,0xA2,0x06,0x06,
+ 0x06,0x0A,0x0B,0x06,0x06,0x06,0x02,0x03,0x02,0x03,
+ 0x06,0x06,0x06,0x06,0x12,0x13,0x12,0x13,0x12,0x13,
+ 0x12,0x13,0x12,0x13,0x06,0x06,0x31,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x02,0x03,0x02,0x03,
+ 0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,0x00,0x01,
+ 0x00,0x01,0x02,0x03,0x02,0x03,0x02,0x03,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x02,0x03,0x00,0x01,0x12,0x13,
+ 0x06,0x06,0x06,0x46,0x81,0x82,0x83,0x80,0xB6,0x06,
+ 0x06,0x06,0x06,0x06,0x44,0x45,0x00,0x01,0x06,0x06,
+ 0x02,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,
+ 0x69,0x26,0x26,0x26,0x26,0x27,0x06,0x06,0x06,0x4C,
+ 0x4D,0x63,0x64,0x6A,0x08,0x08,0x09,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x2F,0x36,0x36,0x36,
+ 0x36,0x36,0x36,0x30,0x06,0x4C,0x4D,0x63,0x64,0x4E,
+ 0x4F,0x06,0x06,0x06,0x6B,0x6C,0x6D,0x6C,0x6D,0x6C,
+ 0x6D,0x6C,0x6D,0x30,0x06,0x06,0x31,0x06,0x06,0x6E,
+ 0x6F,0x70,0x71,0x72,0x73,0x06,0x06,0x06,0x06,0x32,
+ 0x05,0x04,0x06,0x06,0x06,0x05,0x04,0x0D,0x0C,0x05,
+ 0x06,0x06,0x06,0x3F,0x40,0x55,0x5B,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x75,0x76,0x77,0x78,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x79,0x41,0x42,0x0C,
+ 0x0D,0x06,0x04,0x05,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x02,0x03,0x06,0xAF,0xB0,0x06,0x06,0x06,0x02,0x03,
+ 0x06,0x31,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x31,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,
+ 0x52,0x90,0x91,0x92,0x8F,0xC0,0x06,0x06,0x06,0x06,
+ 0x06,0x50,0x51,0x0A,0x0B,0x06,0x06,0x06,0x00,0x01,
+ 0x00,0x01,0x06,0x31,0x06,0x06,0x06,0x7A,0x06,0x06,
+ 0x5D,0x5E,0x5F,0x60,0x7B,0x7C,0x74,0x08,0x08,0x08,
+ 0x7D,0x7E,0x08,0x5C,0x5D,0x5E,0x5F,0x60,0x61,0x62,
+ 0x06,0x06,0x06,0x2F,0x7F,0x36,0x36,0x36,0x1B,0x1C,
+ 0x43,0x06,0x0E,0x08,0x08,0x08,0x08,0x0F,0x06,0x06,
+ 0x06,0x2D,0x80,0x81,0x82,0x83,0x80,0x81,0x80,0x81,
+ 0x2C,0x06,0x06,0x06,0x31,0x06,0x84,0x85,0x86,0x87,
+ 0x08,0x88,0x06,0x06,0x06,0x06,0x2D,0x0D,0x0C,0x04,
+ 0x05,0x06,0x0D,0x0C,0x05,0x04,0x0D,0x06,0x06,0x06,
+ 0x4C,0x4D,0x64,0x6A,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x75,0x76,0x77,0x78,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x89,0x4E,0x4F,0x06,0x06,0x06,0x0C,
+ 0x0D,0x06,0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x03,0x02,0x03,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x12,0x13,
+ 0x12,0x13,0x12,0x13,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x12,0x13,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,
+ 0x06,0x06,0x12,0x13,0x12,0x13,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x31,0x06,0x06,
+ 0x06,0x06,0x02,0x03,0x02,0x03,0x06,0x31,0x06,0x06,
+ 0x06,0x06,0x02,0x03,0x02,0x03,0x02,0x03,0x06,0x06,
+ 0x02,0x03,0x00,0x01,0x12,0x13,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x02,0x03,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x06,
+ 0x06,0x31,0x06,0x06,0x8A,0x06,0x06,0x6E,0x6F,0x70,
+ 0x8B,0x72,0x8C,0x07,0x08,0x08,0x08,0x8D,0x8E,0x08,
+ 0x09,0x6E,0x6F,0x70,0x71,0x72,0x73,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x36,0x36,0x29,0x06,0x06,0x06,0x14,
+ 0x15,0x08,0x08,0x24,0x25,0x06,0x06,0x06,0x32,0x8F,
+ 0x90,0x91,0x92,0x8F,0x90,0x8F,0x90,0x30,0x06,0x06,
+ 0x06,0x06,0x06,0x93,0x94,0x95,0x96,0x97,0x98,0x06,
+ 0x31,0x06,0x06,0x32,0x05,0x04,0x0C,0x0D,0x04,0x05,
+ 0x04,0x0D,0x0C,0x06,0x06,0x06,0x06,0x74,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x75,
+ 0x76,0x77,0x78,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x79,0x41,0x42,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x06,0x31,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0A,
+ 0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0A,
+ 0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x00,0x01,0x00,0x01,0x06,0x06,0x06,0x06,
+ 0x06,0x33,0x34,0x06,0x99,0x08,0x86,0x87,0x9A,0x88,
+ 0x0E,0x08,0x08,0x08,0x08,0x08,0x08,0x0F,0x84,0x85,
+ 0x86,0x87,0x08,0x88,0x06,0x06,0x31,0x06,0x06,0x06,
+ 0x7F,0x36,0x39,0x06,0x06,0x06,0x06,0x9B,0x9C,0x08,
+ 0x39,0x06,0x06,0x06,0x06,0x9B,0x9D,0x06,0x06,0x06,
+ 0x06,0x9E,0x9F,0xA0,0x2C,0x06,0x06,0x06,0x06,0x06,
+ 0xA1,0xA2,0x36,0x36,0x2E,0x06,0x06,0x06,0x06,0x06,
+ 0x2D,0x0D,0x0C,0x06,0x06,0x0C,0x0D,0x0C,0x05,0x04,
+ 0x06,0x06,0x06,0x06,0x0E,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x75,0xA3,0xA4,0x78,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x89,
+ 0x4E,0x4F,0x06,0x06,0x04,0x05,0x06,0x06,0x02,0x03,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x06,0x31,0x06,0x06,0x12,0x13,0x12,0x13,0x06,0x06,
+ 0x31,0x06,0x02,0x03,0x02,0x03,0x02,0x03,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x12,0x13,0x12,0x13,0x12,0x13,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x12,0x13,0x00,0x01,0x00,0x01,
+ 0x12,0x13,0x12,0x13,0x31,0x06,0x06,0x06,0x12,0x13,
+ 0x12,0x13,0x12,0x13,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x02,0x03,0x00,0x01,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x12,0x13,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0A,
+ 0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,0x3A,0x3B,
+ 0x06,0x93,0x94,0x95,0x96,0x97,0x98,0x14,0x15,0x21,
+ 0x22,0x21,0x22,0x24,0x25,0x93,0x94,0x95,0x96,0x97,
+ 0x98,0x31,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x3C,
+ 0x3D,0x6C,0x6D,0xA5,0xA6,0xA7,0xA8,0x3C,0x3D,0xA9,
+ 0xAA,0xA5,0xA6,0xAB,0x06,0x06,0x06,0x06,0xAC,0xAD,
+ 0xAE,0x30,0x06,0x06,0x06,0x06,0x06,0xAF,0xB0,0x36,
+ 0x36,0xB1,0x06,0x31,0x06,0x06,0x06,0x32,0x04,0x05,
+ 0x06,0x06,0x06,0x04,0x05,0x0D,0x0C,0x04,0x06,0x06,
+ 0x06,0x74,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x75,0xB2,0xB3,0x78,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x5C,0x06,
+ 0x06,0x0C,0x0D,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x31,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x12,0x13,0x12,
+ 0x13,0x12,0x13,0x12,0x13,0x0A,0x0B,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x00,0x01,0x02,0x03,
+ 0x06,0x06,0xB4,0xB5,0x5F,0x60,0x61,0x62,0xA1,0xA2,
+ 0x36,0x36,0x2E,0x06,0x12,0x13,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0xA1,0xA2,0x36,0x36,0x2E,0x06,0x06,0x31,
+ 0x06,0x5A,0x19,0x19,0x19,0x19,0x46,0x47,0x80,0x81,
+ 0x80,0xB6,0xB7,0xB8,0x46,0x47,0xB9,0xBA,0x80,0xB6,
+ 0x9D,0x06,0x06,0x06,0x06,0x9E,0x06,0x06,0x2C,0x06,
+ 0x06,0x06,0x12,0x13,0x06,0x35,0x36,0x36,0x2E,0x06,
+ 0x06,0x06,0x06,0x06,0x2D,0x0C,0x0D,0x06,0x06,0x06,
+ 0x0C,0x0D,0x05,0x04,0x0C,0x06,0x06,0x06,0x07,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x23,0xBB,
+ 0xBC,0xA3,0xA4,0xBD,0x22,0x22,0x22,0x16,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x09,0x06,0x04,0x05,0x04,
+ 0x05,0x06,0x06,0x06,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x06,0x06,0x12,0x13,0x00,0x01,
+ 0x00,0x01,0x12,0x13,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x12,0x13,0x12,0x13,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,
+ 0x12,0x13,0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,
+ 0x06,0x06,0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13,
+ 0x12,0x13,0x06,0x06,0x31,0x06,0x12,0x13,0x31,0x06,
+ 0x06,0x06,0x02,0x03,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,
+ 0x0A,0x0B,0x02,0x03,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x12,0x13,0x12,0x0A,0x0B,0x06,0x06,0x06,0x06,0xBE,
+ 0x6F,0x70,0x71,0x72,0x73,0xAF,0xB0,0x36,0x36,0xB1,
+ 0x06,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0xAF,
+ 0xB0,0x36,0x36,0xB1,0x06,0x06,0x06,0x06,0x69,0x26,
+ 0x26,0x26,0x26,0x52,0x53,0x8F,0x90,0xBF,0xC0,0xC1,
+ 0xC2,0x52,0x53,0xC3,0xC4,0xBF,0xC0,0xAB,0x06,0x06,
+ 0x06,0x06,0xAC,0x06,0x06,0x30,0x06,0x06,0x06,0x0A,
+ 0x0B,0x06,0x2F,0x36,0x36,0xB1,0x06,0x06,0x06,0x06,
+ 0x06,0x32,0x04,0x06,0x06,0x06,0x06,0x04,0x05,0x0D,
+ 0x0C,0x04,0x06,0x06,0x06,0x0E,0x08,0x08,0x08,0x08,
+ 0x08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06,0x2C,0x06,0x06,0x06,0x02,0x03,0x06,0x35,
+ 0x36,0x36,0x2E,0x06,0x06,0x06,0x06,0x06,0x2D,0x06,
+ 0x06,0x06,0x06,0x06,0x0C,0x0D,0x05,0x04,0x04,0x06,
+ 0x06,0x06,0x74,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x09,0x06,0x31,0x06,0x31,0x06,0x31,0x06,
+ 0x06,0x07,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x09,
+ 0x06,0x06,0x04,0x05,0x06,0x06,0x06,0x06,0x00,0x01,
+ 0x00,0x01,0x02,0x03,0x02,0x03,0x02,0x03,0x06,0x06,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,
+ 0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x03,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x02,0x03,0x02,0x03,0x12,0x13,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,0x06,0x06,
+ 0x00,0x01,0x12,0x13,0x06,0x06,0x06,0x06,0x0A,0x0B,
+ 0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x12,0x13,0x00,0x01,0x00,0x0A,0x0B,0x06,
+ 0x06,0x06,0x06,0x93,0x94,0x95,0x96,0x97,0x98,0x06,
+ 0x2F,0x36,0x36,0xB1,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x2F,0x36,0x36,0xB1,0x06,0x50,
+ 0x51,0x06,0x06,0x4C,0x4D,0x63,0x64,0x63,0x64,0x63,
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 0x06,0x35,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,
+ 0x2E,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x35,0x36,0x36,0x2E,0x06,0x06,0x06,0x06,0x06,
+ 0x74,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x5C,0x06,0x06,0x06,0xCD,0xCE,0x06,
+ 0x06,0x06,0x06,0x9E,0x06,0x06,0x2C,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x2D,0x06,0x06,0x06,0x06,0x0C,0x0D,0x0C,
+ 0x05,0x04,0x0C,0x06,0x06,0x06,0x74,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x5C,0x06,0x06,0x31,
+ 0x06,0x31,0x31,0x06,0x06,0x07,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x09,0x06,0x06,0x06,0x06,0x0C,0x0D,
+ 0x06,0x06,0x00,0x01,0x02,0x03,0x06,0x06,0x06,0x06,
+ 0x31,0x06,0x06,0x06,0x02,0x03,0x02,0x03,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x02,0x03,0x02,0x03,0x02,0x03,
+ 0x02,0x03,0x02,0x03,0x02,0x03,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x12,0x13,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x12,0x13,0x12,0x13,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x12,0x13,0x00,0x01,0x00,0x01,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x12,0x13,0x00,0x01,0x00,0x01,
+ 0x00,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,0x2F,0x36,
+ 0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x2E,0x2F,0x2E,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x2F,0x36,
+ 0x36,0x2E,0x2F,0x2E,0x06,0x06,0x06,0x74,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x09,0x06,0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,
+ 0xAC,0x06,0x06,0x30,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x32,
+ 0x06,0x06,0x06,0x06,0x06,0x04,0x05,0x0D,0x06,0x06,
+ 0x06,0x06,0x06,0x0E,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x09,0x06,0x06,0x31,0x31,0x06,0x06,
+ 0x06,0x06,0x74,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x4F,0x06,0x06,0x06,0x04,0x05,0x06,0x06,0x06,0x0A,
+ 0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x0A,0x0B,0x0B,0x0A,0x0A,0x0B,0x0B,0xCF,0xD0,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x7F,0x36,
+ 0x7F,0x36,0x36,0x36,0x36,0x36,0x2E,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x35,0x36,0x36,0x36,0x36,
+ 0x2E,0x06,0x06,0x06,0x07,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x5C,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x31,0x06,0x9E,0x06,0x06,
+ 0x2C,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x31,0x06,0x06,0x06,0x2D,0x06,0x06,0x06,
+ 0x06,0x06,0x0C,0x0D,0x06,0x06,0x06,0x31,0x06,0x06,
+ 0x74,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x79,0x41,0x42,0x06,0x06,0x31,0x06,0x3F,0x40,0x5B,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x5C,0x06,0x06,
+ 0x06,0x0C,0x0D,0x06,0x06,0x06,0x02,0x03,0x06,0x06,
+ 0x06,0x06,0x12,0x13,0x12,0x13,0x12,0x13,0x06,0x06,
+ 0x06,0x06,0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x03,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,0x12,0x13,
+ 0x12,0x13,0x12,0x13,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x12,0x13,0x12,0x13,0x31,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x12,0x13,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x5A,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x36,
+ 0x36,0x36,0x36,0xB1,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x2F,0x2E,0x2F,0x36,0x36,0x36,0x36,0xB1,0x06,0x06,
+ 0x06,0x74,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x09,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0xAC,0x06,0x06,0x30,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x32,0x06,0x06,0x06,0x06,0x06,0x05,
+ 0x04,0x05,0x04,0x06,0x06,0x31,0x06,0x07,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x89,0x4E,0x4F,
+ 0x06,0x06,0x06,0x06,0x4C,0x4D,0x6A,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x09,0x06,0x06,0x04,0x05,0x04,
+ 0x05,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0B,0x7A,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x2F,0x36,0x36,
+ 0x2E,0x06,0x06,0x06,0x06,0x06,0x36,0x36,0x36,0x36,
+ 0x36,0x36,0x36,0x7F,0xB1,0x06,0x06,0x06,0x07,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x5C,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0xD1,0xD2,0x04,0x05,0x2C,0x06,0x06,0x06,0x44,0x45,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x2D,0x06,0x06,0x06,0x06,0x04,0x0D,0x0C,0x0D,0x0C,
+ 0x06,0x06,0x06,0x06,0x74,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x79,0x54,0x55,0x54,
+ 0x55,0x5B,0x08,0x08,0x08,0x08,0x08,0x08,0x23,0x24,
+ 0x24,0x25,0x06,0x06,0x0C,0x0D,0x0C,0x0D,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x12,0x13,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x12,0x13,0x12,0x13,0x06,0x06,0x02,0x03,
+ 0x02,0x03,0x02,0x03,0x02,0x03,0x00,0x01,0x02,0x03,
+ 0x06,0x06,0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13,
+ 0x12,0x13,0x06,0x06,0x31,0x06,0x02,0x03,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x10,0x11,0x00,0x01,0x00,0x01,0x02,0x03,0x00,0x01,
+ 0x00,0x01,0x12,0x13,0x00,0x01,0x02,0x03,0x02,0x03,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,0x12,0x13,
+ 0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x8A,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x36,0x36,0x2E,0x2F,0x2E,
+ 0x2F,0x2E,0x2F,0x36,0x36,0x36,0x36,0x36,0x36,0xB1,
+ 0x06,0x06,0x06,0x06,0x06,0x0E,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x09,0x06,
+ 0x06,0x06,0xD3,0xD4,0xD5,0xD4,0xD5,0xD6,0xD7,0x0C,
+ 0x0D,0x30,0x06,0x06,0x06,0x50,0x51,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x32,0x06,0x06,
+ 0x06,0x06,0x0C,0x05,0x04,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x07,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x64,0x64,0x63,0x64,0x6A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06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x9B,0x06,0x06,0x06,0x06,0x06,
+ 0x0D,0x0C,0x06,0x06,0x06,0x06,0x06,0x06,0x0E,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x5C,0x06,0x06,0x06,0x06,0x0C,0x0D,0x0C,
+ 0x0D,0x06,0x06,0x06,0x12,0x13,0x12,0x13,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x12,0x13,0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x06,
+ 0x02,0x03,0x06,0x06,0x12,0x13,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,0x06,0x06,
+ 0x06,0x06,0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,
+ 0x02,0x03,0x00,0x01,0x12,0x13,0x00,0x01,0x00,0x01,
+ 0x12,0x13,0x00,0x01,0x02,0x03,0x02,0x03,0x02,0x03,
+ 0x06,0x06,0x31,0x06,0x02,0x03,0x02,0x03,0x02,0x03,
+ 0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x8A,0x06,0xAF,0xB0,0xAF,0xB0,0xAF,
+ 0xB0,0xAF,0xB0,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x2F,0x36,0x36,0xB1,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x4C,0x4D,0x63,0x64,0x6A,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x09,0x06,0x06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,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x3F,0x40,0x54,0x55,0x54,0x55,
+ 0x54,0x55,0x5B,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x79,
+ 0x41,0x42,0x06,0x06,0x04,0x05,0x04,0x05,0x3F,0x40,
+ 0x41,0x42,0xD8,0xD9,0xDA,0xD9,0xDA,0xD9,0xDB,0xDB,
+ 0xDB,0xDB,0xDB,0xDB,0xDB,0xDB,0xDB,0xDB,0xDC,0x31,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x31,0x06,0x06,0x06,0x07,0x08,0x08,0x08,0x7D,
+ 0x7E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x5C,0x06,0x06,0x06,0x06,0x06,
+ 0x0C,0x0D,0x06,0x06,0x06,0x06,0x12,0x13,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,0x12,0x13,
+ 0x12,0x13,0x06,0x06,0x06,0x06,0x06,0x06,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x12,0x13,0x06,0x06,0x31,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x10,0x11,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x03,0x06,0x5A,
+ 0x19,0x19,0x19,0x19,0x19,0x19,0x34,0x19,0x19,0x19,
+ 0x19,0x5A,0x06,0x06,0x06,0x06,0x02,0x03,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x02,0x03,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x03,
+ 0x00,0x01,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,0x26,0x26,0x26,0x26,0x69,0x06,
+ 0x31,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x54,0x55,0x54,0x55,0x54,0x55,
+ 0x54,0x55,0x54,0x55,0x54,0x55,0x54,0x55,0x54,0x55,
+ 0x54,0x56,0x57,0x58,0x59,0x55,0x54,0x55,0x5B,0x08,
+ 0x08,0x08,0x08,0x08,0x7D,0x7E,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x7D,0x7E,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x79,0x54,0x55,0x54,0x55,
+ 0x54,0x55,0x5B,0x08,0x08,0x5C,0x46,0x47,0x80,0x81,
+ 0x80,0x81,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
+ 0x80,0x80,0xB6,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x74,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x5C,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x04,0x05,0x06,0x06,0x06,0x06,0x06,0x06,0x12,0x13,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,0x12,0x13,
+ 0x12,0x13,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,
+ 0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13,0x06,0x06,
+ 0x06,0x06,0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,
+ 0x06,0x5A,0x19,0x7A,0x06,0x06,0x06,0x06,0x3F,0x40,
+ 0x41,0x42,0x12,0x13,0x06,0x7A,0x34,0x19,0x19,0x5A,
+ 0x06,0x06,0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x06,0x06,0x02,0x03,0x00,0x01,0x02,0x03,
+ 0x00,0x63,0x64,0x63,0x64,0x63,0x64,0x63,0x64,0x63,
+ 0x64,0x63,0x64,0x63,0x64,0x63,0x64,0x63,0x65,0x66,
+ 0x67,0x68,0xE4,0x63,0x64,0x6A,0x08,0x08,0x08,0x08,
+ 0x08,0x8D,0x8E,0x08,0x08,0x7D,0x7E,0x08,0x08,0x8D,
+ 0x8E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x89,0x63,0x64,0x63,0x64,0x63,0x64,0x6A,
+ 0x08,0x08,0x09,0x52,0x53,0x8F,0x90,0x8F,0x90,0xBF,
+ 0xBF,0xBF,0xBF,0xBF,0xBF,0xBF,0xBF,0xBF,0xBF,0xC0,
+ 0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x31,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x07,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x09,
+ 0x06,0x06,0x06,0x06,0x06,0x04,0x05,0x0C,0x0D,0x04,
+ 0x05,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x69,0x26,
+ 0x26,0x06,0x06,0x06,0x06,0x4C,0x4D,0x4E,0x4F,0x0A,
+ 0x0B,0x06,0x26,0x3B,0x26,0x26,0x7A,0x06,0x06,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,
+ 0x06,0x06,0x06,0x0A,0x0B,0x06,0x06,0x0A,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x75,0x76,0x77,0x78,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x8D,0x8E,0x08,0x08,0x08,0x08,0x08,0x7D,
+ 0x7E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x79,
+ 0x54,0x55,0x41,0x42,0x12,0x13,0x12,0x13,0x12,0x13,
+ 0x12,0x13,0x12,0x13,0x12,0x13,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x0E,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x5C,0x06,0x06,0x06,
+ 0x06,0x06,0x0C,0x0D,0x04,0x05,0x0C,0x0D,0x04,0x05,
+ 0x06,0x06,0x02,0x03,0x02,0x03,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,
+ 0x02,0x03,0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x12,0x13,0x06,0x06,0x06,0x06,0x06,0x5A,
+ 0x19,0x19,0x19,0x19,0x19,0x7A,0x06,0x06,0x3F,0x40,
+ 0x54,0x55,0x5B,0x08,0x08,0x5C,0x02,0x03,0x06,0x06,
+ 0x06,0x06,0x06,0x7A,0x06,0x06,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,0x06,0x06,
+ 0x00,0x01,0x12,0x13,0x00,0x08,0x08,0x7D,0x7E,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x75,0xA3,0xA4,0x78,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x8D,0x8E,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x89,0x63,0x64,0x4E,
+ 0x4F,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x06,0x06,0x31,0x06,0x06,0x06,0x06,
+ 0x31,0x06,0x06,0x06,0x06,0x06,0x3F,0x40,0x54,0x55,
+ 0x5B,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08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02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x4C,0x4D,0x63,0x64,0x6A,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x09,0x06,0x48,0x49,0x4A,0x4B,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x02,0x03,0x02,0x03,0x02,0x03,0x06,0x4C,0x4D,0x63,
+ 0x64,0x64,0x64,0x64,0x63,0x64,0x4E,0x4F,0x02,0x03,
+ 0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,
+ 0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x06,0x31,
+ 0x06,0x31,0x06,0x7A,0x06,0x06,0x5D,0x5E,0x5F,0x60,
+ 0x7B,0x7C,0x74,0x08,0x08,0x08,0x7D,0x7E,0x08,0x5C,
+ 0x06,0x06,0x06,0x0A,0x0B,0x06,0x06,0x7A,0x06,0x06,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x12,0x13,0x00,0x01,0x00,0x01,0x00,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0xBE,0x6F,0x70,0x71,0x72,
+ 0x73,0x21,0x22,0x21,0x22,0x21,0xBC,0xA3,0xA4,0xBD,
+ 0x22,0x16,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x7D,0x7E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x09,0x54,0x55,0x54,0x55,0x54,
+ 0x55,0x54,0x55,0x54,0x55,0x54,0x55,0x54,0x55,0x54,
+ 0x54,0x55,0x54,0x55,0x54,0x55,0x54,0x55,0x54,0x55,
+ 0x5B,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x79,0x41,0x56,
+ 0x57,0x58,0x59,0x55,0x54,0x55,0x54,0x55,0x54,0x55,
+ 0x54,0x54,0x55,0x54,0x55,0x54,0x55,0x54,0x55,0x54,
+ 0x55,0x54,0x55,0x55,0x5B,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x5C,0x55,0x55,0x54,0x55,0x41,
+ 0x42,0x06,0x06,0x06,0x06,0x31,0x06,0x31,0x06,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x31,0x06,0x06,
+ 0x8A,0x06,0x06,0x6E,0x6F,0x70,0x8B,0x72,0x8C,0x07,
+ 0x08,0x08,0x08,0x8D,0x8E,0x08,0x09,0x06,0x06,0x06,
+ 0x02,0x03,0x06,0x06,0x8A,0x06,0x06,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x1B,0x1C,0x1D,0x1E,
+ 0x1F,0x20,0x99,0x08,0x86,0x87,0x9A,0x88,0x1A,0x06,
+ 0x06,0x06,0x06,0xC5,0xC6,0xC7,0xC8,0x06,0x0E,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x8D,0x8E,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x64,0x63,0x64,0x64,0x63,0x64,0x63,0x64,
+ 0x63,0x64,0x63,0x64,0x63,0x64,0x63,0x63,0x64,0x63,
+ 0x64,0x63,0x64,0x63,0x64,0x63,0x64,0x6A,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x89,0x4E,0x65,0x66,0x67,0x68,
+ 0xE4,0x63,0x64,0x63,0x64,0x63,0x64,0x63,0x63,0x64,
+ 0x63,0x64,0x63,0x64,0x63,0x64,0x63,0x64,0x63,0x64,
+ 0x64,0x6A,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x64,0x64,0x64,0x63,0x64,0x4E,0x4F,0x06,0x44,
+ 0x45,0x31,0x06,0x31,0x06,0x06,0x02,0x03,0x02,0x03,
+ 0x02,0x03,0x02,0x03,0x02,0x03,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x03,
+ 0x02,0x03,0x06,0x06,0x06,0x06,0x06,0x33,0x06,0x06,
+ 0x99,0x08,0x86,0x87,0x9A,0x88,0x0E,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x5C,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x8A,0x06,0x06,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x29,0x06,0x06,0x06,0x06,0x2A,0x93,
+ 0x94,0x95,0x96,0x97,0x98,0x27,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x14,0x15,0xBB,0xE3,0xBB,
+ 0xE3,0xBB,0xE3,0xBB,0xE3,0xEB,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x75,0x76,0x77,0x78,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x5C,0x06,0x50,0x51,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,0x5A,0x19,
+ 0x19,0x06,0x06,0x06,0x33,0x06,0x06,0x93,0x94,0x95,
+ 0x96,0x97,0x98,0x0E,0x08,0x08,0x7D,0x7E,0x08,0x08,
+ 0x09,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x7A,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x43,0x06,0x12,0x13,0x06,0x2D,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x2B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13,
+ 0x12,0x13,0x0E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x7D,0x7E,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x75,0xA3,0xA4,0x78,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x09,0x31,0x06,0x06,0x06,0x06,0x31,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x02,0x03,0x06,0x06,0x06,0x69,0x26,0x7A,0x06,0x06,
+ 0x06,0x7A,0x06,0x06,0xA1,0xA2,0x36,0x36,0x2E,0x06,
+ 0x14,0x15,0x16,0x8D,0x8E,0x08,0x08,0x25,0xA1,0xA2,
+ 0x36,0x36,0x2E,0x06,0x06,0x8A,0x06,0x06,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x12,0x13,0x00,0x01,0x00,0x01,
+ 0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x06,0x06,0x0A,
+ 0x0B,0x06,0x32,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0xEC,0x06,0x06,0x06,0x06,0xD3,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x14,
+ 0x15,0x16,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x8D,0x8E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x7D,0x7E,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x75,0xB2,0xB3,
+ 0x78,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x5C,0x06,
+ 0x06,0x06,0x44,0x45,0x1B,0x1C,0x37,0x38,0x1D,0x1E,
+ 0x1D,0x1E,0x1D,0x1F,0x20,0x06,0x06,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x5A,
+ 0x19,0x19,0x7A,0x06,0x26,0x06,0x06,0x06,0x26,0x06,
+ 0x06,0xAF,0xB0,0x36,0x36,0xB1,0x06,0x06,0x06,0x0E,
+ 0x08,0x08,0x08,0x09,0x06,0xAF,0xB0,0x36,0x36,0xB1,
+ 0x06,0x06,0x8A,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x12,0x13,0x00,0x01,0x06,0x2D,
+ 0x19,0x19,0x19,0x19,0x34,0x06,0x06,0x06,0x06,0x06,
+ 0x9E,0x06,0x06,0x06,0x06,0xED,0x02,0x03,0x00,0x01,
+ 0x00,0x01,0x02,0x03,0x02,0x03,0x06,0x06,0x74,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x7D,0x7E,0x08,0x08,0x08,0x08,0x08,0x08,0x7D,
+ 0x7E,0x08,0x08,0x8D,0x8E,0x08,0x08,0x08,0x08,0x08,
+ 0x23,0xBB,0xE3,0xBB,0xE3,0xBB,0xE3,0xBB,0xE3,0x15,
+ 0xBB,0xE3,0xBB,0xE3,0xE3,0x22,0x21,0xBB,0xE3,0xE3,
+ 0xBB,0x22,0x21,0xE3,0xBB,0x22,0x21,0xBB,0xE3,0xBB,
+ 0xE3,0xBB,0xE3,0x15,0xBB,0xE3,0xBB,0xE3,0x22,0x21,
+ 0x22,0x21,0x22,0x21,0xBC,0xA3,0xA4,0xBD,0x22,0xE3,
+ 0x15,0xBB,0xE3,0xBB,0xE3,0x15,0x21,0x22,0x21,0x22,
+ 0x21,0x22,0x21,0x22,0x21,0x22,0x21,0x22,0x21,0x22,
+ 0x16,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x09,0x06,0x06,0x06,0x50,
+ 0x51,0x30,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x32,0x06,0x06,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x06,0x06,0x7A,0x26,0x26,0x26,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x35,
+ 0x36,0x36,0x2E,0x06,0x06,0x06,0x14,0xE3,0xE3,0x24,
+ 0x25,0x06,0x06,0x35,0x36,0x36,0x2E,0x06,0x06,0x8A,
+ 0x06,0x31,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0xA1,0xA2,0x00,0x01,0x00,0x01,
+ 0x00,0x0A,0x0B,0x0A,0x0B,0x06,0x32,0x26,0x26,0x26,
+ 0x26,0x3B,0x06,0x06,0x06,0x06,0x06,0xAC,0x06,0x06,
+ 0x06,0x06,0xEE,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x07,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x8D,0x8E,
+ 0x08,0x08,0x7D,0x7E,0x08,0x08,0x8D,0x8E,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x7D,0x7E,0x08,0x5C,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0xC5,0xC6,0xC7,0xC8,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x12,0x13,0x12,0x13,0x12,0x13,0x12,
+ 0x13,0x06,0x06,0x12,0x13,0x06,0x06,0x74,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x79,0x41,0x42,0x06,0x06,0x06,0x2C,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x2D,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x06,0x06,0x7A,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x2F,0x2E,0x06,0x36,0x36,0x36,
+ 0x2E,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x35,0x36,0x36,0x2E,0x06,0x06,0x7A,0x06,0x06,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0xAF,0xB0,0x0A,0x0B,0x0A,0x0B,0x0A,0x02,0x03,
+ 0x00,0x01,0x06,0x2D,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x9E,0x06,0x06,0x06,0x06,0xED,
+ 0x06,0x06,0x02,0x03,0x02,0x03,0x04,0x05,0x06,0x06,
+ 0x06,0x06,0x74,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x8D,
+ 0x8E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x8D,0x8E,0x08,0x09,0x06,0x06,0x06,0x12,0x13,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x31,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x31,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x06,
+ 0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,
+ 0x0A,0x0B,0x06,0x06,0x07,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x89,
+ 0x4E,0x4F,0x06,0x06,0x06,0x30,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x32,0x06,0x06,0x02,0x03,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x06,0x06,
+ 0x8A,0x06,0x06,0x06,0x06,0x44,0x45,0x06,0x06,0x35,
+ 0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x2E,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x35,0x36,0x36,0x36,0x36,0x36,
+ 0x36,0x2E,0x06,0x8A,0x06,0x06,0x00,0x01,0x00,0x01,
+ 0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x06,0x06,0x0A,0x0B,0x06,
+ 0x32,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0xAC,0x06,0x06,0x06,0x06,0xEE,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x0C,0x0D,0x06,0x06,0x06,0x06,0x07,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x23,0x21,0x22,0x22,
+ 0x24,0x25,0x06,0x06,0x06,0x0A,0x0B,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x31,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x31,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x02,0x03,0x00,
+ 0x01,0x00,0x01,0x00,0x01,0x12,0x13,0x00,0x01,0x06,
+ 0x06,0x74,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x4F,0x06,
+ 0x06,0x06,0x2C,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x9B,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x8A,0x06,0x31,
+ 0x06,0x06,0x50,0x51,0x06,0x06,0x2F,0x2E,0x2E,0x06,
+ 0x06,0x2F,0x36,0x36,0x36,0x36,0x2E,0x06,0x06,0x06,
+ 0x06,0x06,0x2F,0x36,0x36,0x36,0x36,0x36,0xB1,0x06,
+ 0x8A,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x06,0x06,0x02,0x03,0x06,0x2D,0x12,0x13,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x9D,0x06,
+ 0x06,0x06,0x06,0xCD,0x06,0x06,0x04,0x05,0x04,0x05,
+ 0x04,0x05,0x06,0x06,0x06,0x06,0x0E,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x5C,0x12,0x13,0x12,0x13,0x12,0x13,
+ 0x12,0x13,0x00,0x01,0x06,0x06,0x12,0x13,0x06,0x06,
+ 0x06,0x31,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x31,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x04,0x06,
+ 0x06,0x06,0x06,0x04,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x31,0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,
+ 0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x07,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x4F,0x06,0x06,0x06,0x30,
+ 0x06,0x06,0x6B,0x6C,0x6D,0x6C,0x6D,0x6C,0x6D,0xA6,
+ 0x06,0x06,0x06,0x06,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x06,0x06,0x33,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x36,0x36,0x36,0x2E,0x06,0x06,0x06,0x06,0x2F,0x36,
+ 0x2F,0x36,0x36,0x36,0x2E,0x06,0x06,0x7A,0x06,0x06,
+ 0x00,0x01,0x00,0x01,0x12,0x13,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x06,
+ 0x06,0x06,0x06,0x06,0x32,0x0A,0x0B,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0xAB,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x0C,0x0D,0x0C,0x0D,0x0C,0x0D,0x06,
+ 0x06,0x06,0x06,0x14,0x15,0x16,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x09,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x06,0x06,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x31,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x05,
+ 0x04,0x05,0x04,0x05,0x04,0x04,0x06,0x06,0x05,0x04,
+ 0x0C,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x31,0x06,
+ 0x06,0x06,0x06,0x00,0x01,0x00,0x01,0x00,0x01,0x00,
+ 0x01,0x00,0x01,0x06,0x06,0x0E,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x4F,0x06,0x06,0x06,0x2C,0x06,0x06,0x2D,
+ 0x80,0x81,0x82,0x83,0x80,0x81,0xDC,0x06,0x06,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,
+ 0x06,0x7A,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x31,
+ 0x06,0x06,0x06,0x06,0x12,0x13,0x35,0x36,0x36,0x2E,
+ 0x06,0x12,0x13,0x06,0x06,0x06,0x2F,0x36,0x36,0x36,
+ 0x36,0xB1,0x06,0x06,0x8A,0x06,0x31,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x02,0x03,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x06,0x06,0x06,0x06,
+ 0x06,0x9B,0x00,0x01,0x12,0x13,0x06,0x06,0x06,0xCD,
+ 0xEF,0xF0,0xCE,0x06,0x06,0x06,0x04,0x05,0x04,0x05,
+ 0x12,0x13,0x04,0x05,0x04,0x05,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x0E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x0F,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,
+ 0x00,0x01,0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x31,0x06,0x06,0x06,0x06,0x0D,0x0C,0x0D,0x0C,
+ 0x0D,0x0C,0x06,0x06,0x06,0x0D,0x0C,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x02,0x03,0x02,0x03,
+ 0x06,0x06,0x14,0x15,0x16,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x4F,
+ 0x06,0x06,0x06,0x30,0x06,0x06,0x32,0x8F,0x90,0x91,
+ 0x92,0x8F,0x8F,0x90,0x06,0x06,0x12,0x13,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x06,0x06,0x8A,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x0A,0x0B,0x2F,0x36,0x36,0xB1,0x06,0x0A,0x0B,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x7A,0x06,0x06,0x00,0x01,0x00,0x01,0x02,0x03,
+ 0x06,0x06,0x00,0x01,0x02,0x03,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x6C,0x6D,0x6C,0x6D,0xA5,0xA6,0x0A,
+ 0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x0C,0x0D,0x0C,0x0D,0x0A,0x0B,0x0C,
+ 0x0D,0x0C,0x0D,0x06,0x06,0x06,0x06,0x06,0x06,0x14,
+ 0x15,0x21,0x22,0x16,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x23,0x21,0x22,0x24,0x25,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x05,0x04,0x05,0x04,0x04,0x05,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x04,0x05,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x02,0x03,0x02,
+ 0x03,0x02,0x03,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x0E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x4F,0x06,0x06,0x06,
+ 0x2C,0x06,0x06,0x32,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x06,0x06,0x7A,0x06,0xA1,0xA2,0xA1,
+ 0xA2,0xA1,0xA2,0xA1,0xA2,0x06,0x06,0x06,0x02,0x03,
+ 0x35,0x36,0x36,0x2E,0x06,0x02,0x03,0x06,0xA1,0xA2,
+ 0xA1,0xA2,0xA1,0xA2,0xA1,0xA2,0x06,0x06,0x8A,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x0A,
+ 0x0B,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x80,0x81,0x80,0x81,0x80,0xB6,0x00,0x01,0x00,0x01,
+ 0x12,0x13,0x12,0x13,0x12,0x13,0x04,0x05,0x04,0x05,
+ 0x04,0x05,0x12,0x13,0x02,0x03,0x04,0x05,0x04,0x05,
+ 0x04,0x05,0x06,0x06,0x44,0x45,0x12,0x13,0x06,0x06,
+ 0x0E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x0F,0x12,0x13,
+ 0x12,0x13,0x00,0x01,0x02,0x03,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x03,
+ 0x00,0x01,0x00,0x01,0x12,0x13,0x12,0x13,0x12,0x13,
+ 0x12,0x13,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0D,
+ 0x0C,0x0D,0x04,0x0C,0x0D,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x12,0x13,0x0C,0x0D,0x04,0x04,0x05,0x04,0x05,
+ 0x12,0x13,0x12,0x13,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x31,0x06,0x06,0x06,0x06,0x06,0x06,0x14,0x15,
+ 0x21,0x22,0x16,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x4F,0x06,0x06,0x06,0x30,0x06,0x06,
+ 0x32,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x00,0x01,0x00,0x01,0x00,0x01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x06,0x07,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x79,0x41,0x41,0x41,0x2C,0x06,0x06,0x2D,0x41,0x41,
+ 0x42,0x06,0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x33,
+ 0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,
+ 0x19,0x19,0x19,0x28,0x06,0x06,0x06,0x06,0x06,0x28,
+ 0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,
+ 0x19,0x19,0x8A,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x06,0x06,0x12,0x13,0x06,0x06,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x1B,0x1C,
+ 0x1D,0x1E,0x1D,0x1E,0x1D,0x1E,0x1F,0x20,0x04,0x05,
+ 0x04,0x05,0x04,0x05,0x04,0x05,0x12,0x13,0x12,0x13,
+ 0x02,0x03,0x12,0x13,0x06,0x06,0x12,0x13,0x12,0x13,
+ 0x12,0x13,0x12,0x13,0x06,0x06,0x12,0x13,0x06,0x06,
+ 0x12,0x13,0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,
+ 0x10,0x11,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x12,0x13,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,0x12,0x13,
+ 0x06,0x06,0x04,0x05,0x04,0x05,0x04,0x0C,0x06,0x06,
+ 0x06,0x06,0x0D,0x0C,0x0D,0x00,0x01,0x0A,0x0B,0x04,
+ 0x04,0x05,0x04,0x05,0x00,0x01,0x00,0x01,0x12,0x13,
+ 0x12,0x13,0x12,0x13,0x06,0x06,0x12,0x13,0x12,0x13,
+ 0x06,0x06,0x31,0x06,0x06,0x06,0x0E,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x30,0x06,0x06,0x32,0x4E,0x4E,0x4F,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x06,0x06,0x26,0x26,0x26,0x26,
+ 0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,
+ 0x26,0x06,0x06,0x06,0x06,0x06,0x26,0x26,0x26,0x26,
+ 0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,
+ 0x06,0x06,0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x03,
+ 0x02,0x03,0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x06,0x06,0x0A,0x0B,0x06,0x06,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x29,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x2A,0x0C,0x0D,0x0C,0x0D,0x0C,
+ 0x0D,0x0C,0x0D,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0A,
+ 0x0B,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x06,0x06,0x0A,0x0B,0x06,0x06,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x12,0x13,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x04,0x0C,
+ 0x0D,0x0C,0x0D,0x0C,0x04,0x05,0x06,0x06,0x04,0x05,
+ 0x12,0x13,0x0A,0x0B,0x00,0x01,0x0C,0x0C,0x0D,0x0C,
+ 0x0D,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x74,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x2C,0x06,
+ 0x06,0x2D,0x08,0x08,0x5C,0x06,0x06,0x06,0x06,0x12,
+ 0x13,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x12,0x13,
+ 0x02,0x03,0x44,0x45,0x10,0x11,0x00,0x01,0x00,0x01,
+ 0x02,0x03,0x2C,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x2D,0x04,0x05,0x04,0x05,0x12,0x13,0x12,0x13,
+ 0x00,0x01,0x00,0x01,0x12,0x13,0x00,0x01,0x12,0x13,
+ 0x02,0x03,0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,
+ 0x00,0x01,0x12,0x13,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x0A,0x0B,0x02,0x03,0x10,0x11,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x06,0x0C,0x04,0x05,0x12,0x13,
+ 0x04,0x0C,0x0D,0x06,0x06,0x0C,0x0D,0x0A,0x0B,0x10,
+ 0x11,0x0A,0x0B,0x04,0x04,0x05,0x04,0x05,0x10,0x11,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x12,0x13,
+ 0x00,0x01,0x00,0x01,0x12,0x13,0x06,0x06,0x06,0x06,
+ 0x07,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x30,0x06,0x06,0x32,0x08,
+ 0x08,0x09,0x06,0x06,0x06,0x06,0x0A,0x0B,0x02,0x03,
+ 0x02,0x03,0x02,0x03,0x00,0x01,0x00,0x01,0x12,0x13,
+ 0x12,0x13,0x06,0x06,0x06,0x06,0x06,0x06,0x12,0x13,
+ 0x12,0x13,0x12,0x13,0x12,0x13,0x06,0x06,0x06,0x06,
+ 0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13,
+ 0x12,0x13,0x12,0x13,0x12,0x13,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x02,0x03,0x06,0x06,0x06,0x06,0x06,0x06,0x02,0x03,
+ 0x00,0x01,0x00,0x01,0x00,0x0A,0x0B,0x06,0x06,0x50,
+ 0x51,0x17,0x18,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x30,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x32,0x0C,
+ 0x0D,0x0C,0x0D,0x0A,0x0B,0x0A,0x0B,0x0A,0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x06,0x12,0x13,0x06,0x06,0x06,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x02,0x03,0x06,0x06,0x06,0x06,0x31,0x06,
+ 0x02,0x03,0x02,0x03,0x12,0x13,0x39,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x9B,0x04,0x05,0x04,0x05,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x12,0x13,0x00,0x01,0x10,0x11,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x03,
+ 0x02,0x03,0x02,0x03,0x00,0x01,0x00,0x01,0x0A,0x0B,
+ 0x0A,0x0B,0x06,0x06,0x02,0x03,0x02,0x03,0x02,0x03,
+ 0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,
+ 0x02,0x03,0x02,0x03,0x00,0x01,0x00,0x01,0x06,0x04,
+ 0x04,0x05,0x00,0x01,0x04,0x0C,0x0D,0x0C,0x0C,0x0D,
+ 0x0C,0x0D,0x0D,0x06,0x06,0x17,0x18,0x04,0x04,0x05,
+ 0x04,0x05,0x04,0x05,0x02,0x03,0x02,0x03,0x02,0x03,
+ 0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x00,0x01,
+ 0x12,0x13,0x06,0x06,0x07,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x09,0x06,0x30,
+ 0x06,0x06,0x9B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x31,0x06,0x50,0x51,0x06,0x02,0x03,
+ 0x02,0x03,0x02,0x03,0x02,0x03,0x0A,0x0B,0x0A,0x0B,
+ 0x0A,0x0B,0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,
+ 0x06,0x06,0x06,0x06,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x02,0x03,0x00,0x01,0x06,0x06,0x06,0x06,0x06,0x0A,
+ 0x0B,0x06,0x06,0x06,0x00,0x01,0x00,0x01,0x00,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,
+ 0x06,0x0A,0x0B,0x3C,0x3D,0x3E,0x06,0x06,0x06,0x06,
+ 0x6B,0xA5,0xA6,0x0C,0x0D,0x0C,0x0D,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x17,0x18,0x0A,0x0B,0x02,
+ 0x03,0x02,0x03,0x02,0x03,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x00,0x01,0x00,0x01,0x12,
+ 0x13,0x12,0x13,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x06,0x0C,0x0C,0x0D,0x0A,
+ 0x0B,0x0C,0x04,0x05,0x04,0x05,0x04,0x05,0x04,0x05,
+ 0x04,0x05,0x04,0x05,0x04,0x0C,0x0D,0x0C,0x0D,0x0C,
+ 0x0D,0x06,0x06,0x06,0x06,0x06,0x06,0x02,0x03,0x00,
+ 0x01,0x00,0x01,0x00,0x01,0x0A,0x0B,0x0A,0x0B,0x06,
+ 0x06,0x0E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x09,0x06,0x2C,0x06,0x06,0x06,
+ 0x1D,0x1E,0x1D,0x1F,0x20,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x02,0x03,0x02,0x03,0x02,0x03,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0A,
+ 0x0B,0x06,0x06,0x06,0x06,0x06,0x02,0x03,0x06,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x06,0x06,0x12,0x13,
+ 0x06,0x06,0x12,0x13,0x06,0x06,0x06,0x06,0x02,0x03,
+ 0x46,0x47,0x39,0x06,0x06,0x06,0x06,0x9B,0x80,0xB6,
+ 0x04,0x05,0x04,0x05,0x10,0x11,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x10,0x11,0x12,0x13,0x02,0x03,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x12,0x13,0x06,0x06,0x02,0x03,
+ 0x02,0x03,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x02,0x03,
+ 0x02,0x03,0x06,0x04,0x04,0x05,0x10,0x11,0x04,0x0C,
+ 0x0D,0x0C,0x0D,0x0C,0x0D,0x0C,0x0D,0x06,0x06,0x06,
+ 0x0D,0x04,0x04,0x05,0x04,0x05,0x04,0x05,0x04,0x05,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,
+ 0x0A,0x0B,0x00,0x01,0x00,0x01,0x06,0x06,0x74,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x09,0x06,0x30,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x32,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x12,0x13,0x00,0x01,0x12,0x13,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x00,0x01,
+ 0x00,0x01,0x00,0x06,0x06,0x0A,0x0B,0x06,0x06,0x0A,
+ 0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x52,0x53,0x3C,
+ 0x3D,0x6C,0x6D,0xA5,0xA6,0xBF,0xC0,0x0C,0x0D,0x0C,
+ 0x0D,0x17,0x18,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x17,0x18,0x0A,
+ 0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x02,
+ 0x03,0x02,0x03,0x02,0x03,0x02,0x03,0x06,0x06,0x06,
+ 0x06,0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13,0x12,
+ 0x13,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x0C,0x0C,0x0D,0x17,0x18,0x0C,0x04,0x05,0x05,0x04,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0C,0x0C,
+ 0x0D,0x0C,0x0D,0x0C,0x0D,0x0C,0x0D,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x02,0x03,0x02,0x03,0x02,0x03,0x0A,
+ 0x0B,0x0A,0x0B,0x06,0x06,0x07,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x09,0x06,
+ 0x39,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x32,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x31,0x06,0x06,0x06,0x06,0x06,0x31,0x06,0x06,
+ 0x06,0x06,0x06,0x12,0x13,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x31,0x06,0x02,0x03,0x06,0x06,0x02,0x03,0x06,0x06,
+ 0x12,0x13,0x06,0x06,0x06,0x06,0x46,0x47,0x80,0x81,
+ 0x80,0xB6,0x44,0x45,0x04,0x05,0x04,0x05,0x04,0x05,
+ 0x02,0x03,0x02,0x03,0x02,0x03,0x0A,0x0B,0x0A,0x0B,
+ 0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x02,0x03,0x06,0x06,
+ 0x06,0x06,0x12,0x13,0x12,0x13,0x12,0x13,0x00,0x01,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,
+ 0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x04,0x05,
+ 0x04,0x05,0x04,0x0C,0x0D,0x0D,0x0C,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x00,0x01,0x00,0x01,
+ 0x06,0x06,0x74,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x09,0x06,0x39,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x9B,0x06,0x06,0x12,0x13,
+ 0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13,
+ 0x06,0x06,0x06,0x06,0x12,0x13,0x12,0x13,0x12,0x13,
+ 0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13,0x12,0x13,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x12,0x13,0x06,0x06,0x12,0x13,
+ 0x12,0x13,0x00,0x01,0x00,0x01,0x00,0x06,0x31,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x06,
+ 0x06,0x06,0x06,0x52,0x53,0x8F,0x90,0xBF,0xC0,0x50,
+ 0x51,0x0C,0x0D,0x0C,0x0D,0x0C,0x0D,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x02,0x03,0x00,0x01,0x00,0x01,0x00,
+ 0x01,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x12,
+ 0x13,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x10,0x11,0x00,0x01,0x00,
+ 0x01,0x00,0x01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,0x06,0x06,0x02,0x03,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x12,0x13,0x0A,0x0B,0x12,0x13,
+ 0x12,0x13,0x12,0x13,0x12,0x13,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x17,0x18,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,
+ 0x0A,0x0B,0x06,0x06,0x12,0x13,0x12,0x13,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x31,
+ 0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x12,0x13,0x12,0x13,0x06,0x06,0x12,0x13,
+ 0x00,0x01,0x02,0x03,0x06,0x06,0x0E,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x09,
+ 0x06,0x46,0x47,0x81,0x80,0x81,0x81,0x80,0x81,0xDC,
+ 0x12,0x13,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x12,0x13,0x12,0x13,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x12,0x13,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0C,0x0D,0x0C,0x0D,0x0C,0x0D,0x0C,
+ 0x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+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x06,0x06,
+ 0x06,0x06,0x31,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x06,0x06,0x04,0x05,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x12,0x13,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x02,0x03,0x02,0x03,0x02,0x03,0x00,0x01,
+ 0x06,0x06,0x02,0x03,0x02,0x03,0x02,0x03,0x02,0x03,
+ 0x0A,0x0B,0x06,0x06,0x06,0x06,0x0A,0x0B,0x06,0x06,
+ 0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x02,0x03,
+ 0x02,0x03,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x05,0x04,0x05,0x05,0x04,0x05,
+ 0x04,0x05,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x05,0x04,0x05,0x00,0x01,0x00,0x01,
+ 0x06,0x06,0x00,0x01,0x00,0x01,0x12,0x13,0x12,0x13,
+ 0x07,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x08,0x08,0x08,0x09,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x12,0x13,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x02,0x03,
+ 0x02,0x03,0x02,0x03,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x02,0x03,0x02,0x03,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
+ 0x00,0x01,0x00,0x01,0x00,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x31,0x06,0x06,0x06,0x06,
+ 0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0C,
+ 0x0D,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x00,0x01,0x12,
+ 0x13,0x06,0x06,0x02,0x03,0x06,0x06,0x02,0x03,0x02,
+ 0x03,0x02,0x03,0x00,0x01,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x05,0x04,0x05,
+ 0x04,0x05,0x0C,0x0C,0x0D,0x0C,0x0D,0x0C,0x0C,0x05,
+ 0x04,0x05,0x06,0x06,0x06,0x06,0x06,0x05,0x04,0x05,
+ 0x05,0x04,0x05,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x74,0x08,0x08,
+ 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+ 0x5C,0x06,0x06,0x06,0x06,0x06,0x06,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
+ 0x06,0x06,0x06,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,0x0B,0x0A,
+ 0x0B,0x0A
+};
+
+/* End of BIGMAP_MAP.C */
diff --git a/gbdk/gbdk-lib/examples/gb/large_map/bigmap_map.h b/gbdk/gbdk-lib/examples/gb/large_map/bigmap_map.h
new file mode 100644
index 00000000..4ab64633
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/large_map/bigmap_map.h
@@ -0,0 +1,32 @@
+/*
+
+ BIGMAP_MAP.H
+
+ Map Include File.
+
+ Info:
+ Section :
+ Bank : 0
+ Map size : 247 x 66
+ Tile set : bigmap_tiles.gbr
+ Plane count : 1 plane (8 bits)
+ Plane order : Planes are continues
+ Tile offset : 0
+ Split data : No
+
+ This file was generated by GBMB v1.8
+
+*/
+#ifndef __bigmap_map_h_INCLUDE
+#define __bigmap_map_h_INCLUDE
+
+#define bigmap_mapWidth 247
+#define bigmap_mapHeight 66
+#define bigmap_mapBank 0
+
+#define bigmap_map bigmap_mapPLN0
+extern const unsigned char bigmap_mapPLN0[];
+
+#endif
+
+/* End of BIGMAP_MAP.H */
diff --git a/gbdk/gbdk-lib/examples/gb/large_map/bigmap_tiles.c b/gbdk/gbdk-lib/examples/gb/large_map/bigmap_tiles.c
new file mode 100644
index 00000000..6cef85df
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/large_map/bigmap_tiles.c
@@ -0,0 +1,512 @@
+/*
+
+ BIGMAP_TILES.C
+
+ Tile Source File.
+
+ Info:
+ Form : All tiles as one unit.
+ Format : Gameboy 4 color.
+ Compression : None.
+ Counter : None.
+ Tile size : 8 x 8
+ Tiles : 0 to 240
+
+ Palette colors : Included.
+ SGB Palette : None.
+ CGB Palette : None.
+
+ Convert to metatiles : No.
+
+ This file was generated by GBTD v2.2
+
+*/
+
+/* Start of tile array. */
+const unsigned char bigmap_tiles[] =
+{
+ 0x5C,0x63,0x33,0x3C,0x2D,0x10,0x5A,0x20,
+ 0xDD,0x20,0xBF,0x40,0xBF,0x40,0x1B,0x64,
+ 0x02,0xFE,0xCC,0x3C,0x74,0x08,0xFA,0x04,
+ 0xFB,0x04,0xFB,0x06,0xD3,0x2E,0xC6,0x3E,
+ 0x5C,0x63,0x3B,0x37,0x3C,0x0F,0x6F,0x18,
+ 0xCD,0x3A,0xC9,0x3E,0x3C,0x03,0x0F,0x00,
+ 0x02,0xFE,0xCC,0xFC,0x7C,0xF0,0x76,0xF8,
+ 0x73,0xFC,0x73,0xFC,0x3C,0xC0,0xF0,0x00,
+ 0x00,0x22,0x14,0x41,0x22,0x49,0x1C,0x22,
+ 0x00,0x00,0x00,0x44,0x28,0x82,0x44,0x92,
+ 0x00,0x00,0x00,0x22,0x14,0x41,0x22,0x49,
+ 0x1C,0x22,0x00,0x00,0x00,0x44,0x28,0x82,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x17,0x10,0x17,0x30,0x67,0x10,0x77,0x08,
+ 0x3B,0x08,0x0B,0x38,0x7B,0x18,0xE7,0x30,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0xFC,0x0E,0xF4,0x06,0xF7,0x08,0xEB,0x0C,
+ 0xE0,0x0E,0xEC,0x10,0xE6,0x18,0xE0,0x0C,
+ 0x63,0x9C,0x7D,0x82,0x7E,0x81,0xBB,0xC4,
+ 0xCF,0xFC,0x87,0xFC,0x82,0xFF,0x48,0x77,
+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+ 0x00,0x00,0x0C,0x00,0x0E,0x01,0x06,0x09,
+ 0x01,0x1F,0x32,0x0E,0x1D,0x04,0x0E,0x1D,
+ 0x30,0x00,0x70,0x00,0x62,0x90,0x97,0xF8,
+ 0x9D,0x9A,0x6B,0x0F,0x10,0xE0,0x07,0xF8,
+ 0x00,0x00,0x00,0x00,0x06,0x80,0x07,0x88,
+ 0xCB,0x8C,0xED,0x9F,0x30,0x58,0xC4,0x73,
+ 0x0C,0x00,0x1C,0x00,0x58,0xE0,0x60,0xF8,
+ 0x80,0x8E,0x31,0x84,0x1F,0x68,0x0E,0xFC,
+ 0x40,0xE0,0xE0,0x90,0x70,0x80,0x30,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,
+ 0x04,0x00,0x0B,0x00,0x1C,0x18,0x1D,0x12,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x00,
+ 0x20,0x00,0xD0,0x00,0x30,0x10,0xD0,0x30,
+ 0xEB,0x5C,0xF1,0x3E,0xE3,0x3C,0xF7,0x28,
+ 0xFF,0x20,0xFB,0x44,0xFF,0x44,0xFF,0x44,
+ 0xF0,0x0F,0xE0,0x1F,0xE1,0x1E,0x47,0xBC,
+ 0x07,0xFC,0x8B,0x7C,0x99,0x76,0x9B,0x66,
+ 0x00,0x0F,0x00,0x30,0x00,0x40,0x03,0x40,
+ 0x3E,0x21,0x3B,0x3C,0x1D,0x13,0x1F,0x14,
+ 0x00,0x00,0x00,0x80,0x00,0x80,0x80,0x80,
+ 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
+ 0x00,0x00,0x00,0x01,0x00,0x01,0x01,0x01,
+ 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
+ 0x00,0xF8,0x00,0x0C,0x00,0x02,0xC0,0x02,
+ 0x78,0x84,0xDC,0x3C,0xB8,0xC8,0xF8,0x28,
+ 0x48,0x3B,0x14,0x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xF0,0x30,0x70,0x30,0x62,0x30,0x76,0x38,
+ 0x6D,0x3B,0x6A,0x2E,0x71,0x20,0x64,0x3B,
+ 0x00,0x00,0x00,0x00,0x38,0x00,0x44,0x00,
+ 0xBA,0x00,0xC6,0x82,0xDA,0xA6,0xFB,0xAF,
+ 0x77,0x10,0x37,0x30,0xA3,0x34,0xCB,0x64,
+ 0x93,0x8C,0x47,0x38,0x87,0x78,0x17,0xE8,
+ 0xE0,0x0C,0xCC,0x10,0xF8,0x24,0xD0,0x18,
+ 0xA0,0x4C,0x93,0x64,0x97,0x68,0xDE,0x28,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x03,0x00,0x0D,0x00,0x31,0x00,0xD1,0x00,
+ 0x03,0x00,0x0D,0x00,0x31,0x00,0xD1,0x00,
+ 0x11,0x00,0x01,0x00,0x01,0x00,0x11,0x00,
+ 0xFF,0x00,0x10,0x00,0x10,0x00,0x00,0x00,
+ 0x10,0x00,0x00,0x00,0x10,0x00,0x10,0x00,
+ 0xFF,0x00,0x08,0x00,0x08,0x00,0x08,0x00,
+ 0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,
+ 0xC0,0x00,0xF0,0x00,0xAC,0x00,0xDF,0x00,
+ 0xAA,0x00,0xDD,0x00,0xAA,0x00,0xDD,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xC0,0x00,0xF0,0x00,0xAC,0x00,0xDF,0x00,
+ 0x40,0xBF,0xEE,0x11,0xFF,0x00,0xFF,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0x38,0xC7,0x00,0xFF,0xC7,0x38,0xFF,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0x3D,0xC4,0x05,0xFC,0xC5,0x3C,0xFD,0x04,
+ 0xFD,0x04,0xFD,0x04,0xFD,0x04,0xFD,0x04,
+ 0xC0,0xFF,0xFF,0x80,0x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0x33,0xCE,0x33,0xCE,0x33,0xCE,0x33,0xCE,
+ 0x97,0xEE,0xCF,0x3C,0xFE,0x00,0x7C,0x00,
+ 0x04,0xFB,0x03,0xFC,0x00,0xFF,0x10,0xEF,
+ 0x90,0x6F,0x52,0x8C,0x7F,0x80,0x47,0x80,
+ 0xA0,0x5F,0xC0,0x3F,0x00,0xFF,0x04,0xFB,
+ 0x0D,0xF2,0x4A,0x31,0xFE,0x01,0xE2,0x01,
+ 0xF8,0x40,0x78,0xC0,0xF8,0x80,0xF0,0x80,
+ 0xF0,0x00,0xE0,0x00,0xC0,0x00,0x00,0x00,
+ 0x02,0x03,0x02,0x03,0x06,0x03,0x07,0x01,
+ 0x07,0x01,0x03,0x00,0x01,0x00,0x00,0x00,
+ 0x1F,0x10,0x1F,0x10,0x0F,0x09,0x02,0x0F,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xC0,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x03,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xF8,0x08,0xF8,0x08,0xF0,0x90,0x40,0xF0,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x02,0x80,0x07,0x80,0x08,0x80,0x70,0x80,
+ 0x3C,0x80,0x07,0x80,0x78,0x00,0xFF,0x00,
+ 0x40,0x01,0xE0,0x01,0x10,0x01,0x0E,0x01,
+ 0x3C,0x01,0xE0,0x01,0x1E,0x00,0xFF,0x00,
+ 0xBF,0x00,0xCF,0x00,0xF0,0x00,0xFF,0x00,
+ 0x7F,0x00,0xFF,0x00,0xFE,0x00,0xFF,0x00,
+ 0xFD,0x00,0xF3,0x00,0x0F,0x00,0xFF,0x00,
+ 0xFE,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0x16,0x08,0x14,0x08,0x01,0x0C,0x11,0x06,
+ 0x02,0x01,0x05,0x00,0x03,0x00,0x05,0x00,
+ 0x68,0x10,0x28,0x10,0x80,0x30,0x88,0x60,
+ 0x40,0x80,0xA0,0x00,0xC0,0x00,0xA0,0x00,
+ 0xC9,0x3E,0x3C,0x03,0x0F,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x73,0xFC,0x3C,0xC0,0xF0,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,
+ 0x2C,0x10,0x18,0x24,0x00,0x38,0x30,0x0C,
+ 0x6B,0x04,0xB7,0x08,0x5E,0x08,0x7C,0x0E,
+ 0x05,0x00,0x03,0x00,0x05,0x00,0x02,0x01,
+ 0x11,0x06,0x01,0x0C,0x14,0x08,0x16,0x08,
+ 0x01,0x00,0x28,0x00,0x51,0x00,0x41,0xBE,
+ 0x0C,0xF3,0xAE,0x50,0xA6,0x00,0x00,0x00,
+ 0x80,0x00,0x02,0x00,0x55,0x00,0x1E,0xE0,
+ 0x40,0xBF,0xCC,0x33,0x9C,0x00,0x18,0x00,
+ 0x01,0x00,0x82,0x00,0x55,0x00,0x9E,0x60,
+ 0xC0,0x3F,0x4C,0xB3,0x1C,0x00,0x18,0x00,
+ 0xEC,0x06,0xBC,0x02,0x72,0x04,0xC3,0x1C,
+ 0xD1,0x2C,0x18,0xE0,0x08,0x60,0x40,0x00,
+ 0xF3,0x4C,0xF7,0x28,0xEF,0x30,0xFF,0x20,
+ 0xFF,0x20,0xFA,0x25,0xFE,0x25,0xFF,0x44,
+ 0xF1,0x0E,0xF1,0x0E,0xF9,0x06,0x7B,0x84,
+ 0x7F,0x84,0x7F,0x84,0xF9,0x06,0xFB,0x06,
+ 0xC7,0x38,0xCF,0x30,0x9F,0x60,0xBF,0x40,
+ 0xFD,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00,0xFF,0x10,0x00,0x10,0x00,0x00,0x00,
+ 0x10,0x00,0x00,0x00,0x10,0x00,0x10,0x00,
+ 0x00,0xFF,0x08,0x00,0x08,0x00,0x08,0x00,
+ 0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,
+ 0x3F,0xC0,0xCF,0x30,0xA3,0x0C,0xDC,0x03,
+ 0xAA,0x00,0xDD,0x00,0xAA,0x00,0xDD,0x00,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0x3F,0xC0,0xCF,0x30,0xA3,0x0C,0xDC,0x03,
+ 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
+ 0x9F,0x60,0x8F,0x30,0x2F,0x10,0x77,0x10,
+ 0xA0,0x00,0xC0,0x00,0xA0,0x00,0x40,0x80,
+ 0x88,0x60,0x80,0x30,0x28,0x10,0x68,0x10,
+ 0x10,0x0C,0x2C,0x10,0x18,0x24,0x00,0x38,
+ 0x30,0x0C,0x6B,0x04,0x77,0x08,0x5E,0x08,
+ 0x3C,0x0E,0x6C,0x06,0x57,0x08,0x3B,0x0C,
+ 0x30,0x0E,0x0C,0x10,0x26,0x18,0x10,0x0C,
+ 0x00,0x00,0x80,0x00,0xC2,0x10,0xD6,0x78,
+ 0x6C,0x9B,0xFD,0x0E,0xDF,0x00,0xF5,0x00,
+ 0x00,0x00,0x00,0x00,0x06,0x00,0x47,0x88,
+ 0xEB,0x9C,0x3C,0xDF,0xBF,0x78,0xAB,0x00
+};
+
+/* End of BIGMAP_TILES.C */
diff --git a/gbdk/gbdk-lib/examples/gb/large_map/bigmap_tiles.h b/gbdk/gbdk-lib/examples/gb/large_map/bigmap_tiles.h
new file mode 100644
index 00000000..708077e2
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/large_map/bigmap_tiles.h
@@ -0,0 +1,107 @@
+/*
+
+ BIGMAP_TILES.H
+
+ Include File.
+
+ Info:
+ Form : All tiles as one unit.
+ Format : Gameboy 4 color.
+ Compression : None.
+ Counter : None.
+ Tile size : 8 x 8
+ Tiles : 0 to 240
+
+ Palette colors : Included.
+ SGB Palette : None.
+ CGB Palette : None.
+
+ Convert to metatiles : No.
+
+ This file was generated by GBTD v2.2
+
+*/
+
+#ifndef __bigmap_tiles_h_INCLUDE
+#define __bigmap_tiles_h_INCLUDE
+
+/* Bank of tiles. */
+#define bigmap_tilesBank 0
+
+/* Super Gameboy palette 0 */
+#define bigmap_tilesSGBPal0c0 0
+#define bigmap_tilesSGBPal0c1 0
+#define bigmap_tilesSGBPal0c2 10240
+#define bigmap_tilesSGBPal0c3 400
+
+/* Super Gameboy palette 1 */
+#define bigmap_tilesSGBPal1c0 6076
+#define bigmap_tilesSGBPal1c1 8935
+#define bigmap_tilesSGBPal1c2 6596
+#define bigmap_tilesSGBPal1c3 5344
+
+/* Super Gameboy palette 2 */
+#define bigmap_tilesSGBPal2c0 6076
+#define bigmap_tilesSGBPal2c1 8935
+#define bigmap_tilesSGBPal2c2 6596
+#define bigmap_tilesSGBPal2c3 5344
+
+/* Super Gameboy palette 3 */
+#define bigmap_tilesSGBPal3c0 6076
+#define bigmap_tilesSGBPal3c1 8935
+#define bigmap_tilesSGBPal3c2 6596
+#define bigmap_tilesSGBPal3c3 5344
+
+/* Gameboy Color palette 0 */
+#define bigmap_tilesCGBPal0c0 0
+#define bigmap_tilesCGBPal0c1 10570
+#define bigmap_tilesCGBPal0c2 20083
+#define bigmap_tilesCGBPal0c3 32767
+
+/* Gameboy Color palette 1 */
+#define bigmap_tilesCGBPal1c0 6076
+#define bigmap_tilesCGBPal1c1 8935
+#define bigmap_tilesCGBPal1c2 6596
+#define bigmap_tilesCGBPal1c3 5344
+
+/* Gameboy Color palette 2 */
+#define bigmap_tilesCGBPal2c0 6076
+#define bigmap_tilesCGBPal2c1 8935
+#define bigmap_tilesCGBPal2c2 6596
+#define bigmap_tilesCGBPal2c3 5344
+
+/* Gameboy Color palette 3 */
+#define bigmap_tilesCGBPal3c0 6076
+#define bigmap_tilesCGBPal3c1 8935
+#define bigmap_tilesCGBPal3c2 6596
+#define bigmap_tilesCGBPal3c3 5344
+
+/* Gameboy Color palette 4 */
+#define bigmap_tilesCGBPal4c0 6076
+#define bigmap_tilesCGBPal4c1 8935
+#define bigmap_tilesCGBPal4c2 6596
+#define bigmap_tilesCGBPal4c3 5344
+
+/* Gameboy Color palette 5 */
+#define bigmap_tilesCGBPal5c0 6076
+#define bigmap_tilesCGBPal5c1 8935
+#define bigmap_tilesCGBPal5c2 6596
+#define bigmap_tilesCGBPal5c3 5344
+
+/* Gameboy Color palette 6 */
+#define bigmap_tilesCGBPal6c0 6076
+#define bigmap_tilesCGBPal6c1 8935
+#define bigmap_tilesCGBPal6c2 6596
+#define bigmap_tilesCGBPal6c3 5344
+
+/* Gameboy Color palette 7 */
+#define bigmap_tilesCGBPal7c0 6076
+#define bigmap_tilesCGBPal7c1 8935
+#define bigmap_tilesCGBPal7c2 6596
+#define bigmap_tilesCGBPal7c3 5344
+/* Start of tile array. */
+extern const unsigned char bigmap_tiles[];
+
+#endif
+
+/* End of BIGMAP_TILES.H */
diff --git a/gbdk/gbdk-lib/examples/gb/large_map/large_map.c b/gbdk/gbdk-lib/examples/gb/large_map/large_map.c
new file mode 100644
index 00000000..9349beb4
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/large_map/large_map.c
@@ -0,0 +1,96 @@
+#include <gb/gb.h>
+#include <stdint.h>
+
+#include "bigmap_map.h"
+#include "bigmap_tiles.h"
+
+#define camera_max_y ((bigmap_mapHeight - 18) * 8)
+#define camera_max_x ((bigmap_mapWidth - 20) * 8)
+
+#define MIN(A,B) ((A)<(B)?(A):(B))
+
+uint8_t joy;
+
+// current and old positions of the camera in pixels
+uint16_t camera_x, camera_y, old_camera_x, old_camera_y;
+// current and old position of the map in tiles
+uint8_t map_pos_x, map_pos_y, old_map_pos_x, old_map_pos_y;
+// redraw flag, indicates that camera position was changed
+uint8_t redraw;
+
+void set_camera() {
+ // update hardware scroll position
+ SCY_REG = camera_y; SCX_REG = camera_x;
+ // up or down
+ map_pos_y = (uint8_t)(camera_y >> 3u);
+ if (map_pos_y != old_map_pos_y) {
+ if (camera_y < old_camera_y) {
+ set_bkg_submap(map_pos_x, map_pos_y, MIN(21u, bigmap_mapWidth-map_pos_x), 1, bigmap_map, bigmap_mapWidth);
+ } else {
+ if ((bigmap_mapHeight - 18u) > map_pos_y) set_bkg_submap(map_pos_x, map_pos_y + 18u, MIN(21u, bigmap_mapWidth-map_pos_x), 1, bigmap_map, bigmap_mapWidth);
+ }
+ old_map_pos_y = map_pos_y;
+ }
+ // left or right
+ map_pos_x = (uint8_t)(camera_x >> 3u);
+ if (map_pos_x != old_map_pos_x) {
+ if (camera_x < old_camera_x) {
+ set_bkg_submap(map_pos_x, map_pos_y, 1, MIN(19u, bigmap_mapHeight - map_pos_y), bigmap_map, bigmap_mapWidth);
+ } else {
+ if ((bigmap_mapWidth - 20u) > map_pos_x) set_bkg_submap(map_pos_x + 20u, map_pos_y, 1, MIN(19u, bigmap_mapHeight - map_pos_y), bigmap_map, bigmap_mapWidth);
+ }
+ old_map_pos_x = map_pos_x;
+ }
+ // set old camera position to current camera position
+ old_camera_x = camera_x, old_camera_y = camera_y;
+}
+
+void main(){
+ DISPLAY_OFF;
+ SHOW_BKG;
+ set_bkg_data(0, 241u, bigmap_tiles);
+
+ map_pos_x = map_pos_y = 0;
+ old_map_pos_x = old_map_pos_y = 255;
+ set_bkg_submap(map_pos_x, map_pos_y, 20, 18, bigmap_map, bigmap_mapWidth);
+ DISPLAY_ON;
+
+ camera_x = camera_y = 0;
+ old_camera_x = camera_x; old_camera_y = camera_y;
+
+ redraw = FALSE;
+
+ SCX_REG = camera_x; SCY_REG = camera_y;
+ while (TRUE) {
+ joy = joypad();
+ // up or down
+ if (joy & J_UP) {
+ if (camera_y) {
+ camera_y--;
+ redraw = TRUE;
+ }
+ } else if (joy & J_DOWN) {
+ if (camera_y < camera_max_y) {
+ camera_y++;
+ redraw = TRUE;
+ }
+ }
+ // left or right
+ if (joy & J_LEFT) {
+ if (camera_x) {
+ camera_x--;
+ redraw = TRUE;
+ }
+ } else if (joy & J_RIGHT) {
+ if (camera_x < camera_max_x) {
+ camera_x++;
+ redraw = TRUE;
+ }
+ }
+ if (redraw) {
+ wait_vbl_done();
+ set_camera();
+ redraw = FALSE;
+ } else wait_vbl_done();
+ }
+} \ No newline at end of file
diff --git a/gbdk/gbdk-lib/examples/gb/lcd_isr_wobble/Makefile b/gbdk/gbdk-lib/examples/gb/lcd_isr_wobble/Makefile
new file mode 100644
index 00000000..5ec52080
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/lcd_isr_wobble/Makefile
@@ -0,0 +1,17 @@
+CC = ../../../bin/lcc -Wa-l -Wl-m -Wl-j
+
+BINS = lcd_isr_wobble.gb
+
+all: $(BINS)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+# Compile and link single file in one pass
+%.gb: %.c
+ $(CC) -o $@ $<
+
+clean:
+ rm -f *.o *.lst *.map *.gb *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi
+
diff --git a/gbdk/gbdk-lib/examples/gb/lcd_isr_wobble/lcd_isr_wobble.c b/gbdk/gbdk-lib/examples/gb/lcd_isr_wobble/lcd_isr_wobble.c
new file mode 100644
index 00000000..a76e6d1b
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/lcd_isr_wobble/lcd_isr_wobble.c
@@ -0,0 +1,28 @@
+#include <gb/gb.h>
+#include <stdint.h>
+#include <stdio.h>
+
+#include <gb/emu_debug.h>
+
+const uint8_t scanline_offsets_tbl[] = {0, 1, 2, 3, 3, 2, 1, 0, 0, 1, 2, 3, 3, 2, 1, 0};
+const uint8_t * scanline_offsets = scanline_offsets_tbl;
+
+void scanline_isr() {
+ SCX_REG = scanline_offsets[LY_REG & (uint8_t)7];
+}
+
+
+void main() {
+ printf("This is\na wobble\ntest\nfor DMG\n|\n|\n|\n|\n|");
+
+ CRITICAL {
+ STAT_REG = STATF_MODE01 | STATF_MODE00;
+ add_LCD(scanline_isr);
+ }
+ set_interrupts(VBL_IFLAG | LCD_IFLAG);
+
+ while (1) {
+ wait_vbl_done();
+ scanline_offsets = &scanline_offsets_tbl[(uint8_t)(sys_time >> 2) & 0x07u];
+ }
+} \ No newline at end of file
diff --git a/gbdk/gbdk-lib/examples/gb/linkerfile/Makefile b/gbdk/gbdk-lib/examples/gb/linkerfile/Makefile
new file mode 100644
index 00000000..5a06d759
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/linkerfile/Makefile
@@ -0,0 +1,69 @@
+#
+# A Makefile that compiles all .c and .s files in "src" and "res"
+# subdirectories and places the output in a "obj" subdirectory
+#
+
+# If you move this project you can change the directory
+# to match your GBDK root directory (ex: GBDK_HOME = "C:/GBDK/"
+GBDK_HOME = ../../../
+
+LCC = $(GBDK_HOME)bin/lcc
+
+# You can set flags for LCC here
+# For example, you can uncomment the line below to turn on debug output
+# LCCFLAGS = -debug
+# LCCFLAGS = -v
+
+# You can set the name of the .gb ROM file here
+PROJECTNAME = Example
+
+SRCDIR = src
+OBJDIR = obj
+RESDIR = res
+BINS = $(OBJDIR)/$(PROJECTNAME).gb
+CSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.c))) $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.c)))
+ASMSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.s)))
+OBJS = $(CSOURCES:%.c=$(OBJDIR)/%.o) $(ASMSOURCES:%.s=$(OBJDIR)/%.o)
+
+all: prepare $(BINS)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+# Compile .c files in "src/" to .o object files
+$(OBJDIR)/%.o: $(SRCDIR)/%.c
+ $(LCC) $(LCCFLAGS) -c -o $@ $<
+
+# Compile .c files in "res/" to .o object files
+$(OBJDIR)/%.o: $(RESDIR)/%.c
+ $(LCC) $(LCCFLAGS) -c -o $@ $<
+
+# Compile .s assembly files in "src/" to .o object files
+$(OBJDIR)/%.o: $(SRCDIR)/%.s
+ $(LCC) $(LCCFLAGS) -c -o $@ $<
+
+# If needed, compile .c files i n"src/" to .s assembly files
+# (not required if .c is compiled directly to .o)
+$(OBJDIR)/%.s: $(SRCDIR)/%.c
+ $(LCC) $(LCCFLAGS) -S -o $@ $<
+
+
+$(OBJDIR)/linkfile.lk: $(OBJS)
+ rm -f $@
+ @for obj in $(OBJS); do \
+ echo $$obj >>$@; \
+ done
+
+# Link the compiled object files (via linkerfile) into a .gb ROM file
+$(BINS): $(OBJDIR)/linkfile.lk
+ $(LCC) $(LCCFLAGS) -o $(BINS) -Wl-f$<
+
+prepare:
+ mkdir -p $(OBJDIR)
+ mkdir -p $(RESDIR)
+
+clean:
+# rm -f *.gb *.ihx *.cdb *.adb *.noi *.map
+ rm -f $(OBJDIR)/*.*
+
diff --git a/gbdk/gbdk-lib/examples/gb/linkerfile/Readme.md b/gbdk/gbdk-lib/examples/gb/linkerfile/Readme.md
new file mode 100644
index 00000000..dada1094
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/linkerfile/Readme.md
@@ -0,0 +1,18 @@
+
+# Example of how to use a linkerfile
+
+A linkerfile allows storing all the object files to be linked in a
+file which is passed to the linker instead of a list of filenames on
+the command line. This may be useful if your project has filenames
+that use up more length than will fit on the command line for Windows
+(8191 chars max).
+
+The typical extension for the linkerfile is ".lk".
+
+It is passed to sdldgb through lcc using `-Wl-f<pathtolinkerfile>`
+If calling sdldgb directly, use `-f<pathtolinkerfile>`
+
+The Makefile is configured to store all the compiled ".o" object files
+into `obj/linkerfile.lk`.
+
+
diff --git a/gbdk/gbdk-lib/examples/gb/linkerfile/src/main.c b/gbdk/gbdk-lib/examples/gb/linkerfile/src/main.c
new file mode 100644
index 00000000..0326df95
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/linkerfile/src/main.c
@@ -0,0 +1,15 @@
+#include <gb/gb.h>
+#include <stdint.h>
+
+
+void main(void)
+{
+ // Loop forever
+ while(1) {
+
+ // Game main loop processing goes here
+
+ // Done processing, yield CPU and wait for start of next frame
+ wait_vbl_done();
+ }
+}
diff --git a/gbdk/gbdk-lib/examples/gb/metasprites/Makefile b/gbdk/gbdk-lib/examples/gb/metasprites/Makefile
new file mode 100644
index 00000000..9237fcd6
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/metasprites/Makefile
@@ -0,0 +1,36 @@
+LCC = ../../../bin/lcc
+PNG2ASSET = ../../../bin/png2asset
+
+CFLAGS =
+
+# Output name for compiled ROM
+BINS = metasprites.gb
+
+# Add entries here to have them converted into metasprites
+PNGSOURCES = sprite.png
+PNG_CSOURCES = $(PNGSOURCES:%.png=%.c)
+PNG_CHEADERS = $(PNGSOURCES:%.png=%.h)
+
+# List of all C source files except those generated by png2asset
+CSOURCES = $(filter-out $(PNGSOURCES:%.png=%.c), $(wildcard *.c))
+
+all: $(BINS)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+# Use png2asset to convert the png into C formatted metasprite data
+# -sh 48 : Sets sprite height to 48 (width remains automatic)
+# -spr8x16 : Use 8x16 hardware sprites
+# -c ... : Set C output file
+%.c: %.png
+ $(PNG2ASSET) $< -sh 48 -spr8x16 -c $@
+
+# Compile all C sources, including converted png metasprites
+$(BINS): $(CSOURCES) $(PNG_CSOURCES)
+ $(LCC) $(CFLAGS) -o $(BINS) $(CSOURCES) $(PNG_CSOURCES)
+
+
+clean:
+ rm -f *.o *.lst *.map *.gb *.ihx *.sym *.cdb *.adb *.asm $(PNG_CHEADERS) $(PNG_CSOURCES)
diff --git a/gbdk/gbdk-lib/examples/gb/metasprites/Readme.md b/gbdk/gbdk-lib/examples/gb/metasprites/Readme.md
new file mode 100644
index 00000000..1a82e4be
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/metasprites/Readme.md
@@ -0,0 +1,20 @@
+
+Metasprite Example
+==================
+
+Demonstrates using the metasprite features to move and animate a large sprite.
+
+* Press A button to show / hide the metasprite
+* Press B button to cycle through the metasprite animations
+* Press SELECT button to cycle the metasprite through Normal / Flip-Y / Flip-XY / Flip-X
+* Up / Down / Left / Right to move the metasprite
+
+In this example the move_metasprite...() functions are called every
+frame to simplify the example code, regardless of whether the updates
+are needed or not.
+
+In a real game it would be better to only call them if something changed
+(such as movement or rotation) since that reduces CPU usage on frames where
+the updates aren't required.
+
+
diff --git a/gbdk/gbdk-lib/examples/gb/metasprites/metasprites.c b/gbdk/gbdk-lib/examples/gb/metasprites/metasprites.c
new file mode 100644
index 00000000..2f92550f
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/metasprites/metasprites.c
@@ -0,0 +1,153 @@
+#include <stdint.h>
+
+#include <gbdk/platform.h>
+#include <gbdk/metasprites.h>
+
+#include "sprite.h"
+
+const unsigned char pattern[] = {0x80,0x80,0x40,0x40,0x20,0x20,0x10,0x10,0x08,0x08,0x04,0x04,0x02,0x02,0x01,0x01};
+
+joypads_t joypads;
+
+#define ACC_X 1
+#define ACC_Y 2
+
+// The metasprite will be built starting with hardware sprite zero (the first)
+#define SPR_NUM_START 0
+
+// Metasprite tiles are loaded into VRAM starting at tile number 0
+#define TILE_NUM_START 0
+
+// sprite coords
+uint16_t PosX, PosY;
+int16_t SpdX, SpdY;
+uint8_t PosF;
+uint8_t hide, jitter;
+uint8_t idx, rot;
+
+// main funxction
+void main(void) {
+ // init palettes
+ BGP_REG = OBP0_REG = 0xE4;
+ OBP1_REG = 0xE0;
+
+ // Fill the screen background with a single tile pattern
+ fill_bkg_rect(0, 0, 20, 18, 0);
+ set_bkg_data(0, 1, pattern);
+
+ // Load metasprite tile data into VRAM
+ set_sprite_data(TILE_NUM_START, sizeof(sprite_tiles) >> 4, sprite_tiles);
+
+ // show bkg and sprites
+ SHOW_BKG; SHOW_SPRITES;
+
+ // Check what size hardware sprite the metasprite is using (from sprite.h)
+ #if sprite_TILE_H == 16
+ SPRITES_8x16;
+ #else
+ SPRITES_8x8;
+ #endif
+
+ // init 1 joypad
+ joypad_init(1, &joypads);
+
+ // Set initial position, zero out speed
+ PosX = PosY = 64 << 4;
+ SpdX = SpdY = 0;
+
+ hide = 0; jitter = 0; idx = 0; rot = 0;
+
+ while(1) {
+ // poll joypads
+ joypad_ex(&joypads);
+
+ PosF = 0;
+ // game object
+ if (joypads.joy0 & J_UP) {
+ SpdY -= 2;
+ if (SpdY < -32) SpdY = -32;
+ PosF |= ACC_Y;
+ } else if (joypads.joy0 & J_DOWN) {
+ SpdY += 2;
+ if (SpdY > 32) SpdY = 32;
+ PosF |= ACC_Y;
+ }
+
+ if (joypads.joy0 & J_LEFT) {
+ SpdX -= 2;
+ if (SpdX < -32) SpdX = -32;
+ PosF |= ACC_X;
+ } else if (joypads.joy0 & J_RIGHT) {
+ SpdX += 2;
+ if (SpdX > 32) SpdX = 32;
+ PosF |= ACC_X;
+ }
+
+
+ // Press A button to show/hide metasprite
+ if ((joypads.joy0 & J_A) && (!jitter)) {
+ hide = (!hide);
+ jitter = 20;
+ }
+
+ // Press B button to cycle through metasprite animations
+ if ((joypads.joy0 & J_B) && (!jitter) && (!hide)) {
+ idx++; if (idx >= (sizeof(sprite_metasprites) >> 1)) idx = 0;
+ jitter = 10;
+ }
+
+ // Press SELECT button to cycle metasprite through Normal/Flip-Y/Flip-XY/Flip-X
+ if ((joypads.joy0 & J_SELECT) && (!jitter) && (!hide)) {
+ rot++; rot &= 3;
+ jitter = 20;
+ }
+
+ // Hide/Animate/Flip input throttling
+ if (jitter) jitter--;
+
+ PosX += SpdX, PosY += SpdY;
+
+ uint8_t hiwater = 0;
+
+ // NOTE: In a real game it would be better to only call the move_metasprite..()
+ // functions if something changed (such as movement or rotation). That
+ // reduces CPU usage on frames that don't need updates.
+ //
+ // In this example they are called every frame to simplify the example code
+
+ // Hide the metasprite or move it & apply any rotation settings
+ if (hide)
+ hide_metasprite(sprite_metasprites[idx], SPR_NUM_START);
+ else
+ switch (rot) {
+ case 0: hiwater = move_metasprite (sprite_metasprites[idx], TILE_NUM_START, SPR_NUM_START, (PosX >> 4), (PosY >> 4)); break;
+ case 1: hiwater = move_metasprite_hflip (sprite_metasprites[idx], TILE_NUM_START, SPR_NUM_START, (PosX >> 4), (PosY >> 4)); break;
+ case 2: hiwater = move_metasprite_hvflip(sprite_metasprites[idx], TILE_NUM_START, SPR_NUM_START, (PosX >> 4), (PosY >> 4)); break;
+ case 3: hiwater = move_metasprite_vflip (sprite_metasprites[idx], TILE_NUM_START, SPR_NUM_START, (PosX >> 4), (PosY >> 4)); break;
+ };
+
+ // Hide rest of the hardware sprites, because amount of sprites differ between animation frames.
+ hide_sprites_range(hiwater, 40);
+
+ // Y Axis: update velocity (reduce speed) if no U/D button pressed
+ if (!(PosF & ACC_Y)) {
+ if (SpdY != 0) {
+ if (SpdY > 0) SpdY--;
+ else SpdY ++;
+ }
+ }
+
+ // X Axis: update velocity (reduce speed) if no L/R button pressed
+ if (!(PosF & ACC_X)) {
+ if (SpdX != 0) {
+ if (SpdX > 0) SpdX--;
+ else SpdX ++;
+ }
+ }
+
+
+ // wait for VBlank to slow down everything and reduce cpu use when idle
+ wait_vbl_done();
+ }
+}
+
diff --git a/gbdk/gbdk-lib/examples/gb/metasprites/sprite.png b/gbdk/gbdk-lib/examples/gb/metasprites/sprite.png
new file mode 100644
index 00000000..aa0f74b9
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/metasprites/sprite.png
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/gb/paint/Makefile b/gbdk/gbdk-lib/examples/gb/paint/Makefile
new file mode 100644
index 00000000..5d016918
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/paint/Makefile
@@ -0,0 +1,17 @@
+CC = ../../../bin/lcc -Wa-l -Wl-m -Wl-j
+
+BINS = paint.gb
+
+all: $(BINS)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+# Compile and link single file in one pass
+%.gb: %.c
+ $(CC) -o $@ $<
+
+clean:
+ rm -f *.o *.lst *.map *.gb *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi
+
diff --git a/gbdk/gbdk-lib/examples/gb/paint/paint.c b/gbdk/gbdk-lib/examples/gb/paint/paint.c
new file mode 100644
index 00000000..8b9962b5
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/paint/paint.c
@@ -0,0 +1,528 @@
+#include <gb/gb.h>
+#include <stdint.h>
+#include <gb/drawing.h>
+
+#define NB_TOOLS 18
+#define NB_DATA_TILES 48
+
+#define ARROW 0
+#define PEN 1
+#define BRUSH 2
+#define FILL 3
+#define ERASER 4
+#define CROSS 5
+
+#define UNSELECTED 0
+#define SELECTED 1
+
+#define FIRST_TOOL 0
+#define LAST_TOOL 9
+#define FIRST_COLOR 10
+#define LAST_COLOR 13
+#define FIRST_MODE 14
+#define LAST_MODE 17
+
+typedef struct icon_info_
+{
+ uint8_t data_idx; /* Index of data in the data array */
+ uint8_t x, y, w, h; /* Position and size (in tiles) */
+ uint8_t up, down, left, right; /* Index of next icons (for cursor movements) */
+ uint8_t cursor; /* Cursor associated with icon */
+} icon_info;
+
+typedef struct cursor_info_
+{
+ uint8_t data_idx; /* Index of data in the data array */
+ uint8_t w, h; /* Size (in tiles) */
+ uint8_t hot_x, hot_y; /* Position of hot point, relatice to top-left of sprite (in pixels) */
+} cursor_info;
+
+const icon_info icons[] =
+{
+ /* Pen */
+ { 0, 0, 0, 2, 2, 10, 2, 1, 1, 1 }, /* 0 */
+ /* Brush */
+ { 4, 2, 0, 2, 2, 14, 3, 0, 0, 2 }, /* 1 */
+ /* Fill */
+ { 8, 0, 2, 2, 2, 0, 4, 3, 3, 3 }, /* 2 */
+ /* Eraser */
+ { 12, 2, 2, 2, 2, 1, 5, 2, 2, 4 }, /* 3 */
+ /* Line */
+ { 16, 0, 4, 2, 2, 2, 6, 5, 5, 5 }, /* 4 */
+ /* Line */
+ { 20, 2, 4, 2, 2, 3, 7, 4, 4, 5 }, /* 5 */
+ /* Rectangle */
+ { 24, 0, 6, 2, 2, 4, 8, 7, 7, 5 }, /* 6 */
+ /* Oval */
+ { 28, 2, 6, 2, 2, 5, 9, 6, 6, 5 }, /* 7 */
+ /* Filled rectangle */
+ { 32, 0, 8, 2, 2, 6, 10, 9, 9, 5 }, /* 8 */
+ /* Filled oval */
+ { 36, 2, 8, 2, 2, 7, 14, 8, 8, 5 }, /* 9 */
+ /* Color */
+ { 40, 0, 10, 1, 1, 8, 11, 16, 12, 0 }, /* 10 */
+ { 41, 0, 11, 1, 1, 10, 0, 17, 13, 0 }, /* 11 */
+ { 42, 1, 10, 1, 1, 8, 13, 10, 14, 0 }, /* 12 */
+ { 43, 1, 11, 1, 1, 12, 0, 11, 15, 0 }, /* 13 */
+ /* Mode */
+ { 44, 2, 10, 1, 1, 9, 15, 12, 16, 0 }, /* 14 */
+ { 45, 2, 11, 1, 1, 14, 1, 13, 17, 0 }, /* 15 */
+ { 46, 3, 10, 1, 1, 9, 17, 14, 10, 0 }, /* 16 */
+ { 47, 3, 11, 1, 1, 16, 1, 15, 11, 0 } /* 17 */
+};
+
+const unsigned char data[NB_DATA_TILES][0x10] =
+{
+ /* Pen */
+ { 0x00,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x01 },
+ { 0x7E,0x02,0x7D,0x05,0x7B,0x0A,0x77,0x14,0x7F,0x18,0x7F,0x27,0x7F,0x00,0x00,0x7F },
+ { 0x00,0x00,0xFE,0x01,0xFE,0x0D,0xF6,0x15,0xEE,0x29,0xDE,0x51,0xBE,0xA1,0x7E,0x41 },
+ { 0xFE,0x81,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0xFD,0xFE,0x01,0x00,0xFF },
+ /* Brush */
+ { 0x00,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x01 },
+ { 0x7E,0x02,0x7D,0x0D,0x7F,0x1E,0x7F,0x1E,0x7F,0x1D,0x7F,0x11,0x7F,0x00,0x00,0x7F },
+ { 0x00,0x00,0xFE,0x01,0xFE,0x0D,0xF6,0x15,0xEE,0x29,0xDE,0x51,0xBE,0xA1,0x7E,0x41 },
+ { 0xFE,0x81,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0xFD,0xFE,0xFD,0xFE,0x01,0x00,0xFF },
+ /* Fill */
+ { 0x00,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x01,0x7F,0x02,0x7E,0x0C,0x7D,0x18,0x7E,0x1D },
+ { 0x7F,0x1B,0x7F,0x19,0x7F,0x18,0x7F,0x08,0x7F,0x08,0x7F,0x08,0x7F,0x00,0x00,0x7F },
+ { 0x00,0x00,0xFE,0x01,0xFE,0x81,0xFE,0x41,0x7E,0x21,0xBE,0x71,0x5E,0xE9,0xAE,0xC5 },
+ { 0x5E,0x89,0xBE,0x11,0xFE,0xA1,0xFE,0x41,0xFE,0x01,0xFE,0x01,0xFE,0x01,0x00,0xFF },
+ /* Eraser */
+ { 0x00,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x01,0x7E,0x02,0x7C,0x04 },
+ { 0x78,0x08,0x7F,0x1F,0x71,0x11,0x7F,0x1F,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x00,0x7F },
+ { 0x00,0x00,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0xF9,0x1E,0x19,0x2E,0x29,0x5E,0x51 },
+ { 0xBE,0xA1,0x7E,0x41,0xFE,0x81,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0x00,0xFF },
+ /* Line */
+ { 0x00,0x00,0x7F,0x00,0x7F,0x20,0x7F,0x10,0x7F,0x08,0x7F,0x04,0x7F,0x02,0x7F,0x01 },
+ { 0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x00,0x7F },
+ { 0x00,0x00,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01 },
+ { 0xFE,0x81,0xFE,0x41,0xFE,0x21,0xFE,0x11,0xFE,0x09,0xFE,0x05,0xFE,0x01,0x00,0xFF },
+ /* Arc */
+ { 0x00,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x1E,0x7F,0x01,0x7F,0x00,0x7F,0x00,0x7F,0x00 },
+ { 0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x00,0x00,0x7F },
+ { 0x00,0x00,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x81,0xFE,0x41,0xFE,0x21,0xFE,0x11 },
+ { 0xFE,0x11,0xFE,0x09,0xFE,0x09,0xFE,0x09,0xFE,0x09,0xFE,0x01,0xFE,0x01,0x00,0xFF },
+ /* Rectangle */
+ { 0x00,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x3F,0x7F,0x20,0x7F,0x20,0x7F,0x20,0x7F,0x20 },
+ { 0x7F,0x20,0x7F,0x20,0x7F,0x20,0x7F,0x20,0x7F,0x3F,0x7F,0x00,0x7F,0x00,0x00,0x7F },
+ { 0x00,0x00,0xFE,0x01,0xFE,0x01,0xFE,0xFD,0xFE,0x05,0xFE,0x05,0xFE,0x05,0xFE,0x05 },
+ { 0xFE,0x05,0xFE,0x05,0xFE,0x05,0xFE,0x05,0xFE,0xFD,0xFE,0x01,0xFE,0x01,0x00,0xFF },
+ /* Oval */
+ { 0x00,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x03,0x7F,0x0C,0x7F,0x10,0x7F,0x20,0x7F,0x20 },
+ { 0x7F,0x20,0x7F,0x20,0x7F,0x10,0x7F,0x0C,0x7F,0x03,0x7F,0x00,0x7F,0x00,0x00,0x7F },
+ { 0x00,0x00,0xFE,0x01,0xFE,0x01,0xFE,0xC1,0xFE,0x31,0xFE,0x09,0xFE,0x05,0xFE,0x05 },
+ { 0xFE,0x05,0xFE,0x05,0xFE,0x09,0xFE,0x31,0xFE,0xC1,0xFE,0x01,0xFE,0x01,0x00,0xFF },
+ /* Filled rectangle */
+ { 0x00,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x3F,0x6A,0x3F,0x75,0x3F,0x6A,0x3F,0x75,0x3F },
+ { 0x6A,0x3F,0x75,0x3F,0x6A,0x3F,0x75,0x3F,0x7F,0x3F,0x7F,0x00,0x7F,0x00,0x00,0x7F },
+ { 0x00,0x00,0xFE,0x01,0xFE,0x01,0xFE,0xFD,0xAE,0xFD,0x56,0xFD,0xAE,0xFD,0x56,0xFD },
+ { 0xAE,0xFD,0x56,0xFD,0xAE,0xFD,0x56,0xFD,0xFE,0xFD,0xFE,0x01,0xFE,0x01,0x00,0xFF },
+ /* Filled oval */
+ { 0x00,0x00,0x7F,0x00,0x7F,0x00,0x7F,0x03,0x7E,0x0F,0x75,0x1F,0x6A,0x3F,0x75,0x3F },
+ { 0x6A,0x3F,0x75,0x3F,0x7A,0x1F,0x7D,0x0F,0x7F,0x03,0x7F,0x00,0x7F,0x00,0x00,0x7F },
+ { 0x00,0x00,0xFE,0x01,0xFE,0x01,0xFE,0xC1,0xBE,0xF1,0x5E,0xF9,0xAE,0xFD,0x56,0xFD },
+ { 0xAE,0xFD,0x56,0xFD,0xAE,0xF9,0x7E,0xF1,0xFE,0xC1,0xFE,0x01,0xFE,0x01,0x00,0xFF },
+ /* Color */
+ { 0x00,0x00,0x7F,0x7F,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40 },
+ { 0x40,0x7F,0x40,0x7F,0x40,0x7F,0x40,0x7F,0x40,0x7F,0x40,0x7F,0x7F,0x7F,0x00,0x7F },
+ { 0x00,0x00,0xFE,0xFF,0xFE,0x03,0xFE,0x03,0xFE,0x03,0xFE,0x03,0xFE,0x03,0xFE,0x03 },
+ { 0xFE,0xFF,0xFE,0xFF,0xFE,0xFF,0xFE,0xFF,0xFE,0xFF,0xFE,0xFF,0xFE,0xFF,0x00,0xFF },
+ /* Mode */
+ { 0x00,0x00,0x7F,0x00,0x7F,0x0C,0x7F,0x10,0x7F,0x08,0x7F,0x04,0x7F,0x18,0x7F,0x00 },
+ { 0x7F,0x00,0x7F,0x08,0x7F,0x14,0x7F,0x14,0x7F,0x14,0x7F,0x08,0x7F,0x00,0x00,0x7F },
+ { 0x00,0x01,0xFE,0x01,0xFE,0x29,0xFE,0x29,0xFE,0x11,0xFE,0x29,0xFE,0x29,0xFE,0x01 },
+ { 0xFE,0x01,0xFE,0x11,0xFE,0x29,0xFE,0x39,0xFE,0x29,0xFE,0x29,0xFE,0x01,0x00,0xFF }
+};
+
+const unsigned char selected_data[NB_DATA_TILES][0x10] =
+{
+ /* Pen */
+ { 0xFF,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFE },
+ { 0x81,0xFD,0x82,0xFA,0x84,0xF5,0x88,0xEB,0x80,0xE7,0x80,0xD8,0x80,0xFF,0xFF,0x80 },
+ { 0xFF,0xFF,0x01,0xFE,0x01,0xF2,0x09,0xEA,0x11,0xD6,0x21,0xAE,0x41,0x5E,0x81,0xBE },
+ { 0x01,0x7E,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0x02,0x01,0xFE,0xFF,0x00 },
+ /* Brush */
+ { 0xFF,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFE },
+ { 0x81,0xFD,0x82,0xF2,0x80,0xE1,0x80,0xE1,0x80,0xE2,0x80,0xEE,0x80,0xFF,0xFF,0x80 },
+ { 0xFF,0xFF,0x01,0xFE,0x01,0xF2,0x09,0xEA,0x11,0xD6,0x21,0xAE,0x41,0x5E,0x81,0xBE },
+ { 0x01,0x7E,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0x02,0x01,0x02,0x01,0xFE,0xFF,0x00 },
+ /* Fill */
+ { 0xFF,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFE,0x80,0xFD,0x81,0xF3,0x82,0xE7,0x81,0xE2 },
+ { 0x80,0xE4,0x80,0xE7,0x80,0xE7,0x80,0xF7,0x80,0xF7,0x80,0xF7,0x80,0xFF,0xFF,0x80 },
+ { 0xFF,0xFF,0x01,0xFE,0x01,0x7E,0x01,0xBE,0x81,0xDE,0x41,0x8E,0xA1,0x16,0x51,0x3A },
+ { 0xA1,0x76,0x41,0xEE,0x01,0x5E,0x01,0xBE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0xFF,0x00 },
+ /* Eraser */
+ { 0xFF,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFE,0x81,0xFD,0x83,0xFB },
+ { 0x87,0xF7,0x80,0xE0,0x8E,0xEE,0x80,0xE0,0x80,0xFF,0x80,0xFF,0x80,0xFF,0xFF,0x80 },
+ { 0xFF,0xFF,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0x06,0xE1,0xE6,0xD1,0xD6,0xA1,0xAE },
+ { 0x41,0x5E,0x81,0xBE,0x01,0x7E,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0xFF,0x00 },
+ /* Line */
+ { 0xFF,0xFF,0x80,0xFF,0x80,0xDF,0x80,0xEF,0x80,0xF7,0x80,0xFB,0x80,0xFD,0x80,0xFE },
+ { 0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0xFF,0x80 },
+ { 0xFF,0xFF,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE },
+ { 0x01,0x7E,0x01,0xBE,0x01,0xDE,0x01,0xEE,0x01,0xF6,0x01,0xFA,0x01,0xFE,0xFF,0x00 },
+ /* Arc */
+ { 0xFF,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xE1,0x80,0xFE,0x80,0xFF,0x80,0xFF,0x80,0xFF },
+ { 0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFF,0xFF,0x80 },
+ { 0xFF,0xFF,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0x7E,0x01,0xBE,0x01,0xDE,0x01,0xEE },
+ { 0x01,0xEE,0x01,0xF6,0x01,0xF6,0x01,0xF6,0x01,0xF6,0x01,0xFE,0x01,0xFE,0xFF,0x00 },
+ /* Rectangle */
+ { 0xFF,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xC0,0x80,0xDF,0x80,0xDF,0x80,0xDF,0x80,0xDF },
+ { 0x80,0xDF,0x80,0xDF,0x80,0xDF,0x80,0xDF,0x80,0xC0,0x80,0xFF,0x80,0xFF,0xFF,0x80 },
+ { 0xFF,0xFF,0x01,0xFE,0x01,0xFE,0x01,0x02,0x01,0xFA,0x01,0xFA,0x01,0xFA,0x01,0xFA },
+ { 0x01,0xFA,0x01,0xFA,0x01,0xFA,0x01,0xFA,0x01,0x02,0x01,0xFE,0x01,0xFE,0xFF,0x00 },
+ /* Oval */
+ { 0xFF,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFC,0x80,0xF3,0x80,0xEF,0x80,0xDF,0x80,0xDF },
+ { 0x80,0xDF,0x80,0xDF,0x80,0xEF,0x80,0xF3,0x80,0xFC,0x80,0xFF,0x80,0xFF,0xFF,0x80 },
+ { 0xFF,0xFF,0x01,0xFE,0x01,0xFE,0x01,0x3E,0x01,0xCE,0x01,0xF6,0x01,0xFA,0x01,0xFA },
+ { 0x01,0xFA,0x01,0xFA,0x01,0xF6,0x01,0xCE,0x01,0x3E,0x01,0xFE,0x01,0xFE,0xFF,0x00 },
+ /* Filled rectangle */
+ { 0xFF,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xC0,0x9F,0xC0,0x9F,0xC0,0x9F,0xC0,0x9F,0xC0 },
+ { 0x9F,0xC0,0x9F,0xC0,0x9F,0xC0,0x9F,0xC0,0x80,0xC0,0x80,0xFF,0x80,0xFF,0xFF,0x80 },
+ { 0xFF,0xFF,0x01,0xFE,0x01,0xFE,0x01,0x02,0xF9,0x02,0xF9,0x02,0xF9,0x02,0xF9,0x02 },
+ { 0xF9,0x02,0xF9,0x02,0xF9,0x02,0xF9,0x02,0x01,0x02,0x01,0xFE,0x01,0xFE,0xFF,0x00 },
+ /* Filled oval */
+ { 0xFF,0xFF,0x80,0xFF,0x80,0xFF,0x80,0xFC,0x83,0xF0,0x8F,0xE0,0x9F,0xC0,0x9F,0xC0 },
+ { 0x9F,0xC0,0x9F,0xC0,0x8F,0xE0,0x83,0xF0,0x80,0xFC,0x80,0xFF,0x80,0xFF,0xFF,0x80 },
+ { 0xFF,0xFF,0x01,0xFE,0x01,0xFE,0x01,0x3E,0xC1,0x0E,0xF1,0x06,0xF9,0x02,0xF9,0x02 },
+ { 0xF9,0x02,0xF9,0x02,0xF1,0x06,0xC1,0x0E,0x01,0x3E,0x01,0xFE,0x01,0xFE,0xFF,0x00 },
+ /* Color */
+ { 0x00,0x00,0x7F,0x7F,0x61,0x61,0x52,0x52,0x4C,0x4C,0x4C,0x4C,0x52,0x52,0x61,0x61 },
+ { 0x40,0x5E,0x40,0x6D,0x40,0x73,0x40,0x73,0x40,0x6D,0x40,0x5E,0x7F,0x7F,0x00,0x7F },
+ { 0x00,0x00,0xFE,0xFF,0xFE,0x87,0xFE,0x4B,0xFE,0x33,0xFE,0x33,0xFE,0x4B,0xFE,0x87 },
+ { 0x7A,0x7B,0xB6,0xB7,0xCE,0xCF,0xCE,0xCF,0xB6,0xB7,0x7A,0x7B,0xFE,0xFF,0x00,0xFF },
+ /* Mode */
+ { 0x00,0x00,0x7F,0x7F,0x73,0x73,0x6F,0x6F,0x77,0x77,0x7B,0x7B,0x67,0x67,0x7F,0x7F },
+ { 0x7F,0x7F,0x77,0x77,0x6B,0x6B,0x6B,0x6B,0x6B,0x6B,0x77,0x77,0x7F,0x7F,0x00,0x7F },
+ { 0x00,0x01,0xFE,0xFF,0xD6,0xD7,0xD6,0xD7,0xEE,0xEF,0xD6,0xD7,0xD6,0xD7,0xFE,0xFF },
+ { 0xFE,0xFF,0xEE,0xEF,0xD6,0xD7,0xC6,0xC7,0xD6,0xD7,0xD6,0xD7,0xFE,0xFF,0x00,0xFF }
+};
+
+const cursor_info cursors[] =
+{
+ /* Arrow */
+ { 0, 1, 1, 0, 0 },
+ /* Pen */
+ { 1, 2, 2, 0, 15 },
+ /* Brush */
+ { 5, 2, 2, 0, 15 },
+ /* Fill */
+ { 9, 2, 2, 2, 15 },
+ /* Eraser */
+ { 13, 2, 2, 0, 15 },
+ /* Cross */
+ { 17, 2, 2, 5, 10 }
+};
+
+const unsigned char cursors_data[][0x10] = {
+ /* Arrow */
+ { 0xFF,0x00,0xFF,0x7E,0xFF,0x7C,0xFE,0x78,0xFF,0x7C,0xFF,0x6E,0xFF,0x46,0xEF,0x00 },
+ /* Pen */
+ { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x03,0x00,0x07,0x01 },
+ { 0x0F,0x02,0x1F,0x05,0x3F,0x0A,0x7F,0x14,0x7E,0x28,0xFC,0x30,0xF8,0x40,0x60,0x00 },
+ { 0x00,0x00,0x00,0x00,0x3C,0x00,0x7C,0x18,0xFC,0x28,0xFC,0x50,0xF8,0xA0,0xF0,0x40 },
+ { 0xE0,0x80,0xC0,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
+ /* Brush */
+ { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x03,0x00,0x07,0x01,0x0F,0x02 },
+ { 0x1F,0x05,0x7F,0x0A,0xFF,0x34,0xFE,0x78,0xFC,0x78,0xFC,0x70,0xF8,0x40,0x60,0x00 },
+ { 0x00,0x00,0x00,0x00,0x78,0x00,0xF8,0x30,0xF8,0x50,0xF8,0xA0,0xF0,0x40,0xE0,0x80 },
+ { 0xC0,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
+ /* Fill */
+ { 0x00,0x00,0x00,0x00,0x07,0x00,0x0F,0x02,0x1F,0x05,0x7F,0x08,0xFE,0x31,0xFD,0x63 },
+ { 0xFA,0x77,0xFD,0x6E,0xFF,0x64,0xFF,0x62,0xF7,0x21,0x73,0x20,0x70,0x20,0x50,0x00 },
+ { 0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0xC0,0x00,0xE0,0x80,0xF0,0xC0,0x78,0xA0 },
+ { 0xF8,0x10,0xF8,0x20,0xF0,0x40,0xE0,0x80,0xC0,0x00,0x80,0x00,0x00,0x00,0x00,0x00 },
+ /* Eraser */
+ { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x0F,0x03 },
+ { 0x1F,0x04,0x3F,0x08,0x7F,0x11,0xFF,0x22,0xFF,0x7D,0xFF,0x46,0xFF,0x7C,0x7E,0x00 },
+ { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x00,0xF0,0xE0 },
+ { 0xF0,0x60,0xF0,0xA0,0xF0,0x40,0xE0,0x80,0xC0,0x00,0x80,0x00,0x00,0x00,0x00,0x00 },
+ /* Cross */
+ { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0E,0x00,0x0E,0x04,0x0E,0x04 },
+ { 0x0E,0x04,0xFF,0x04,0xFB,0x7B,0xFF,0x04,0x0E,0x04,0x0E,0x04,0x0E,0x04,0x0E,0x00 },
+ { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
+ { 0x00,0x00,0xE0,0x00,0xE0,0xC0,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
+};
+
+unsigned char data_buffer[NB_DATA_TILES][0x10];
+
+const uint8_t colors[] = { WHITE, DKGREY, LTGREY, BLACK };
+const uint8_t modes[] = { SOLID, OR, XOR, AND };
+
+uint8_t current_tool;
+uint8_t current_color;
+uint8_t current_mode;
+uint8_t current_cursor;
+uint8_t menu_cursor_pos;
+
+uint8_t cursor_x;
+uint8_t cursor_y;
+
+void set_cursor()
+{
+ uint8_t x, y, i;
+
+ i = 0;
+ for(x = 0; x < cursors[current_cursor].w; x++)
+ for(y = 0; y < cursors[current_cursor].h; y++) {
+ set_sprite_data(i,
+ 1,
+ cursors_data[cursors[current_cursor].data_idx+i]);
+ set_sprite_tile(i, i);
+ set_sprite_prop(i, 0x10);
+ i++;
+ }
+ /* Hide unused sprites */
+ for(; i < 4; i++) {
+ move_sprite(i, 0, 0);
+ }
+}
+
+void move_cursor()
+{
+ uint8_t x, y;
+
+ for(x = 0; x < cursors[current_cursor].w; x++)
+ for(y = 0; y < cursors[current_cursor].h; y++)
+ move_sprite((x<<1)+y,
+ cursor_x+8 - cursors[current_cursor].hot_x + (x<<3),
+ cursor_y+16 - cursors[current_cursor].hot_y + (y<<3));
+}
+
+void move_menu_cursor()
+{
+ move_sprite(0,
+ ((icons[menu_cursor_pos].x+icons[menu_cursor_pos].w)<<3) + 4,
+ ((icons[menu_cursor_pos].y+icons[menu_cursor_pos].h)<<3) + 12);
+}
+
+void set_icon(uint8_t icon, uint8_t selected)
+{
+ uint8_t x, y;
+
+ for(x = 0; x < icons[icon].w; x++)
+ for(y = 0; y < icons[icon].h; y++) {
+ uint16_t index = icons[icon].data_idx+((uint16_t)x<<1)+y;
+ switch_data(icons[icon].x + x,
+ icons[icon].y + y,
+ selected ? selected_data[index] : data[index],
+ data_buffer[index]);
+ }
+}
+
+void change_icon(uint8_t icon, uint8_t selected)
+{
+ uint8_t x, y;
+
+ for(x = 0; x < icons[icon].w; x++)
+ for(y = 0; y < icons[icon].h; y++)
+ switch_data(icons[icon].x + x,
+ icons[icon].y + y,
+ (selected ?
+ selected_data[icons[icon].data_idx+((uint16_t)x<<1)+y] :
+ data[icons[icon].data_idx+((uint16_t)x<<1)+y]),
+ NULL);
+}
+
+void reset_icon(uint8_t icon)
+{
+ uint8_t x, y;
+
+ for(x = 0; x < icons[icon].w; x++)
+ for(y = 0; y < icons[icon].h; y++)
+ switch_data(icons[icon].x + x,
+ icons[icon].y + y,
+ data_buffer[icons[icon].data_idx+(x<<1)+y],
+ NULL);
+}
+
+void splash()
+{
+ uint8_t x, y;
+
+ cursor_x = 40;
+ cursor_y = 50;
+ current_cursor = PEN;
+ set_cursor();
+ move_cursor();
+ SHOW_SPRITES;
+
+ for(; cursor_x < 120; cursor_x++) {
+ wait_vbl_done();
+ move_cursor();
+ plot(cursor_x, cursor_y, BLACK, SOLID);
+ }
+ for(; cursor_y < 94; cursor_y++) {
+ wait_vbl_done();
+ move_cursor();
+ plot(cursor_x, cursor_y, BLACK, SOLID);
+ }
+ for(; cursor_x > 40; cursor_x--) {
+ wait_vbl_done();
+ move_cursor();
+ plot(cursor_x, cursor_y, BLACK, SOLID);
+ }
+ for(; cursor_y > 50; cursor_y--) {
+ wait_vbl_done();
+ move_cursor();
+ plot(cursor_x, cursor_y, BLACK, SOLID);
+ }
+ cursor_x = 160/2;
+ cursor_y = 144/2;
+ current_cursor = FILL;
+ set_cursor();
+ move_cursor();
+
+ for(y = 51; y < 94; y++)
+ for(x = 41; x < 120; x++)
+ plot(x, y, LTGREY, SOLID);
+
+ // HIDE_SPRITES;
+}
+
+void menu()
+{
+ uint8_t i, key;
+ uint8_t slowdown;
+ uint8_t cursor;
+
+ slowdown = 50;
+
+ for(i = 0; i < NB_TOOLS; i++)
+ set_icon(i,
+ i == FIRST_TOOL + current_tool ||
+ i == FIRST_COLOR + current_color ||
+ i == FIRST_MODE + current_mode);
+
+ cursor = current_cursor;
+ current_cursor = ARROW;
+ set_cursor();
+ move_menu_cursor();
+ SHOW_SPRITES;
+ waitpadup();
+ do {
+ wait_vbl_done();
+ key = joypad();
+ if(key & (J_UP|J_DOWN|J_LEFT|J_RIGHT)) {
+ if(key & J_UP)
+ menu_cursor_pos = icons[menu_cursor_pos].up;
+ if(key & J_DOWN)
+ menu_cursor_pos = icons[menu_cursor_pos].down;
+ if(key & J_LEFT)
+ menu_cursor_pos = icons[menu_cursor_pos].left;
+ if(key & J_RIGHT)
+ menu_cursor_pos = icons[menu_cursor_pos].right;
+ move_menu_cursor();
+ while(slowdown && key == joypad()) {
+ wait_vbl_done();
+ slowdown--;
+ }
+ slowdown = 10;
+ } else
+ slowdown = 50;
+ if(key & J_A) {
+ if( /* menu_cursor_pos >= FIRST_TOOL && */ menu_cursor_pos <= LAST_TOOL) {
+ if(menu_cursor_pos != /* FIRST_TOOL + */ current_tool) {
+ change_icon(/* FIRST_TOOL + */ current_tool, UNSELECTED);
+ current_tool = menu_cursor_pos /* - FIRST_TOOL */;
+ change_icon(/* FIRST_TOOL + */ current_tool, SELECTED);
+ cursor = icons[/* FIRST_TOOL + */ current_tool].cursor;
+ }
+ } else if(menu_cursor_pos >= FIRST_COLOR && menu_cursor_pos <= LAST_COLOR) {
+ if(menu_cursor_pos != FIRST_COLOR + current_color) {
+ change_icon(FIRST_COLOR + current_color, UNSELECTED);
+ current_color = menu_cursor_pos - FIRST_COLOR;
+ change_icon(FIRST_COLOR + current_color, SELECTED);
+ }
+ } else if(menu_cursor_pos >= FIRST_MODE && menu_cursor_pos <= LAST_MODE) {
+ if(menu_cursor_pos != FIRST_MODE + current_mode) {
+ change_icon(FIRST_MODE + current_mode, UNSELECTED);
+ current_mode = menu_cursor_pos - FIRST_MODE;
+ change_icon(FIRST_MODE + current_mode, SELECTED);
+ }
+ }
+ }
+ } while(key != J_SELECT);
+ waitpadup();
+ for(i = 0; i < NB_TOOLS; i++)
+ reset_icon(i);
+ HIDE_SPRITES;
+ current_cursor = cursor;
+}
+
+void run()
+{
+ uint8_t key;
+ uint8_t slowdown;
+ uint8_t drawn, erased;
+
+ slowdown = 10;
+ drawn = erased = 0;
+
+ set_cursor();
+ move_cursor();
+ SHOW_SPRITES;
+
+ while(1) {
+ wait_vbl_done();
+ key = joypad();
+ if(key & (J_UP|J_DOWN|J_LEFT|J_RIGHT)) {
+ if(key & J_UP && cursor_y > 0)
+ cursor_y--;
+ if(key & J_DOWN && cursor_y < 143)
+ cursor_y++;
+ if(key & J_LEFT && cursor_x > 0)
+ cursor_x--;
+ if(key & J_RIGHT && cursor_x < 159)
+ cursor_x++;
+ move_cursor();
+ while(slowdown && key == joypad()) {
+ wait_vbl_done();
+ slowdown--;
+ }
+ slowdown = 1;
+ drawn = erased = 0;
+ } else
+ slowdown = 10;
+ if(key & J_SELECT) {
+ HIDE_SPRITES;
+ menu();
+ set_cursor();
+ move_cursor();
+ SHOW_SPRITES;
+ }
+ if((key & (J_A|J_B)) == J_A) {
+ if(!drawn) {
+ drawn++;
+ plot(cursor_x, cursor_y, colors[current_color], modes[current_mode]);
+ }
+ } else
+ drawn = 0;
+ if((key & (J_A|J_B)) == J_B) {
+ if(!erased) {
+ erased++;
+ plot(cursor_x, cursor_y, WHITE, SOLID);
+ }
+ } else
+ erased = 0;
+ }
+}
+
+void main()
+{
+ /* Initialize sprite palette */
+ OBP1_REG = 0xE0U;
+
+ splash();
+
+ current_tool = 0;
+ current_color = BLACK;
+ current_mode = SOLID;
+ current_cursor = PEN;
+ menu_cursor_pos = 0;
+ cursor_x = 160/2;
+ cursor_y = 144/2;
+
+ run();
+}
diff --git a/gbdk/gbdk-lib/examples/gb/ram_function/Makefile b/gbdk/gbdk-lib/examples/gb/ram_function/Makefile
new file mode 100644
index 00000000..76b7b596
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/ram_function/Makefile
@@ -0,0 +1,32 @@
+CC = ../../../bin/lcc -Wa-l -Wl-m -Wl-j
+
+BINS = ram_fn.gb
+
+all: $(BINS)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+%.o: %.c
+ $(CC) -c -o $@ $<
+
+%.s: %.c
+ $(CC) -S -o $@ $<
+
+%.o: %.s
+ $(CC) -c -o $@ $<
+
+%.gb: %.o
+ $(CC) -o $@ $<
+
+clean:
+ rm -f *.o *.lst *.map *.gb *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi
+
+
+ram_fn.o: ram_fn.c
+ $(CC) -D_inc_ram=0xD000 -D_inc_hiram=0xFFA0 -c -o $@ $<
+
+ram_fn.gb: ram_fn.o
+ $(CC) -Wl-g_inc_ram=0xD000 -Wl-g_inc_hiram=0xFFA0 -o $@ ram_fn.o
+
diff --git a/gbdk/gbdk-lib/examples/gb/ram_function/ram_fn.c b/gbdk/gbdk-lib/examples/gb/ram_function/ram_fn.c
new file mode 100644
index 00000000..b6527714
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/ram_function/ram_fn.c
@@ -0,0 +1,71 @@
+#include <gb/gb.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+
+uint16_t counter = 0;
+
+// inc() must be a relocatable function, be careful!
+void inc() {
+ counter++;
+}
+// dummy function, needed to calculate inc() size, must be after it
+void inc_end() {}
+
+// calculate the distance between objects
+#define object_distance(a, b) ((void *)&(b) - (void *)&(a))
+
+// variables at an absolute addresses which are defined by passing parameters to compiler
+unsigned char __at _inc_ram ram_buffer[];
+unsigned char __at _inc_hiram hiram_buffer[];
+
+// those are function pointer variables, we can initialize them right here
+typedef void (*inc_t)(void);
+inc_t inc_ram_var = (inc_t)ram_buffer;
+inc_t inc_hiram_var = (inc_t)hiram_buffer;
+
+// those are defined by passing parameters to the linker, they must be located at the same
+// addresses where ram_buffer and hiram_buffer are located
+extern void inc_ram();
+extern void inc_hiram();
+
+void print_counter() {
+ printf(" Counter is %u\n", counter);
+}
+
+void main() {
+ // copy inc() function to it's new destinations: hiram_buffer and ram_buffer
+ hiramcpy((uint8_t)&hiram_buffer, (void *)&inc, (uint8_t)object_distance(inc, inc_end));
+ memcpy(&ram_buffer, (void *)&inc, (uint16_t)object_distance(inc, inc_end));
+
+ // print initial counter state
+ puts("Program Start...");
+ print_counter();
+
+ // Call function in ROM
+ puts("Call ROM");
+ inc();
+ print_counter();
+
+ // Call function in RAM using link-time address
+ puts("Call RAM direct");
+ inc_ram();
+ print_counter();
+
+ // Call function in RAM using pointer-to-function variable
+ puts("Call RAM indirect");
+ inc_ram_var();
+ print_counter();
+
+ // Call function in HIRAM using link-time address
+ puts("Call HIRAM direct");
+ inc_hiram();
+ print_counter();
+
+ // Call function in HIRAM using pointer-to-function variable
+ puts("Call HIRAM indirect");
+ inc_hiram_var();
+ print_counter();
+
+ puts("The End...");
+}
diff --git a/gbdk/gbdk-lib/examples/gb/rand/Makefile b/gbdk/gbdk-lib/examples/gb/rand/Makefile
new file mode 100644
index 00000000..49793c54
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/rand/Makefile
@@ -0,0 +1,17 @@
+CC = ../../../bin/lcc -Wa-l -Wl-m -Wl-j
+
+BINS = rand.gb
+
+all: $(BINS)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+# Compile and link single file in one pass
+%.gb: %.c
+ $(CC) -o $@ $<
+
+clean:
+ rm -f *.o *.lst *.map *.gb *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi
+
diff --git a/gbdk/gbdk-lib/examples/gb/rand/rand.c b/gbdk/gbdk-lib/examples/gb/rand/rand.c
new file mode 100644
index 00000000..c16a1d36
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/rand/rand.c
@@ -0,0 +1,59 @@
+/***************************************************************************
+ * *
+ * Module : rand.c *
+ * *
+ * Purpose : A test for the rand() function, for the GBDK *
+ * *
+ * Version : 1, Januari 6 1998 *
+ * *
+ * Author : Luc Van den Borre ( Homepage : NOC.BASE.ORG ) *
+ * *
+ **************************************************************************/
+
+#include <gb/gb.h>
+#include <stdint.h>
+#include <rand.h>
+#include <gb/drawing.h>
+#include <stdio.h>
+#include <string.h>
+
+uint8_t accu[80];
+uint8_t accua[80];
+
+void main(void)
+{
+ uint8_t r, s, t = 0, u = 0;
+ uint16_t seed;
+
+ memset(accu, 0, sizeof(accu));
+ memset(accua, 0, sizeof(accua));
+
+ /* We use the DIV register to get a random initial seed */
+ puts("Getting seed");
+ puts("Push any key (1)");
+ waitpad(0xFF);
+ waitpadup();
+ seed = DIV_REG;
+ puts("Push any key (2)");
+ waitpad(0xFF);
+ waitpadup();
+ seed |= (uint16_t)DIV_REG << 8;
+
+ /* initarand() calls initrand() */
+ initarand(seed);
+
+ do {
+ r = rand();
+ s = arand();
+
+ if(r < 80) {
+ t = ++accu[r];
+ plot(r, 144-t, LTGREY, SOLID);
+ }
+ if(s < 80) {
+ u = ++accua[s];
+ plot(s+80, 144-u, DKGREY, SOLID);
+ }
+ }
+ while(t != 144 && u != 144);
+}
diff --git a/gbdk/gbdk-lib/examples/gb/rpn/Makefile b/gbdk/gbdk-lib/examples/gb/rpn/Makefile
new file mode 100644
index 00000000..c9f94218
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/rpn/Makefile
@@ -0,0 +1,17 @@
+CC = ../../../bin/lcc -Wa-l -Wl-m -Wl-j
+
+BINS = rpn.gb
+
+all: $(BINS)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+# Compile and link single file in one pass
+%.gb: %.c
+ $(CC) -o $@ $<
+
+clean:
+ rm -f *.o *.lst *.map *.gb *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi
+
diff --git a/gbdk/gbdk-lib/examples/gb/rpn/rpn.c b/gbdk/gbdk-lib/examples/gb/rpn/rpn.c
new file mode 100644
index 00000000..7f322db2
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/rpn/rpn.c
@@ -0,0 +1,102 @@
+#include <stdint.h>
+#include <stdio.h>
+#include <ctype.h>
+
+#define MAXOP 40
+#define NUMBER '0'
+#define STACKSIZE 40
+
+uint8_t sp;
+int16_t stack[STACKSIZE];
+
+char s[MAXOP];
+uint8_t pos;
+int16_t n;
+
+void push(int16_t l)
+{
+ if(sp < STACKSIZE)
+ stack[sp++] = l;
+ else
+ puts("Stack full");
+}
+
+int16_t pop(void)
+{
+ if(sp > 0)
+ return stack[--sp];
+ else
+ puts("Stack empty");
+ return 0;
+}
+
+int16_t top(void)
+{
+ if(sp > 0)
+ return stack[sp-1];
+ else
+ puts("Stack empty");
+ return 0;
+}
+
+int8_t read_op(void)
+{
+ if(pos == 0) {
+ gets(s);
+ }
+
+ while(s[pos] == ' ' || s[pos] == '\t')
+ pos++;
+
+ if(s[pos] == '\0') {
+ pos = 0;
+ return('\n');
+ }
+
+ if(!isdigit(s[pos]))
+ return(s[pos++]);
+
+ n = s[pos] - '0';
+ while(isdigit(s[++pos]))
+ n = 10 * n + s[pos] - '0';
+
+ return NUMBER;
+}
+
+void main(void)
+{
+ int8_t type;
+ int16_t op2;
+
+ puts("RPN Calculator");
+ sp = 0;
+ pos = 0;
+
+ while((type = read_op()) != 0) {
+ switch(type) {
+ case NUMBER:
+ push(n);
+ break;
+ case '+':
+ push(pop() + pop());
+ break;
+ case '*':
+ push(pop() * pop());
+ break;
+ case '-':
+ op2 = pop();
+ push(pop() - op2);
+ break;
+ case '/':
+ op2 = pop();
+ if(op2 != 0)
+ push(pop() / op2);
+ else
+ puts("Divide by 0");
+ break;
+ case '\n':
+ printf("==> %d\n", top());
+ break;
+ }
+ }
+}
diff --git a/gbdk/gbdk-lib/examples/gb/samptest/Makefile b/gbdk/gbdk-lib/examples/gb/samptest/Makefile
new file mode 100644
index 00000000..827b5b8c
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/samptest/Makefile
@@ -0,0 +1,23 @@
+CC = ../../../bin/lcc -Wa-l -Wl-m -Wl-j
+
+BINS = samptest.gb
+
+all: $(BINS)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+# Compile and link single file in one pass
+%.o: %.s
+ $(CC) -c -o $@ $<
+
+%.o: %.c
+ $(CC) -c -o $@ $<
+
+%.gb: %.o sample.o
+ $(CC) -o $@ $< sample.o
+
+clean:
+ rm -f *.o *.lst *.map *.gb *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi
+
diff --git a/gbdk/gbdk-lib/examples/gb/samptest/sample.h b/gbdk/gbdk-lib/examples/gb/samptest/sample.h
new file mode 100644
index 00000000..df0d8b74
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/samptest/sample.h
@@ -0,0 +1,20 @@
+/** @file gb/sample.h
+ Playback raw sound sample with length len from start at 8192Hz rate.
+ len defines the length of the sample in samples/32 or bytes/16.
+ The format of the data is unsigned 4-bit samples,
+ 2 samples per byte, upper 4-bits played before lower 4 bits.
+
+ Adaption for GBDK by Lars Malmborg.
+ Original code by Jeff Frohwein.
+*/
+#ifndef _SAMPLE_H
+#define _SAMPLE_H
+
+#include <types.h>
+#include <stdint.h>
+
+/** Play the given, appropriatly formatted sample.
+ */
+void play_sample(uint8_t *start, uint16_t len) OLDCALL;
+
+#endif /* _SAMPLE_H */
diff --git a/gbdk/gbdk-lib/examples/gb/samptest/sample.s b/gbdk/gbdk-lib/examples/gb/samptest/sample.s
new file mode 100644
index 00000000..7d0d770e
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/samptest/sample.s
@@ -0,0 +1,97 @@
+ .include "global.s"
+
+ ;; BANKED: checked
+ .title "Sound sample player"
+ .module Sample
+
+ .area _BASE
+ .AUD3WAVERAM = 0xff30
+
+_play_sample::
+ push bc
+ lda hl,4(sp)
+ ld a,(hl+)
+ ld d,(hl)
+ ld e,a
+
+ lda hl,6(sp)
+ ld a,(hl+)
+ ld b,(hl)
+ ld c,a
+
+ ld h,d
+ ld l,e
+
+ call .play_sample
+ pop bc
+ ret
+
+; Playback raw sound sample with length BC from HL at 8192Hz rate.
+; BC defines the length of the sample in samples/32 or bytes/16.
+; The format of the data is unsigned 4-bit samples,
+; 2 samples per byte, upper 4-bits played before lower 4 bits.
+;
+; Adaption for GBDK by Lars Malmborg.
+; Original code by Jeff Frohwein.
+
+.play_sample::
+ ld a,#0x84
+ ldh (.NR52),a ;enable sound 3
+
+ ld a,#0
+ ldh (.NR30),a
+ ldh (.NR51),a
+
+ ld a,#0x77
+ ldh (.NR50),a ;select speakers
+ ld a,#0xff
+ ldh (.NR51),a ;enable sound 3
+
+ ld a,#0x80
+ ldh (.NR31),a ;sound length
+ ld a,#0x20
+ ldh (.NR32),a ;sound level high
+
+ ld a,#0x00
+ ldh (.NR33),a ;sound freq low
+
+.samp2:
+ ld de,#.AUD3WAVERAM ;12
+ push bc ;16
+ ld b,#16 ;16
+
+ xor a
+ ldh (.NR30),a
+.samp3:
+ ld a,(hl+) ;8
+ ld (de),a ;8
+ inc de ;8
+ dec b ;4
+ jr nz,.samp3 ;12
+
+ ld a,#0x80
+ ldh (.NR30),a
+
+ ld a,#0x87 ; (256hz)
+ ldh (.NR34),a
+
+ ld bc,#558 ;delay routine
+.samp4:
+ dec bc ;8
+ ld a,b ;4
+ or c ;4
+ jr nz,.samp4 ;12
+
+ ld a,#0 ;more delay
+ ld a,#0
+ ld a,#0
+
+ pop bc ;12
+ dec bc ;8
+ ld a,b ;4
+ or c ;4
+ jr nz,.samp2 ;12
+
+ ld a,#0xbb
+ ldh (.NR51),a ;disable sound 3
+ ret
diff --git a/gbdk/gbdk-lib/examples/gb/samptest/samptest.c b/gbdk/gbdk-lib/examples/gb/samptest/samptest.c
new file mode 100644
index 00000000..7f9581d5
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/samptest/samptest.c
@@ -0,0 +1,1641 @@
+/*
+ * Demonstration of sound sample player
+ * by Lars Malmborg <glue@df.lth.se>
+ */
+
+#include <stdint.h>
+#include <stdio.h>
+
+#include <gb/gb.h>
+
+#include "sample.h"
+
+#define SAMPLES 25768
+extern const uint8_t sample[];
+
+void main()
+{
+ puts("\n Ren & Stimpy\n");
+ while(1)
+ {
+ waitpad(J_START);
+ puts(".");
+ play_sample(sample, SAMPLES / 32);
+ waitpadup();
+ }
+}
+
+const uint8_t sample[] =
+{
+0x86,0x98,0x65,0x97,0x7b,0x79,0x66,0x77,
+0x87,0x76,0x88,0x89,0x88,0x68,0x88,0x99,
+0x66,0x78,0x88,0x69,0x79,0x87,0x78,0x86,
+0x67,0x77,0x87,0x98,0x86,0x8a,0x7a,0x89,
+0x76,0x75,0x96,0x64,0x76,0x67,0x6a,0x79,
+0x8a,0xaa,0x88,0x68,0x69,0x55,0x6a,0xa7,
+0x6b,0x98,0x92,0x78,0x66,0x88,0x68,0x97,
+0xa4,0x58,0x96,0x9b,0xcb,0x79,0xba,0x11,
+0x3a,0x00,0x8e,0xda,0xaf,0xb4,0x05,0x92,
+0x07,0xe5,0x6b,0xfa,0x45,0xb7,0x08,0xb8,
+0x77,0xd8,0x05,0xd2,0x27,0xee,0xa9,0xfc,
+0x60,0x45,0x40,0x5d,0xca,0xad,0xb5,0x37,
+0x97,0x46,0xa8,0x57,0xb6,0x26,0xc6,0x68,
+0xed,0x67,0xd7,0x02,0x48,0x36,0xcf,0x9a,
+0xb9,0x30,0x49,0x85,0xbb,0xc7,0x68,0x60,
+0x38,0x98,0x7e,0xe9,0x88,0x40,0x54,0x7a,
+0x7d,0xe8,0x85,0x43,0x66,0xa8,0xdc,0xa7,
+0x52,0x66,0x67,0xbb,0xb8,0x79,0x84,0x56,
+0x68,0x87,0x9a,0x97,0x77,0x35,0x86,0x9a,
+0x8a,0x96,0x53,0x37,0x57,0xdb,0xa9,0xc9,
+0x52,0x26,0x87,0x6d,0xc8,0x57,0x87,0x56,
+0x58,0x97,0x9c,0xa8,0x65,0x32,0x6a,0xc9,
+0x9a,0xa4,0x36,0xba,0x78,0xb6,0x05,0xbb,
+0x99,0x99,0x62,0x39,0xc9,0x9a,0xa9,0x74,
+0x03,0xaf,0x95,0x8a,0x60,0x3a,0xe9,0x88,
+0xb8,0x10,0x7f,0xd6,0x59,0x95,0x15,0xcf,
+0x85,0x8b,0x71,0x38,0xfc,0x65,0x98,0x44,
+0x7d,0xc8,0x69,0x97,0x43,0x8d,0xb6,0x59,
+0x88,0x44,0xbe,0x84,0x79,0x97,0x33,0x9d,
+0x95,0x78,0x75,0x46,0xcd,0x84,0x7a,0x95,
+0x34,0xbe,0x84,0x78,0x86,0x37,0xeb,0x64,
+0x8a,0x94,0x18,0xeb,0x64,0x78,0x85,0x5c,
+0xd8,0x46,0x9a,0x73,0x4b,0xe7,0x46,0x88,
+0x65,0xae,0x95,0x58,0x97,0x33,0xae,0x95,
+0x55,0x99,0x69,0xc9,0x56,0x78,0x85,0x36,
+0xca,0x64,0x59,0xb6,0x59,0xa9,0x65,0x7a,
+0x82,0x4b,0xb8,0x55,0x6a,0x74,0x9d,0x97,
+0x58,0xa8,0x25,0x7e,0xb6,0x35,0xaa,0x77,
+0x9a,0x86,0x78,0x85,0x36,0xcc,0x75,0x66,
+0x98,0x7a,0xa8,0x67,0x89,0x72,0x4c,0xe7,
+0x43,0x6a,0x96,0x89,0x77,0x77,0x77,0x44,
+0xbd,0x86,0x66,0x89,0x69,0xb8,0x56,0x89,
+0x95,0x35,0xdd,0x75,0x47,0xb9,0x79,0x87,
+0x77,0x78,0x52,0x6d,0xc7,0x56,0x68,0x78,
+0xda,0x75,0x68,0xa7,0x13,0xcf,0xa5,0x45,
+0x9a,0x89,0x98,0x77,0x87,0x63,0x3b,0xea,
+0x64,0x58,0x97,0x8b,0xa7,0x66,0x8a,0x63,
+0x4c,0xda,0x63,0x5a,0xb9,0x98,0x78,0x77,
+0x74,0x27,0xdc,0x85,0x34,0x99,0x9b,0x87,
+0x76,0x79,0x71,0x2a,0xec,0x74,0x87,0xbb,
+0xa7,0x68,0x89,0x74,0x22,0xbf,0xb7,0x34,
+0x7a,0x9a,0x96,0x78,0x78,0x74,0x16,0xdb,
+0x76,0x67,0x99,0x88,0x97,0x78,0x86,0x43,
+0x8c,0x99,0x75,0x79,0x99,0x88,0x97,0x88,
+0x75,0x37,0xbc,0xa6,0x57,0x9a,0x88,0x88,
+0x97,0x75,0x45,0x99,0x98,0x77,0x78,0x79,
+0x87,0xa9,0x77,0x41,0x4a,0xbb,0xb7,0x67,
+0x66,0x99,0x79,0x89,0x75,0x33,0x7a,0xb8,
+0x87,0x77,0x77,0x9a,0x98,0x78,0x51,0x49,
+0xbb,0xa8,0x76,0x67,0x89,0xa9,0x77,0x84,
+0x23,0x7a,0xca,0x98,0x66,0x58,0x9a,0x98,
+0x76,0x52,0x27,0x9b,0xec,0x85,0x45,0x89,
+0x89,0x98,0x87,0x53,0x47,0x9b,0xca,0x87,
+0x66,0x78,0x8a,0xa9,0x94,0x23,0x79,0x9c,
+0xcb,0x96,0x56,0x87,0x99,0x89,0x75,0x45,
+0x78,0x9a,0xa9,0xa7,0x87,0x67,0x9a,0x75,
+0x22,0x79,0xbb,0x89,0xa9,0x75,0x55,0x89,
+0x9a,0x87,0x53,0x46,0x77,0xba,0xbb,0x77,
+0x66,0x68,0x87,0x97,0x22,0x99,0x7a,0x7a,
+0xd9,0x76,0x55,0x88,0x79,0x78,0x85,0x66,
+0x65,0x79,0xab,0x98,0x98,0x69,0x88,0x71,
+0x05,0x8a,0xd8,0x9a,0xbb,0x75,0x46,0x78,
+0x98,0x97,0x46,0x75,0x77,0x89,0xa9,0x98,
+0x77,0x88,0x8a,0x60,0x26,0x7d,0xa7,0x9b,
+0xbb,0x84,0x47,0x89,0x98,0x85,0x46,0x77,
+0x78,0x9b,0xa9,0x86,0x67,0x97,0x87,0x83,
+0x16,0x69,0xa6,0x9b,0xcc,0x86,0x57,0x87,
+0x65,0x65,0x57,0x89,0x76,0x8a,0x9b,0x87,
+0x89,0x88,0x87,0x52,0x24,0x4a,0x78,0xbb,
+0xcb,0x88,0x67,0x66,0x66,0x77,0x56,0x77,
+0x86,0x79,0x8a,0xa8,0x98,0x89,0x86,0x87,
+0x24,0x46,0x96,0x88,0xac,0xd8,0xa8,0x78,
+0x85,0x55,0x68,0x89,0x87,0x87,0x87,0x87,
+0x78,0x89,0x98,0x88,0x88,0x78,0x88,0x78,
+0x87,0x88,0x87,0x78,0x87,0x87,0x78,0x88,
+0x88,0x87,0x77,0x77,0x77,0x78,0x87,0x77,
+0x76,0x77,0x77,0x78,0x78,0x87,0x88,0x89,
+0x87,0x77,0x77,0x78,0x87,0x78,0x77,0x77,
+0x77,0x78,0x88,0x77,0x88,0x77,0x88,0x78,
+0x88,0x88,0x88,0x88,0x88,0x87,0x77,0x87,
+0x78,0x88,0x87,0x88,0x88,0x78,0x88,0x77,
+0x77,0x78,0x77,0x88,0x77,0x88,0x88,0x88,
+0x89,0x77,0x77,0x78,0x87,0x68,0x77,0x87,
+0x77,0x78,0x88,0x77,0x77,0x77,0x87,0x67,
+0x78,0x88,0x88,0x88,0x88,0x88,0x88,0x87,
+0x77,0x77,0x77,0x77,0x87,0x78,0x88,0x78,
+0x77,0x87,0x77,0x77,0x78,0x88,0x87,0x78,
+0x88,0x77,0x77,0x88,0x76,0x77,0x77,0x88,
+0x77,0x77,0x88,0x87,0x78,0x88,0x87,0x78,
+0x77,0x88,0x88,0x88,0x89,0x88,0x78,0x87,
+0x87,0x68,0x88,0x87,0x87,0x88,0x77,0x77,
+0x87,0x88,0x77,0x78,0x88,0x88,0x88,0x88,
+0x88,0x77,0x77,0x78,0x76,0x67,0x77,0x77,
+0x67,0x87,0x78,0x77,0x77,0x88,0x87,0x78,
+0x77,0x77,0x87,0x88,0x88,0x78,0x87,0x88,
+0x88,0x78,0x77,0x87,0x77,0x78,0x87,0x77,
+0x77,0x88,0x78,0x88,0x88,0x88,0x78,0x89,
+0x97,0x78,0x78,0x87,0x78,0x88,0x88,0x77,
+0x87,0x78,0x88,0x77,0x77,0x88,0x78,0x89,
+0x88,0x87,0x78,0x78,0x88,0x77,0x88,0x88,
+0x77,0x88,0x87,0x87,0x77,0x88,0x87,0x87,
+0x78,0x88,0x87,0x88,0x88,0x78,0x77,0x88,
+0x87,0x77,0x77,0x87,0x77,0x77,0x88,0x87,
+0x77,0x78,0x87,0x78,0x87,0x78,0x88,0x88,
+0x88,0x88,0x88,0x88,0x98,0x78,0x78,0x77,
+0x77,0x77,0x78,0x88,0x87,0x78,0x87,0x77,
+0x77,0x88,0x77,0x87,0x78,0x88,0x88,0x78,
+0x88,0x77,0x87,0x78,0x76,0x77,0x88,0x88,
+0x87,0x88,0x87,0x78,0x78,0x88,0x87,0x77,
+0x88,0x78,0x88,0x88,0x87,0x88,0x88,0x88,
+0x88,0x76,0x78,0x87,0x77,0x78,0x87,0x78,
+0x77,0x78,0x87,0x77,0x78,0x88,0x77,0x88,
+0x88,0x78,0x77,0x77,0x78,0x77,0x77,0x77,
+0x87,0x78,0x88,0x76,0x78,0x88,0x88,0x87,
+0x87,0x78,0x77,0x88,0x88,0x87,0x78,0x98,
+0x87,0x78,0x88,0x77,0x87,0x78,0x87,0x88,
+0x77,0x88,0x87,0x77,0x88,0x77,0x77,0x77,
+0x87,0x78,0x87,0x78,0x87,0x78,0x88,0x87,
+0x78,0x87,0x78,0x77,0x78,0x77,0x88,0x87,
+0x88,0x88,0x76,0x88,0x77,0x77,0x78,0x87,
+0x88,0x88,0x88,0x88,0x76,0x78,0x77,0x78,
+0x88,0x88,0x78,0x87,0x88,0x88,0x87,0x78,
+0x87,0x78,0x77,0x88,0x87,0x78,0x77,0x77,
+0x87,0x77,0x77,0x76,0x78,0x88,0x88,0x77,
+0x87,0x88,0x77,0x77,0x77,0x76,0x78,0x88,
+0x88,0x87,0x88,0x88,0x77,0x78,0x87,0x77,
+0x78,0x87,0x88,0x88,0x88,0x88,0x88,0x78,
+0x87,0x77,0x77,0x88,0x78,0x98,0x88,0x88,
+0x78,0x77,0x88,0x76,0x78,0x88,0x88,0x88,
+0x87,0x77,0x77,0x77,0x78,0x77,0x77,0x77,
+0x78,0x78,0x88,0x78,0x87,0x77,0x77,0x87,
+0x67,0x88,0x78,0x77,0x88,0x88,0x77,0x78,
+0x87,0x67,0x77,0x78,0x88,0x78,0x88,0x88,
+0x87,0x87,0x88,0x77,0x78,0x87,0x88,0x79,
+0x87,0xa7,0x97,0x78,0x78,0x87,0x77,0x89,
+0x79,0x67,0x89,0x88,0x79,0x78,0x77,0x88,
+0x89,0x77,0x97,0x96,0x67,0x79,0x96,0x96,
+0x78,0x88,0x68,0x89,0x68,0x66,0x77,0x97,
+0xa6,0x67,0xa3,0xa4,0x68,0x39,0xa3,0x8b,
+0x93,0xaa,0x87,0xb3,0xc9,0x56,0xa5,0x6a,
+0x58,0x86,0x97,0x7b,0x76,0xc5,0x96,0x68,
+0x98,0x74,0xcb,0x1a,0x68,0x97,0x66,0xa6,
+0x87,0xa7,0x88,0x7d,0x79,0x7a,0x66,0x63,
+0x46,0x78,0x98,0xa9,0xc7,0xa8,0xb7,0x49,
+0x6a,0x86,0x77,0x86,0x44,0x88,0x57,0x88,
+0x69,0x9b,0xfa,0xad,0xab,0x73,0x00,0x05,
+0x45,0xbf,0xeb,0xb9,0x87,0x66,0x43,0x67,
+0x69,0x99,0xb8,0x69,0x43,0x31,0x59,0xca,
+0xdf,0xda,0x78,0x84,0x43,0x24,0x67,0x6d,
+0xc9,0x9a,0x67,0x69,0xb7,0x58,0xb8,0x79,
+0xb5,0x20,0x08,0xb3,0x8f,0xfa,0x48,0x96,
+0x34,0x89,0x98,0x8a,0x50,0x59,0x93,0x7f,
+0xf9,0x68,0xa7,0x37,0xb9,0x77,0x74,0x06,
+0xa5,0x8c,0xec,0x66,0x98,0x45,0x88,0x88,
+0x89,0x96,0x56,0x66,0x76,0x7b,0xa7,0x88,
+0x99,0x76,0x79,0x77,0x95,0x61,0x4a,0xd8,
+0x7b,0xc9,0x44,0x5a,0x78,0x8a,0x88,0x53,
+0x6c,0x86,0x68,0x98,0x43,0x4a,0xea,0x78,
+0xaa,0x65,0x77,0x88,0x79,0x87,0x31,0x7c,
+0xba,0xaa,0x74,0x37,0xb9,0x88,0x99,0x74,
+0x78,0x85,0x45,0xbb,0x74,0x9b,0x74,0x7c,
+0xc7,0x47,0xa9,0x67,0x8b,0x70,0x18,0xdd,
+0x67,0xba,0x53,0x59,0x97,0x78,0x98,0x43,
+0xad,0xa9,0x66,0x86,0x44,0x6a,0xc9,0x78,
+0x88,0x88,0x78,0x79,0x87,0x88,0x76,0x76,
+0x44,0xb7,0xac,0xb5,0x55,0x78,0x89,0x97,
+0x77,0x78,0x85,0x00,0x7e,0xe8,0x76,0x97,
+0x45,0xab,0x86,0x58,0x9a,0x64,0x6a,0xaa,
+0x87,0x47,0x79,0x8a,0x79,0x77,0x99,0x66,
+0x77,0x88,0xa9,0x84,0x56,0x9b,0x35,0xdd,
+0x75,0x59,0x96,0x6a,0x98,0x66,0x68,0x62,
+0x6b,0xb8,0x68,0xab,0x55,0x9a,0x86,0x79,
+0x88,0x98,0x55,0x26,0xd8,0x66,0xce,0x93,
+0x35,0x8a,0xc8,0x76,0x79,0xa7,0x55,0x65,
+0x66,0x6d,0xea,0x64,0x6a,0x97,0x56,0x88,
+0x76,0x6a,0xb9,0x57,0xa7,0x54,0x4a,0xa8,
+0x8a,0x99,0x65,0x98,0x68,0x88,0x86,0x57,
+0x9b,0x94,0x66,0x67,0x28,0xfd,0x75,0x59,
+0x77,0x9a,0x89,0x67,0x70,0x3c,0xe8,0x3b,
+0xa9,0x16,0xca,0x57,0x8a,0x96,0x38,0xca,
+0x75,0x68,0x56,0x5a,0xec,0x86,0x58,0x97,
+0x79,0x77,0x77,0x98,0x12,0xde,0x46,0xac,
+0x93,0x6b,0x85,0x57,0x99,0x64,0x6c,0xa8,
+0x58,0x88,0x67,0x86,0x77,0x86,0x99,0xa8,
+0x78,0x87,0x87,0x77,0x77,0x99,0x76,0x86,
+0x76,0x46,0xda,0x98,0x87,0x66,0x8c,0xa8,
+0x76,0x65,0x06,0xa6,0xbd,0xca,0x65,0x76,
+0x47,0x99,0x76,0x6b,0x96,0x69,0x76,0x68,
+0xa7,0x65,0x69,0x85,0xa9,0xa8,0x8a,0x76,
+0x77,0x77,0x88,0x98,0x77,0x77,0x52,0x8d,
+0xb8,0x8a,0x85,0x47,0x88,0x87,0x88,0x76,
+0x56,0x95,0x5e,0xb9,0x97,0xa7,0x57,0x77,
+0x88,0x77,0x79,0xa7,0x98,0x86,0x45,0x57,
+0x6b,0x7b,0xb9,0xb7,0x77,0x66,0x76,0x66,
+0x77,0x59,0x68,0x98,0x99,0x8a,0x78,0x88,
+0x66,0x68,0x88,0x87,0x76,0x48,0x84,0xa9,
+0x88,0x87,0x97,0x69,0x77,0x88,0x77,0x78,
+0x89,0x79,0x88,0x76,0x87,0x77,0x78,0x87,
+0x78,0x78,0x79,0x87,0x86,0x7a,0x68,0x77,
+0x77,0x86,0x87,0x78,0x88,0x77,0x77,0x87,
+0x88,0x79,0x88,0x97,0x87,0x77,0x77,0x67,
+0x76,0x77,0x87,0x78,0x78,0x87,0x78,0x88,
+0x89,0x98,0x88,0x89,0x87,0x77,0x77,0x77,
+0x78,0x76,0x77,0x77,0x77,0x88,0x87,0x87,
+0x88,0x78,0x88,0x88,0x88,0x88,0x88,0x87,
+0x77,0x76,0x77,0x77,0x77,0x77,0x78,0x88,
+0x88,0x88,0x88,0x87,0x87,0x77,0x77,0x88,
+0x88,0x98,0x87,0x88,0x87,0x77,0x77,0x87,
+0x77,0x87,0x88,0x88,0x77,0x77,0x87,0x77,
+0x78,0x77,0x89,0x88,0x98,0x88,0x77,0x77,
+0x77,0x76,0x67,0x67,0x87,0x78,0x88,0x87,
+0x78,0x87,0x88,0x87,0x77,0x88,0x88,0x98,
+0x98,0x87,0x87,0x77,0x77,0x76,0x78,0x77,
+0x88,0x87,0x88,0x88,0x77,0x87,0x77,0x87,
+0x87,0x78,0x88,0x88,0x88,0x87,0x88,0x77,
+0x77,0x77,0x77,0x88,0x77,0x77,0x77,0x77,
+0x78,0x88,0x88,0x87,0x78,0x87,0x88,0x78,
+0x87,0x88,0x88,0x88,0x88,0x87,0x87,0x78,
+0x87,0x77,0x88,0x87,0x78,0x88,0x77,0x87,
+0x77,0x77,0x87,0x77,0x88,0x87,0x78,0x88,
+0x78,0x87,0x77,0x78,0x77,0x67,0x87,0x78,
+0x88,0x88,0x88,0x87,0x78,0x77,0x78,0x87,
+0x87,0x88,0x88,0x88,0x88,0x87,0x87,0x77,
+0x77,0x67,0x77,0x88,0x78,0x88,0x88,0x97,
+0x78,0x78,0x87,0x77,0x89,0x88,0x78,0x87,
+0x78,0x87,0x77,0x77,0x86,0x77,0x88,0x88,
+0x88,0x87,0x88,0x87,0x88,0x77,0x88,0x88,
+0x88,0x98,0x88,0x88,0x87,0x78,0x78,0x67,
+0x77,0x77,0x77,0x98,0x78,0x88,0x78,0x87,
+0x77,0x68,0x87,0x77,0x98,0x87,0x76,0x96,
+0x87,0x87,0x87,0x79,0x68,0x77,0x87,0x87,
+0x87,0x89,0x69,0x87,0x86,0x87,0x89,0x89,
+0x79,0x98,0x76,0x88,0x69,0x86,0x77,0x87,
+0x87,0x79,0x78,0x96,0x97,0x69,0x78,0x86,
+0x78,0x59,0x98,0x78,0x88,0x86,0x88,0x68,
+0x97,0x56,0x68,0x85,0x65,0xa6,0x46,0x7a,
+0x75,0x79,0x76,0x67,0x98,0x97,0x99,0x6a,
+0x6b,0x86,0xc5,0xa5,0xa7,0x57,0x78,0x4a,
+0x48,0x56,0x8a,0x87,0x8a,0x78,0x88,0x78,
+0xa8,0x4a,0x96,0x79,0x6a,0x87,0x67,0x86,
+0x86,0x69,0x67,0xa8,0x88,0x89,0x7a,0x86,
+0x85,0x88,0x74,0x45,0x87,0x38,0x67,0x86,
+0xa7,0x9b,0xa8,0xba,0x78,0x89,0x55,0x96,
+0x74,0x75,0x67,0x67,0x69,0x97,0x8d,0xa8,
+0xa8,0xaa,0x59,0x69,0x44,0x77,0x84,0x66,
+0x65,0x49,0x77,0x98,0xcb,0x7a,0xcb,0x58,
+0x98,0x33,0x46,0x60,0x49,0xc5,0x9b,0xfc,
+0x6d,0xd8,0x76,0x58,0x04,0x72,0x7a,0x16,
+0xb8,0x58,0xba,0x87,0xde,0x9a,0xca,0x66,
+0x68,0x41,0x11,0x95,0x06,0xea,0x7e,0xfc,
+0x8a,0xa7,0x43,0x43,0x12,0x87,0x8a,0xca,
+0x9c,0x67,0x65,0x43,0x67,0x8b,0xcc,0xb9,
+0x99,0x46,0x85,0x65,0x5b,0x99,0x82,0x98,
+0x36,0xa7,0xab,0xcb,0xb9,0xa7,0x44,0x67,
+0x35,0x67,0x8b,0x58,0x89,0xa8,0x6b,0xb9,
+0x78,0x78,0x64,0x55,0x77,0x67,0x79,0x76,
+0x58,0xdb,0x8b,0xb9,0x47,0x66,0x47,0x99,
+0x67,0xb9,0x76,0x13,0x67,0x6c,0xec,0xca,
+0x89,0x63,0x43,0x44,0xcb,0x87,0xca,0x98,
+0x75,0x05,0x34,0x6b,0xef,0xbb,0xc9,0x35,
+0x12,0x49,0x6a,0xbb,0x98,0x89,0x20,0x06,
+0x87,0xef,0xd9,0xa9,0x85,0x23,0x77,0x47,
+0xec,0x89,0xa8,0x85,0x03,0x86,0x48,0xfd,
+0x97,0xb9,0x52,0x36,0x67,0x7b,0xfa,0x88,
+0x98,0x64,0x34,0x79,0x76,0x9d,0xc8,0x87,
+0x97,0x34,0x9a,0x87,0x89,0x86,0x89,0x62,
+0x68,0x44,0x9b,0xea,0x89,0xa5,0x34,0x76,
+0x8b,0x98,0x78,0x74,0x79,0xb8,0x68,0x88,
+0x45,0x53,0x5d,0xba,0x9b,0x97,0x45,0x87,
+0x85,0x8b,0x98,0x77,0x65,0x56,0x85,0x19,
+0xfc,0x68,0xca,0x63,0x6a,0x65,0x67,0xa8,
+0x98,0x9a,0x56,0x36,0x51,0x7d,0xf9,0x8b,
+0x97,0x34,0x78,0x78,0x89,0xa8,0x79,0x86,
+0x56,0x48,0x85,0x7c,0xc8,0x8a,0x98,0x46,
+0x76,0x68,0x88,0x99,0xa7,0x87,0x66,0x36,
+0x86,0x37,0xda,0x79,0xa9,0x53,0x6b,0x77,
+0x8a,0xa8,0x78,0x96,0x47,0x76,0x8a,0x63,
+0x8a,0x93,0x7e,0xb4,0x7b,0x96,0x58,0x77,
+0x58,0xb7,0x57,0x77,0x57,0x95,0x47,0xaa,
+0x98,0x9a,0x66,0x88,0x87,0x88,0x76,0x6a,
+0x66,0x5a,0x87,0x98,0x93,0x54,0x39,0x9a,
+0xad,0xb9,0x77,0x74,0x37,0x96,0x7c,0xa9,
+0x76,0x86,0x56,0x64,0x59,0x86,0x5c,0xb9,
+0x89,0xb9,0x56,0x65,0x68,0x66,0x88,0x98,
+0x88,0x87,0x57,0x65,0x66,0x97,0x6b,0xba,
+0x9a,0x89,0x62,0x34,0x86,0xac,0xcc,0x88,
+0x86,0x55,0x44,0x78,0x88,0xba,0x97,0x36,
+0x44,0x58,0xad,0xeb,0xb9,0x99,0x45,0x33,
+0x49,0x79,0xa9,0xc7,0x78,0x86,0x24,0x4b,
+0x86,0xeb,0xc9,0x89,0x75,0x46,0x56,0x39,
+0x98,0xaa,0xc8,0x57,0x65,0x67,0x9a,0xa6,
+0xa9,0x65,0x09,0xc4,0x9b,0xaa,0x88,0xb7,
+0x56,0x67,0x56,0x97,0x79,0x8a,0x96,0x87,
+0x76,0x53,0x49,0x67,0xb9,0xca,0x8c,0x96,
+0x76,0x57,0x68,0x95,0x99,0x89,0x88,0x76,
+0x87,0x86,0x68,0x74,0x68,0x76,0x89,0xba,
+0xaa,0x88,0x76,0x75,0x57,0x66,0x87,0x87,
+0x78,0x77,0x98,0x77,0x78,0x97,0x88,0x78,
+0x88,0x87,0x88,0x88,0x89,0x88,0x79,0x97,
+0x77,0x67,0x87,0x77,0x77,0x88,0x87,0x87,
+0x67,0x77,0x67,0x77,0x88,0x89,0x88,0x88,
+0x88,0x88,0x88,0x88,0x98,0x77,0x77,0x76,
+0x77,0x78,0x77,0x77,0x77,0x79,0x88,0x77,
+0x98,0x88,0x78,0x88,0x87,0x77,0x77,0x77,
+0x88,0x77,0x78,0x77,0x76,0x78,0x88,0x77,
+0x88,0x88,0x78,0x78,0x77,0x88,0x77,0x78,
+0x88,0x76,0x78,0x77,0x87,0x88,0x87,0x88,
+0x88,0x78,0x89,0x87,0x88,0x88,0x88,0x78,
+0x88,0x87,0x88,0x87,0x78,0x77,0x77,0x88,
+0x87,0x88,0x88,0x87,0x87,0x87,0x77,0x66,
+0x77,0x78,0x87,0x78,0x78,0x87,0x78,0x88,
+0x87,0x77,0x77,0x77,0x87,0x77,0x88,0x77,
+0x87,0x88,0x88,0x78,0x87,0x78,0x88,0x87,
+0x78,0x87,0x78,0x88,0x98,0x77,0x77,0x77,
+0x77,0x88,0x78,0x88,0x78,0x88,0x88,0x77,
+0x77,0x77,0x78,0x88,0x87,0x88,0x78,0x88,
+0x87,0x77,0x77,0x77,0x77,0x78,0x88,0x77,
+0x88,0x78,0x88,0x77,0x77,0x88,0x78,0x88,
+0x98,0x98,0x88,0x88,0x87,0x87,0x77,0x77,
+0x77,0x77,0x78,0x88,0x87,0x88,0x87,0x78,
+0x87,0x87,0x77,0x78,0x77,0x88,0x88,0x78,
+0x87,0x77,0x87,0x78,0x77,0x77,0x87,0x88,
+0x88,0x78,0x87,0x77,0x77,0x87,0x77,0x78,
+0x88,0x88,0x88,0x88,0x88,0x87,0x77,0x88,
+0x77,0x77,0x78,0x77,0x77,0x88,0x88,0x88,
+0x77,0x87,0x87,0x77,0x88,0x77,0x87,0x78,
+0x87,0x78,0x77,0x78,0x77,0x87,0x88,0x87,
+0x77,0x88,0x88,0x88,0x87,0x88,0x87,0x78,
+0x87,0x87,0x77,0x88,0x88,0x87,0x78,0x87,
+0x78,0x77,0x87,0x77,0x77,0x78,0x87,0x88,
+0x88,0x98,0x77,0x77,0x78,0x87,0x88,0x78,
+0x77,0x77,0x77,0x88,0x87,0x67,0x78,0x78,
+0x77,0x77,0x77,0x78,0x88,0x88,0x98,0x77,
+0x78,0x88,0x88,0x88,0x77,0x88,0x78,0x87,
+0x87,0x77,0x78,0x78,0x77,0x88,0x77,0x78,
+0x88,0x98,0x88,0x77,0x77,0x77,0x77,0x78,
+0x87,0x77,0x78,0x88,0x87,0x88,0x77,0x77,
+0x77,0x77,0x78,0x77,0x88,0x88,0x97,0x78,
+0x87,0x88,0x87,0x88,0x78,0x87,0x78,0x88,
+0x88,0x77,0x87,0x77,0x77,0x88,0x78,0x78,
+0x88,0x88,0x98,0x78,0x77,0x77,0x67,0x77,
+0x78,0x77,0x88,0x77,0x87,0x78,0x87,0x77,
+0x77,0x77,0x78,0x77,0x88,0x88,0x88,0x88,
+0x77,0x87,0x77,0x88,0x88,0x88,0x88,0x78,
+0x87,0x78,0x77,0x77,0x77,0x77,0x88,0x78,
+0x89,0x88,0x87,0x88,0x77,0x77,0x77,0x77,
+0x87,0x78,0x88,0x78,0x77,0x87,0x77,0x77,
+0x77,0x77,0x88,0x78,0x88,0x78,0x88,0x78,
+0x88,0x87,0x78,0x78,0x88,0x88,0x88,0x78,
+0x78,0x77,0x77,0x77,0x77,0x78,0x87,0x78,
+0x87,0x88,0x88,0x88,0x77,0x87,0x77,0x78,
+0x78,0x77,0x87,0x77,0x78,0x78,0x87,0x88,
+0x77,0x78,0x78,0x87,0x88,0x87,0x88,0x78,
+0x88,0x87,0x87,0x89,0x88,0x88,0x87,0x87,
+0x88,0x77,0x88,0x77,0x77,0x88,0x78,0x87,
+0x77,0x87,0x87,0x87,0x77,0x77,0x76,0x88,
+0x77,0x87,0x78,0x77,0x87,0x77,0x77,0x78,
+0x77,0x88,0x87,0x87,0x78,0x88,0x88,0x87,
+0x87,0x78,0x78,0x88,0x87,0x88,0x88,0x88,
+0x78,0x76,0x77,0x77,0x78,0x88,0x77,0x87,
+0x88,0x88,0x88,0x87,0x77,0x77,0x77,0x88,
+0x77,0x77,0x88,0x88,0x88,0x77,0x77,0x77,
+0x78,0x88,0x78,0x88,0x88,0x88,0x89,0x77,
+0x87,0x87,0x78,0x88,0x78,0x88,0x88,0x88,
+0x88,0x77,0x77,0x77,0x78,0x87,0x78,0x78,
+0x88,0x88,0x88,0x77,0x77,0x77,0x77,0x77,
+0x77,0x78,0x88,0x88,0x88,0x87,0x77,0x77,
+0x78,0x77,0x77,0x78,0x88,0x88,0x88,0x77,
+0x78,0x77,0x78,0x87,0x77,0x78,0x98,0x88,
+0x88,0x87,0x78,0x87,0x88,0x77,0x77,0x78,
+0x98,0x88,0x88,0x87,0x78,0x87,0x87,0x77,
+0x77,0x78,0x87,0x88,0x87,0x77,0x78,0x77,
+0x88,0x87,0x77,0x78,0x87,0x88,0x87,0x87,
+0x88,0x77,0x88,0x87,0x77,0x88,0x88,0x88,
+0x87,0x87,0x78,0x77,0x88,0x87,0x77,0x88,
+0x88,0x87,0x77,0x87,0x78,0x87,0x87,0x87,
+0x77,0x78,0x88,0x77,0x77,0x77,0x77,0x77,
+0x78,0x87,0x78,0x88,0x87,0x77,0x77,0x78,
+0x78,0x87,0x88,0x88,0x88,0x88,0x88,0x78,
+0x77,0x87,0x78,0x87,0x78,0x88,0x88,0x88,
+0x87,0x78,0x77,0x88,0x78,0x87,0x78,0x88,
+0x78,0x88,0x77,0x67,0x77,0x87,0x78,0x87,
+0x88,0x88,0x87,0x88,0x77,0x77,0x67,0x87,
+0x78,0x77,0x89,0x87,0x88,0x88,0x77,0x78,
+0x77,0x87,0x87,0x77,0x88,0x87,0x87,0x87,
+0x77,0x77,0x78,0x87,0x87,0x77,0x88,0x77,
+0x76,0x87,0x77,0x77,0x78,0x76,0x88,0x87,
+0x88,0x77,0x77,0x88,0x87,0x78,0x87,0x78,
+0x87,0x88,0x88,0x87,0x77,0x87,0x88,0x78,
+0x88,0x78,0x87,0x87,0x78,0x77,0x77,0x87,
+0x87,0x78,0x88,0x78,0x88,0x87,0x78,0x88,
+0x67,0x77,0x87,0x78,0x88,0x78,0x87,0x87,
+0x68,0x88,0x78,0x77,0x87,0x78,0x88,0x78,
+0x87,0x77,0x68,0x88,0x88,0x77,0x88,0x78,
+0x97,0x88,0x77,0x77,0x77,0x88,0x78,0x77,
+0x88,0x77,0x98,0x78,0x77,0x77,0x77,0x88,
+0x77,0x77,0x87,0x78,0x77,0x86,0x77,0x87,
+0x78,0x78,0x86,0x78,0x88,0x78,0x77,0x87,
+0x88,0x88,0x78,0x87,0x87,0x78,0x98,0x78,
+0x77,0x77,0x78,0x88,0x88,0x78,0x77,0x88,
+0x88,0x88,0x78,0x87,0x88,0x78,0x88,0x88,
+0x86,0x78,0x77,0x78,0x77,0x77,0x78,0x78,
+0x88,0x78,0x87,0x77,0x77,0x88,0x88,0x77,
+0x87,0x78,0x88,0x88,0x77,0x77,0x78,0x88,
+0x88,0x77,0x88,0x78,0x88,0x88,0x66,0x77,
+0x77,0x88,0x88,0x78,0x88,0x87,0x87,0x88,
+0x66,0x77,0x77,0x88,0x88,0x77,0x88,0x87,
+0x87,0x87,0x76,0x78,0x87,0x77,0x88,0x88,
+0x88,0x88,0x77,0x87,0x87,0x77,0x88,0x77,
+0x88,0x88,0x78,0x88,0x76,0x77,0x77,0x77,
+0x88,0x87,0x78,0x98,0x87,0x78,0x77,0x67,
+0x77,0x87,0x68,0x88,0x67,0x88,0x88,0x67,
+0x87,0x77,0x88,0x78,0x77,0x88,0x76,0x88,
+0x88,0x77,0x88,0x77,0x78,0x89,0x87,0x88,
+0x77,0x78,0x88,0x87,0x78,0x87,0x77,0x98,
+0x87,0x77,0x77,0x77,0x88,0x78,0x78,0x88,
+0x77,0x89,0x77,0x76,0x77,0x77,0x89,0x88,
+0x87,0x88,0x77,0x79,0x87,0x76,0x78,0x87,
+0x89,0x88,0x88,0x78,0x87,0x78,0x77,0x77,
+0x68,0x87,0x88,0x88,0x88,0x78,0x87,0x77,
+0x78,0x77,0x77,0x98,0x78,0x89,0x88,0x87,
+0x87,0x77,0x77,0x87,0x77,0x88,0x77,0x87,
+0x98,0x78,0x77,0x77,0x77,0x78,0x78,0x77,
+0x88,0x77,0x89,0x88,0x78,0x77,0x77,0x78,
+0x87,0x78,0x77,0x87,0x88,0x97,0x77,0x87,
+0x78,0x78,0x88,0x77,0x87,0x78,0x77,0x88,
+0x76,0x78,0x88,0x77,0x88,0x86,0x88,0x77,
+0x87,0x87,0x87,0x78,0x88,0x87,0x88,0x88,
+0x78,0x87,0x78,0x77,0x78,0x77,0x88,0x87,
+0x77,0x88,0x87,0x78,0x77,0x87,0x78,0x88,
+0x78,0x87,0x87,0x78,0x87,0x78,0x87,0x77,
+0x77,0x78,0x77,0x77,0x77,0x68,0x88,0x77,
+0x88,0x77,0x77,0x78,0x88,0x88,0x78,0x88,
+0x88,0x88,0x88,0x87,0x77,0x78,0x87,0x88,
+0x77,0x78,0x88,0x88,0x88,0x77,0x77,0x88,
+0x88,0x87,0x87,0x88,0x88,0x88,0x87,0x87,
+0x77,0x78,0x87,0x88,0x78,0x78,0x88,0x87,
+0x88,0x78,0x77,0x87,0x77,0x78,0x88,0x88,
+0x88,0x88,0x88,0x77,0x87,0x77,0x78,0x78,
+0x78,0x88,0x88,0x88,0x78,0x87,0x77,0x78,
+0x78,0x77,0x88,0x78,0x88,0x88,0x87,0x77,
+0x67,0x77,0x77,0x77,0x77,0x87,0x98,0x88,
+0x87,0x77,0x76,0x87,0x78,0x77,0x77,0x78,
+0x88,0x88,0x88,0x77,0x77,0x77,0x77,0x78,
+0x78,0x77,0x88,0x88,0x88,0x87,0x77,0x87,
+0x77,0x88,0x77,0x77,0x88,0x88,0x88,0x88,
+0x77,0x77,0x77,0x78,0x78,0x88,0x88,0x78,
+0x89,0x77,0x88,0x88,0x77,0x78,0x66,0x88,
+0x79,0x77,0x88,0x77,0x88,0x99,0x66,0x88,
+0x77,0x86,0x89,0x67,0x98,0x67,0x87,0x89,
+0x67,0x88,0x77,0x87,0x79,0x77,0x88,0x77,
+0x88,0x89,0x77,0x87,0x66,0x77,0x79,0x76,
+0x87,0x77,0x88,0x89,0x67,0x88,0x67,0x87,
+0x78,0x77,0x97,0x78,0x77,0x99,0x78,0x98,
+0x67,0x78,0x88,0x68,0x87,0x68,0x88,0x8a,
+0x77,0x88,0x77,0x78,0x88,0x77,0x87,0x68,
+0x97,0x89,0x87,0x97,0x78,0x76,0x88,0x67,
+0x87,0x67,0x88,0x78,0x77,0x87,0x57,0x87,
+0x79,0x77,0x98,0x67,0x87,0x79,0x76,0x98,
+0x68,0x97,0x79,0x87,0x98,0x57,0x97,0x79,
+0x76,0x88,0x58,0x97,0x79,0x87,0x98,0x67,
+0xa8,0x79,0x87,0x88,0x67,0x86,0x7a,0x76,
+0x98,0x57,0x97,0x79,0x77,0x88,0x59,0x96,
+0x79,0x76,0x87,0x68,0x97,0x89,0x77,0x96,
+0x58,0x96,0x79,0x77,0x97,0x68,0x86,0x78,
+0x77,0x97,0x69,0x96,0x79,0x89,0xa8,0x6a,
+0x97,0x99,0x77,0x87,0x59,0x86,0x79,0x88,
+0x87,0x58,0x87,0x88,0x78,0x88,0x69,0x65,
+0x78,0x68,0xa6,0x79,0x76,0x88,0x79,0x99,
+0x89,0x86,0x88,0x67,0x87,0x68,0x87,0x78,
+0x88,0x87,0x78,0x76,0x89,0x88,0x98,0x88,
+0x66,0x77,0x78,0x87,0x89,0x76,0x77,0x88,
+0x88,0x89,0x87,0x87,0x77,0x78,0x79,0x97,
+0x78,0x88,0x87,0x78,0x87,0x88,0x88,0x88,
+0x77,0x66,0x66,0x78,0x87,0x78,0x87,0x66,
+0x88,0x89,0x89,0x98,0x88,0x76,0x57,0x67,
+0x89,0x87,0x89,0x88,0x77,0x99,0x77,0x88,
+0x88,0x87,0x77,0x66,0x77,0x99,0x67,0x88,
+0x66,0x78,0x88,0x88,0x88,0x88,0x86,0x78,
+0x66,0x7a,0x86,0x88,0x97,0x77,0x99,0x88,
+0xa8,0x79,0x97,0x66,0x76,0x67,0x88,0x76,
+0x79,0x76,0x78,0x88,0x89,0x78,0x87,0x66,
+0x56,0x76,0x78,0x98,0x77,0x88,0x88,0x78,
+0x88,0x99,0x78,0x98,0x77,0x78,0x77,0x78,
+0x97,0x68,0x87,0x77,0x87,0x98,0x78,0x88,
+0x88,0x66,0x88,0x67,0x87,0x67,0x77,0x87,
+0x67,0x99,0x89,0x76,0x98,0x76,0x77,0x77,
+0x76,0x98,0x67,0x88,0x88,0x77,0x99,0x98,
+0x78,0x77,0x55,0x78,0x78,0x89,0x88,0x77,
+0x97,0x78,0x98,0x9a,0x87,0x88,0x87,0x77,
+0x88,0x76,0x88,0x77,0x88,0x88,0x77,0x87,
+0x89,0x78,0x88,0x76,0x76,0x78,0x77,0x97,
+0x68,0x86,0x78,0x88,0x99,0x87,0x77,0x78,
+0x76,0x98,0x67,0x77,0x77,0x79,0x76,0x77,
+0x77,0x9a,0x77,0x87,0x77,0x76,0x77,0x78,
+0x86,0x68,0x87,0x78,0x78,0x98,0x88,0x77,
+0x88,0x88,0x88,0x88,0x77,0x78,0x88,0xa7,
+0x89,0x98,0x89,0x87,0x87,0x88,0x66,0x77,
+0x67,0x87,0x67,0x88,0x77,0x89,0x99,0x88,
+0x87,0x78,0x77,0x88,0x77,0x87,0x77,0x88,
+0x88,0x77,0x99,0x88,0x66,0x67,0x75,0x77,
+0x78,0x76,0x77,0x87,0x78,0x87,0x88,0x78,
+0x87,0x77,0x88,0x98,0x78,0x97,0x77,0x78,
+0x99,0x77,0x88,0x87,0x88,0x88,0x67,0x87,
+0x76,0x77,0x77,0x66,0x77,0x97,0x78,0x9a,
+0x87,0x88,0x87,0x78,0x99,0x98,0x87,0x88,
+0x77,0x9a,0x98,0x87,0x87,0x67,0x87,0x78,
+0x66,0x87,0x65,0x67,0x77,0x76,0x87,0x76,
+0x78,0x88,0x86,0x79,0x87,0x89,0x99,0x86,
+0x68,0x77,0x88,0x98,0x98,0x78,0x87,0x67,
+0x88,0x86,0x57,0x76,0x67,0x88,0x89,0x87,
+0x88,0x77,0x9a,0x97,0x78,0x88,0x88,0x99,
+0x88,0x77,0x78,0x89,0x88,0x86,0x67,0x77,
+0x77,0x77,0x88,0x76,0x66,0x66,0x67,0x88,
+0x87,0x76,0x67,0x88,0x88,0x88,0x77,0x88,
+0x87,0x88,0x86,0x78,0x89,0x99,0x99,0x88,
+0x87,0x67,0x66,0x78,0x98,0x88,0x87,0x77,
+0x87,0x87,0x87,0x67,0x89,0x88,0x98,0x98,
+0x89,0x78,0x87,0x88,0x88,0x98,0x77,0x74,
+0x66,0x77,0x97,0x98,0x98,0x97,0x88,0x76,
+0x77,0x66,0x65,0x46,0x52,0x47,0x76,0x8a,
+0xba,0xcc,0xa9,0x78,0x76,0x57,0x85,0x46,
+0x64,0x56,0x78,0xbc,0x9b,0xcb,0x88,0x78,
+0x56,0x77,0x67,0x75,0x25,0x86,0x47,0xcd,
+0x7b,0xde,0x9a,0xb9,0x57,0x86,0x58,0x99,
+0x32,0x77,0x44,0x9c,0xb8,0xde,0xb7,0xbb,
+0x62,0x68,0x73,0x67,0x33,0x44,0x33,0x8a,
+0xa6,0xbe,0xc8,0x9a,0xa5,0x68,0x83,0x55,
+0x44,0x85,0x55,0xa9,0xca,0xca,0xca,0xa8,
+0x95,0x55,0x64,0x74,0x15,0x54,0x38,0x9a,
+0xac,0xde,0xab,0x99,0x67,0x77,0x67,0x85,
+0x14,0x45,0x39,0xac,0xbf,0xfc,0x9a,0xb7,
+0x58,0x85,0x22,0x21,0x63,0x25,0x9b,0x99,
+0xdd,0xb9,0x99,0x77,0x66,0x55,0x74,0x06,
+0x37,0x29,0x8c,0xbe,0xcd,0xad,0xb8,0x57,
+0x66,0x55,0x52,0x52,0x43,0x89,0xa9,0xed,
+0xdb,0xb9,0x97,0x65,0x56,0x53,0x33,0x67,
+0x59,0xaa,0x9a,0xdc,0xac,0xb8,0x98,0x87,
+0x55,0x33,0x28,0x34,0x47,0x9b,0xae,0xc8,
+0xcc,0x76,0x55,0x64,0x36,0x42,0x37,0x55,
+0x77,0xaa,0x9d,0xda,0xba,0xa7,0x65,0x76,
+0x55,0x41,0x86,0x84,0x99,0x88,0xab,0xba,
+0xb9,0x98,0x76,0x64,0x68,0x64,0x88,0x56,
+0x89,0x99,0x9c,0xb9,0x99,0x88,0x78,0x76,
+0x89,0x87,0x48,0x88,0x98,0x99,0x56,0x77,
+0x77,0x78,0x88,0x66,0x66,0x66,0x87,0x78,
+0x67,0x76,0x77,0x66,0x89,0xa8,0x78,0x88,
+0x78,0x9a,0x88,0x98,0x78,0x88,0x77,0x76,
+0x55,0x67,0x89,0x78,0x88,0x78,0x88,0x78,
+0x88,0x98,0x88,0x88,0x78,0x87,0x78,0x88,
+0x77,0x77,0x89,0x77,0x88,0x88,0x98,0x89,
+0x87,0x87,0x77,0x77,0x77,0x76,0x65,0x77,
+0x66,0x56,0x66,0x78,0x89,0x77,0x98,0x89,
+0x99,0x78,0x76,0x78,0x88,0x88,0x87,0x79,
+0x87,0x78,0x77,0x88,0x87,0x67,0x77,0x78,
+0x88,0x78,0x87,0x77,0x99,0x99,0x87,0x77,
+0x78,0x88,0x88,0x86,0x78,0x87,0x79,0x88,
+0x99,0x98,0x88,0x77,0x77,0x76,0x77,0x66,
+0x67,0x87,0x65,0x86,0x56,0x77,0x68,0x96,
+0x78,0x98,0x87,0x77,0x66,0x78,0x98,0x89,
+0x77,0x98,0x88,0x89,0x87,0x78,0x86,0x78,
+0x68,0x88,0x98,0x88,0x88,0x78,0x87,0x87,
+0x87,0x77,0x79,0x99,0x98,0x87,0x68,0x97,
+0x88,0x88,0x99,0x98,0x88,0x77,0x66,0x66,
+0x67,0x78,0x77,0x87,0x76,0x77,0x66,0x76,
+0x88,0x77,0x77,0x89,0x86,0x57,0x86,0x68,
+0x79,0x88,0x66,0x68,0x89,0x99,0xa9,0x87,
+0x78,0x77,0x89,0x89,0xa8,0x67,0x88,0x78,
+0x89,0x96,0x59,0x66,0x89,0xaa,0x89,0x76,
+0x77,0x87,0x88,0x88,0x68,0x98,0x87,0x98,
+0x86,0x67,0x66,0x88,0x87,0x98,0x76,0x65,
+0x67,0x78,0x87,0x88,0x66,0x77,0x77,0x78,
+0x78,0x76,0x76,0x67,0x88,0x79,0xa9,0x88,
+0x88,0x88,0x88,0x97,0x66,0x77,0x89,0x88,
+0x79,0x97,0x78,0x75,0x78,0x78,0x98,0x89,
+0x96,0x78,0x98,0x97,0x66,0x78,0x88,0xa9,
+0x88,0x76,0x77,0x78,0x88,0x78,0x76,0x77,
+0x76,0x68,0x77,0x77,0x56,0x77,0x68,0x88,
+0x79,0x75,0x68,0x88,0x75,0x67,0x87,0x78,
+0x8a,0xa8,0x79,0xa8,0x88,0x98,0x78,0x77,
+0x99,0x87,0x79,0x99,0x87,0x77,0x67,0x89,
+0x89,0xa9,0x78,0x77,0x88,0x77,0x78,0x89,
+0x98,0x78,0x87,0x77,0x76,0x89,0x77,0x75,
+0x67,0x76,0x68,0x67,0x77,0x77,0x58,0x57,
+0x86,0x66,0x88,0x76,0x67,0x96,0x55,0x66,
+0x89,0x87,0x89,0x88,0x88,0x99,0x99,0x99,
+0x75,0x78,0x88,0x98,0x8a,0xa7,0x76,0x77,
+0x77,0x88,0xa9,0x78,0x87,0x78,0x97,0x87,
+0x68,0x98,0x88,0x89,0x99,0x76,0x68,0x89,
+0x98,0x66,0x76,0x76,0x67,0x98,0x97,0x75,
+0x67,0x76,0x67,0x78,0x87,0x68,0x77,0x66,
+0x75,0x57,0x88,0x97,0x66,0x99,0x88,0x88,
+0x99,0x97,0x67,0x76,0x98,0x89,0x89,0x98,
+0x76,0x78,0x78,0x79,0x89,0x97,0x89,0x89,
+0x99,0x77,0x87,0x58,0x97,0x66,0x77,0x76,
+0x78,0x9a,0x97,0x76,0x67,0x75,0x88,0x88,
+0x98,0x76,0x76,0x67,0x68,0x88,0x87,0x78,
+0x56,0x78,0x66,0x66,0x78,0x77,0x76,0x99,
+0x88,0x98,0x88,0x89,0x87,0x78,0x98,0x88,
+0x98,0xa8,0x76,0x88,0x77,0x88,0x97,0xa9,
+0x99,0x77,0x98,0x88,0x86,0x7a,0x87,0x75,
+0x68,0x88,0x78,0x97,0x77,0x67,0x86,0x77,
+0x87,0x77,0x87,0x87,0x56,0x77,0x66,0x76,
+0x89,0x76,0x56,0x68,0x65,0x68,0x77,0x89,
+0x76,0x68,0x69,0x98,0x99,0x98,0x67,0x77,
+0xa7,0x79,0x89,0x87,0x87,0x8a,0x88,0xb8,
+0x77,0x7a,0x8a,0x78,0x99,0x86,0x67,0x78,
+0xa8,0x87,0x69,0x69,0x78,0xa9,0x99,0x77,
+0x57,0x87,0x88,0x89,0x87,0x65,0x54,0x67,
+0x85,0x67,0x69,0x87,0x67,0x78,0x77,0xa5,
+0x54,0x67,0x85,0x57,0xbb,0x76,0xac,0xb8,
+0x88,0xaa,0x62,0x55,0x76,0x34,0x9d,0x97,
+0x9b,0xe9,0x88,0xbc,0xa5,0x02,0x98,0x58,
+0x68,0xba,0x57,0xa8,0x53,0x58,0xdc,0x57,
+0xec,0x83,0x7a,0xb7,0x30,0x15,0x62,0x4d,
+0xee,0xbb,0xeb,0x54,0x55,0x10,0x05,0x89,
+0x59,0xfb,0x9b,0x84,0x33,0x05,0xa6,0x8e,
+0xed,0xc8,0x77,0x62,0x39,0x85,0x59,0xdc,
+0xc8,0x3b,0x64,0x87,0x6c,0xea,0xbb,0x79,
+0xa4,0x23,0x52,0x44,0xde,0xbc,0xd9,0x96,
+0x10,0x58,0x55,0xad,0xdc,0x8a,0xb9,0x40,
+0x02,0x31,0x38,0xde,0xfb,0xac,0xa4,0x35,
+0x53,0x54,0x56,0x98,0x9a,0x96,0x78,0x63,
+0x58,0x99,0x9c,0xea,0x78,0xa9,0x43,0x57,
+0x70,0x1a,0xf7,0x56,0xcf,0xb5,0x8c,0x94,
+0x36,0x76,0x78,0xa9,0x57,0xa9,0x54,0x79,
+0x65,0x9c,0xca,0x8a,0xb8,0x55,0x79,0x78,
+0x96,0x52,0x6a,0x65,0x6b,0xf9,0x57,0xa9,
+0x44,0x66,0x76,0x69,0x85,0x79,0x8a,0x96,
+0x77,0x65,0x64,0x57,0x8a,0xdb,0xaa,0xa8,
+0x86,0x54,0x44,0x79,0xa9,0xac,0x98,0x79,
+0x87,0x23,0x35,0x9b,0xcd,0xc9,0x88,0x87,
+0x66,0x55,0x68,0x77,0x74,0x9b,0x85,0x6d,
+0xc9,0x79,0xa8,0x56,0x78,0x54,0x88,0x87,
+0x78,0x87,0x64,0x47,0x95,0x6e,0xd6,0x7a,
+0xa8,0x75,0x76,0x34,0x87,0x57,0x85,0x2a,
+0xa6,0xaa,0xdc,0x75,0x8a,0x66,0x77,0x86,
+0x79,0xa8,0x89,0x89,0x95,0x68,0x88,0x64,
+0x59,0x86,0x79,0xa9,0x87,0x9b,0x75,0x89,
+0x77,0x65,0x88,0x99,0x77,0x67,0x76,0x63,
+0x75,0x59,0x9c,0xa9,0xaa,0x96,0x45,0x76,
+0x56,0x77,0x99,0x96,0x67,0x85,0x45,0x57,
+0x99,0x9c,0xb7,0xa9,0x56,0x56,0x77,0x8b,
+0xa8,0x98,0x57,0x75,0x35,0x9b,0xae,0xdb,
+0xa8,0x87,0x55,0x56,0x89,0x78,0x88,0x87,
+0x66,0x86,0x96,0x58,0x89,0x42,0x6c,0x79,
+0xbc,0xc7,0x66,0x65,0x64,0x48,0x7c,0x87,
+0x5b,0x77,0x77,0x46,0x48,0x65,0x4b,0xb7,
+0x9b,0xb9,0x88,0xb6,0x54,0x83,0x37,0x98,
+0xaa,0xaa,0x99,0x04,0x41,0x7b,0xab,0xfe,
+0xb7,0x9a,0x85,0x57,0x65,0x67,0x98,0xca,
+0x86,0x7a,0x64,0x47,0x94,0x6b,0xd9,0x99,
+0xa7,0x57,0x76,0x67,0x66,0x45,0x86,0x67,
+0xb9,0x86,0x98,0x65,0x4c,0x87,0x8a,0xb7,
+0x98,0x85,0x59,0x76,0x69,0x95,0x67,0x99,
+0x65,0x3a,0xa8,0x87,0xba,0x76,0x99,0x77,
+0x6a,0x6a,0xa6,0x87,0x78,0x56,0x50,0x7c,
+0x88,0xcc,0xa9,0x86,0xa5,0x56,0x86,0x79,
+0x7b,0xa7,0x49,0x83,0x66,0x75,0x3a,0xb8,
+0x89,0xca,0x48,0x95,0x78,0x85,0x77,0x86,
+0x42,0x58,0x97,0x6e,0xd8,0x9a,0x77,0x86,
+0x55,0x86,0x86,0xa7,0x77,0x89,0x67,0x98,
+0x76,0x96,0x55,0xaf,0x88,0xcf,0xa5,0x77,
+0x44,0x66,0x66,0x78,0x78,0x57,0x87,0xa8,
+0xbb,0xba,0xaa,0x74,0x48,0x66,0x68,0x75,
+0x78,0x62,0x27,0xa4,0x1d,0xf5,0xbf,0x97,
+0x86,0x76,0x36,0x54,0x35,0x9a,0x9b,0xaa,
+0x87,0x94,0x36,0x45,0x89,0xbb,0xcb,0xa9,
+0x76,0x76,0x26,0x76,0xa8,0xa7,0x9b,0x55,
+0x88,0xa5,0x8a,0x96,0x76,0x67,0x89,0xa9,
+0x89,0x97,0x32,0x48,0xb1,0x5f,0xb6,0xcd,
+0x66,0x84,0x47,0x53,0x57,0x9a,0x98,0xac,
+0x97,0x86,0x43,0x41,0x29,0xd5,0xae,0xb9,
+0xaa,0x97,0x65,0x75,0x47,0x88,0x98,0x9b,
+0x98,0x65,0x43,0x25,0x78,0xcc,0xbb,0xaa,
+0x99,0x86,0x55,0x22,0x33,0x8a,0x69,0xdc,
+0x99,0xb8,0x78,0x87,0x67,0x88,0x78,0x97,
+0x98,0x66,0x48,0x85,0x89,0x99,0x88,0x88,
+0x79,0x86,0x97,0x67,0x12,0x98,0x38,0xf9,
+0x5b,0xb7,0x88,0x77,0x66,0x76,0x77,0x98,
+0x54,0x9b,0x79,0xba,0x79,0x95,0x76,0x89,
+0x87,0x88,0x68,0x76,0x87,0x54,0x9a,0x8a,
+0xbb,0x77,0x87,0x65,0x87,0x76,0x78,0x54,
+0x9a,0x58,0xd9,0x9a,0xa7,0x75,0x25,0x64,
+0x67,0x99,0x87,0xab,0x93,0x25,0x52,0x7d,
+0xb9,0xec,0x76,0x88,0x62,0x14,0x76,0x8b,
+0xcc,0xaa,0x77,0x82,0x55,0x68,0xea,0xbc,
+0x88,0x98,0x75,0x45,0x55,0x57,0xa9,0x89,
+0xbb,0x78,0x98,0x46,0x87,0x67,0xa9,0x65,
+0x29,0xd3,0x3c,0xf8,0x9c,0xa7,0x78,0x75,
+0x33,0x43,0x6a,0xc9,0xbc,0x88,0x65,0x77,
+0x13,0x6b,0x77,0xbe,0x97,0x89,0x54,0x57,
+0x64,0x47,0x76,0x7c,0xe8,0x9d,0x76,0x66,
+0x67,0x55,0x87,0x79,0x67,0xab,0x76,0x87,
+0x74,0x59,0x76,0x9c,0xa8,0x99,0x97,0x57,
+0x76,0x58,0x60,0x7f,0x96,0xcc,0x9a,0x98,
+0x97,0x56,0x75,0x56,0x75,0x58,0x88,0x65,
+0xed,0x98,0xb7,0x46,0x76,0x66,0x58,0x84,
+0x68,0x46,0xb7,0x4a,0xca,0xab,0x89,0x97,
+0x69,0x84,0x68,0x74,0x21,0x8b,0x54,0xef,
+0x98,0xba,0x84,0x66,0x63,0x56,0x66,0x9a,
+0x98,0xb7,0x87,0x68,0x75,0x3b,0xc9,0x7c,
+0xc7,0x68,0x77,0x55,0x54,0x56,0x8a,0xaa,
+0x8a,0x76,0x77,0x67,0x78,0x88,0x77,0x88,
+0x77,0x75,0x34,0x66,0x79,0xba,0xcb,0xa8,
+0x87,0x86,0x66,0x86,0x76,0x79,0xa8,0x89,
+0x86,0x97,0x77,0x56,0x9d,0x87,0x9a,0x77,
+0x79,0x76,0x66,0x87,0x78,0x97,0x88,0xa9,
+0x88,0x88,0x76,0x88,0x76,0x87,0x67,0x76,
+0x88,0x88,0x9a,0x87,0x77,0x56,0x64,0x87,
+0x98,0x78,0x86,0x77,0x86,0x57,0x86,0x68,
+0x8c,0x97,0xa9,0x56,0x87,0x77,0x76,0x76,
+0x9b,0x67,0x99,0x88,0x88,0x68,0x78,0x97,
+0x79,0x89,0x89,0x37,0x57,0x78,0x89,0x77,
+0x88,0xa9,0x88,0x99,0x66,0x8a,0x68,0x77,
+0x67,0x78,0x77,0x98,0x98,0x98,0x95,0x87,
+0x78,0x57,0x78,0x87,0x67,0x84,0x77,0x98,
+0x66,0x98,0xa9,0x78,0x8b,0x66,0x88,0x85,
+0x67,0x88,0x87,0x88,0x85,0x88,0x98,0x78,
+0x88,0x97,0x67,0x78,0x88,0x67,0x57,0x69,
+0xa9,0x77,0x88,0x99,0x88,0x79,0x79,0x77,
+0x86,0x65,0x66,0x77,0x88,0x88,0x68,0x97,
+0x77,0x76,0x87,0x57,0x79,0x77,0x78,0x66,
+0x68,0x87,0x76,0x88,0x89,0x96,0x78,0x88,
+0x89,0x87,0x87,0x88,0x78,0x89,0x97,0x77,
+0x69,0x97,0x77,0x98,0x79,0x78,0x77,0x87,
+0x67,0x79,0x98,0x86,0x78,0x99,0x97,0x69,
+0x88,0x77,0x77,0x67,0x56,0x66,0x99,0x97,
+0x77,0x77,0x77,0x76,0x87,0x68,0x98,0x87,
+0x88,0x65,0x56,0x97,0x78,0x78,0x79,0x97,
+0x69,0x88,0x88,0x77,0x87,0x87,0x77,0x89,
+0x86,0x76,0x78,0x97,0x88,0x99,0x89,0x87,
+0x78,0x78,0x77,0x78,0x78,0x77,0x77,0x88,
+0x96,0x78,0x99,0x88,0x86,0x76,0x67,0x77,
+0x88,0xa9,0x88,0x77,0x78,0x66,0x77,0x89,
+0x88,0x77,0x96,0x66,0x57,0x78,0x87,0x87,
+0x78,0x86,0x69,0x97,0x88,0x78,0x87,0x77,
+0x77,0x87,0x98,0x77,0x67,0x88,0x87,0x88,
+0x98,0x98,0x77,0x87,0x87,0x87,0x68,0x88,
+0x87,0x88,0x86,0x69,0xa8,0x88,0x86,0x66,
+0x77,0x87,0x88,0x98,0x88,0x66,0x88,0x65,
+0x78,0x88,0x99,0x87,0x87,0x76,0x67,0x77,
+0x78,0x97,0x88,0x87,0x88,0x88,0x99,0x98,
+0x78,0x78,0x77,0x88,0x87,0x78,0x68,0x79,
+0x77,0x88,0x78,0x87,0x88,0x79,0x89,0x66,
+0x77,0x88,0x97,0x79,0x67,0x68,0x87,0x88,
+0x87,0x67,0x67,0x67,0x88,0x88,0x87,0x66,
+0x77,0x46,0x78,0x88,0x88,0x88,0x77,0x77,
+0x77,0x77,0x68,0x78,0x78,0x89,0x87,0x88,
+0x89,0x98,0x79,0x77,0x66,0x88,0x78,0x78,
+0x76,0x79,0x87,0x68,0x87,0x88,0x67,0x89,
+0x89,0x66,0x78,0x87,0x88,0x78,0x8a,0x97,
+0x88,0x87,0x77,0x79,0x87,0x77,0x89,0x89,
+0x77,0x76,0x65,0x76,0x78,0x88,0x98,0x76,
+0x77,0x88,0x86,0x86,0x97,0x77,0x77,0xa9,
+0x87,0x79,0x7a,0x78,0x79,0x77,0x77,0x86,
+0x78,0x67,0x57,0x87,0x84,0x58,0x97,0x86,
+0x78,0xa7,0x77,0x78,0x68,0x96,0x96,0x78,
+0x8b,0x87,0x86,0x98,0x87,0x87,0x76,0xa6,
+0xa8,0x8a,0x78,0x68,0x58,0x96,0x79,0xa5,
+0x95,0x87,0x77,0x97,0x79,0x58,0x77,0x87,
+0x77,0x98,0x87,0xa8,0xb9,0x88,0x67,0x77,
+0x86,0x8a,0x78,0x67,0x78,0x68,0x85,0x68,
+0x78,0x59,0x47,0x86,0x88,0x6a,0x68,0x95,
+0x95,0x79,0x7a,0x58,0x68,0x97,0x8a,0x87,
+0x68,0x89,0x99,0x86,0x67,0x63,0x98,0x55,
+0x77,0xa8,0x76,0x79,0x7b,0x97,0xb7,0xc5,
+0x77,0x46,0x47,0x86,0x85,0xc8,0xac,0x5a,
+0x99,0x97,0x8a,0xb8,0x58,0x64,0x93,0x77,
+0x66,0x57,0x89,0xa6,0xab,0x8a,0x59,0xa9,
+0x76,0x74,0x28,0x56,0x78,0x67,0x79,0x9a,
+0xb9,0x99,0xba,0x99,0xa7,0xb2,0x03,0x66,
+0x74,0x45,0xba,0xa6,0x8c,0xa9,0x97,0xca,
+0xa6,0x45,0x60,0x43,0x73,0x35,0xaa,0xac,
+0xae,0xed,0xb6,0x9b,0x6b,0x62,0x41,0x35,
+0x27,0x23,0xa8,0x9b,0xaf,0xdc,0x88,0xc9,
+0x86,0x72,0x00,0x66,0x31,0x29,0xdd,0xaa,
+0xdf,0xdc,0x88,0x98,0x73,0x34,0x33,0x14,
+0x88,0x58,0xcf,0xfb,0x8a,0xca,0x75,0x57,
+0x97,0x30,0x07,0xa7,0x43,0xbf,0xe8,0x8c,
+0xda,0x86,0x87,0x64,0x44,0x21,0x69,0x96,
+0x5a,0xfe,0x98,0xac,0xa6,0x45,0x76,0x66,
+0x62,0x16,0xca,0x51,0x9f,0xe9,0x79,0xba,
+0x74,0x37,0x88,0x64,0x25,0xba,0x52,0x5e,
+0xfa,0x56,0xcc,0x95,0x56,0x86,0x44,0x78,
+0x77,0x77,0xa9,0x76,0x7a,0xa7,0x67,0x9a,
+0x87,0x89,0x98,0x86,0x33,0x7a,0x95,0x29,
+0xed,0x97,0x8a,0xb8,0x54,0x77,0x75,0x46,
+0x99,0x76,0x89,0x98,0x78,0x98,0x88,0x78,
+0x87,0x87,0x88,0x74,0x04,0xcb,0x61,0x8f,
+0xda,0x57,0xc9,0x75,0x47,0x67,0x65,0xaa,
+0x87,0x78,0x78,0x96,0x66,0x78,0x88,0x89,
+0xa9,0x77,0x79,0x98,0x41,0x5c,0xa5,0x19,
+0xfd,0x64,0x8b,0x88,0x44,0x88,0x75,0x69,
+0x86,0x57,0xb8,0x48,0xba,0x75,0x89,0x97,
+0x77,0x89,0x88,0x73,0x49,0x96,0x34,0xdc,
+0x97,0x9c,0x97,0x65,0x87,0x55,0x58,0xa9,
+0x64,0x9c,0x85,0x48,0xb9,0x76,0x9a,0x76,
+0x78,0x98,0x86,0x68,0x5c,0x94,0x37,0xfa,
+0x78,0xbd,0x86,0x67,0x74,0x46,0x68,0x86,
+0x57,0xb9,0x76,0x7b,0xa6,0x5a,0xb7,0x56,
+0x88,0x76,0x79,0x61,0x6c,0x63,0x39,0xd7,
+0x89,0xdb,0x78,0x88,0x74,0x54,0x67,0x56,
+0x69,0xb8,0x87,0xbb,0x67,0x8a,0x88,0x97,
+0x76,0x58,0x98,0x51,0x6f,0x81,0x4d,0xf5,
+0x5c,0xe9,0x5a,0xb8,0x64,0x67,0x55,0x67,
+0x77,0x78,0xa7,0x69,0xb9,0x58,0xa8,0x88,
+0x88,0x66,0x77,0x73,0x3a,0xb3,0x29,0xe8,
+0x38,0xda,0x57,0xca,0x66,0x77,0x44,0x57,
+0x65,0x78,0xa8,0x89,0xaa,0x86,0x9a,0x86,
+0x8b,0x85,0x68,0x76,0x41,0x7d,0x41,0x7c,
+0xe6,0x4e,0xf7,0x3b,0xc7,0x59,0x95,0x35,
+0x67,0x66,0x79,0xa9,0x76,0x9a,0x66,0xaa,
+0x77,0xa9,0x77,0x77,0x57,0x63,0x6b,0x63,
+0x7d,0xb4,0x8e,0xc6,0x6b,0xa5,0x59,0x85,
+0x56,0x66,0x56,0x79,0x98,0x8a,0xa9,0x78,
+0xa8,0x78,0x99,0x77,0x77,0x55,0x23,0xc7,
+0x07,0xfa,0x39,0xfa,0x68,0xb9,0x56,0x98,
+0x54,0x67,0x76,0x66,0x79,0xa8,0x67,0xaa,
+0x77,0xba,0x76,0x99,0x65,0x78,0x55,0x63,
+0x5a,0x54,0xbc,0x76,0xcc,0x87,0x89,0x75,
+0x68,0x85,0x56,0x76,0x54,0x6b,0xb6,0x7a,
+0xb9,0x68,0xca,0x68,0xb9,0x55,0x97,0x45,
+0x52,0x9b,0x38,0xdd,0x78,0xfd,0x77,0x89,
+0x76,0x67,0x85,0x47,0x98,0x55,0x8c,0xa5,
+0x7a,0x86,0x78,0x99,0x97,0x78,0x86,0x78,
+0x65,0x50,0x4d,0x61,0x9d,0x96,0xae,0xa7,
+0x78,0x85,0x45,0x76,0x44,0x6a,0x74,0x4b,
+0xd8,0x58,0xba,0x65,0x79,0xa8,0x68,0x99,
+0x56,0x98,0x50,0x0b,0xd3,0x28,0xed,0x68,
+0xdd,0x95,0x8a,0x75,0x46,0x65,0x78,0x89,
+0x77,0xab,0x75,0x98,0x78,0x88,0x9a,0x95,
+0x7a,0x95,0x58,0x76,0x11,0xbd,0x53,0x8d,
+0xc9,0x89,0xaa,0x65,0x67,0x73,0x36,0x87,
+0x79,0xb9,0x87,0x69,0x85,0x37,0xbb,0x98,
+0xab,0xa7,0x56,0x76,0x54,0x47,0x63,0x6b,
+0xb8,0x89,0xdc,0x98,0x88,0x85,0x43,0x67,
+0x66,0x88,0x8c,0xd9,0x54,0x8a,0x64,0x37,
+0xbb,0xa8,0x8c,0xb6,0x44,0x77,0x77,0x54,
+0x22,0xcf,0x52,0xaf,0xe8,0x59,0x98,0x74,
+0x45,0x78,0x65,0x7b,0xcb,0x87,0x57,0x87,
+0x65,0x5b,0xea,0x67,0xa9,0x65,0x55,0x79,
+0x97,0x62,0x4c,0xd6,0x46,0xce,0xc8,0x56,
+0x99,0x75,0x45,0x88,0x78,0x9b,0xba,0x73,
+0x48,0x86,0x55,0x9b,0xca,0x97,0x78,0x86,
+0x56,0x89,0x86,0x42,0x3a,0xd9,0x65,0x9d,
+0xb8,0x65,0x57,0x76,0x44,0x58,0xa9,0x89,
+0xb9,0x65,0x56,0x77,0x67,0x8a,0xba,0x88,
+0x87,0x78,0x79,0x99,0x87,0x41,0x5c,0xda,
+0x65,0x8c,0xdb,0x84,0x58,0x76,0x54,0x79,
+0x9a,0xa9,0x99,0x65,0x46,0x78,0x68,0x8a,
+0x99,0x89,0x98,0x87,0x77,0x77,0x87,0x52,
+0x49,0xba,0x85,0x69,0xbb,0x96,0x45,0x67,
+0x78,0x76,0x68,0xaa,0xa8,0x42,0x47,0x99,
+0x75,0x6a,0xba,0x98,0x99,0x98,0x77,0x77,
+0x65,0x33,0x5a,0xca,0x77,0x9c,0xd9,0x65,
+0x66,0x66,0x77,0x67,0x89,0xaa,0x97,0x54,
+0x47,0x98,0x77,0x7a,0xbb,0xa9,0x87,0x87,
+0x77,0x77,0x76,0x42,0x58,0x9a,0x86,0x78,
+0x9a,0xa9,0x86,0x77,0x78,0x87,0x77,0x88,
+0x86,0x22,0x48,0xaa,0x86,0x8a,0xcc,0xb9,
+0x87,0x87,0x98,0x76,0x64,0x22,0x7b,0xda,
+0x75,0x7a,0xbb,0xa8,0x76,0x67,0x87,0x55,
+0x77,0x9a,0x84,0x24,0x8a,0xa9,0x78,0xab,
+0xa9,0x98,0x66,0x77,0x77,0x56,0x98,0x42,
+0x48,0xcb,0x74,0x69,0xdc,0x96,0x67,0x77,
+0x67,0x75,0x57,0x99,0x72,0x14,0xad,0xa8,
+0x8a,0xdc,0x99,0x98,0x65,0x79,0x98,0x73,
+0x02,0x5b,0xea,0x76,0x79,0xdd,0xb8,0x66,
+0x56,0x77,0x77,0x78,0x75,0x44,0x69,0xba,
+0x99,0x9b,0xb9,0x87,0x76,0x66,0x67,0x87,
+0x75,0x43,0x49,0xcb,0x84,0x48,0xdf,0xa5,
+0x55,0x78,0x75,0x56,0x56,0x78,0x64,0x34,
+0x98,0xc9,0x9a,0xbb,0xa8,0x77,0x76,0x89,
+0x96,0x00,0x28,0xee,0x97,0x8a,0xba,0x88,
+0x86,0x65,0x57,0x76,0x79,0x86,0x22,0x7c,
+0xd9,0x79,0xbb,0xa7,0x79,0x86,0x57,0x97,
+0x66,0x53,0x38,0xcc,0x95,0x6c,0xeb,0x64,
+0x46,0x76,0x67,0x78,0x89,0xa6,0x00,0x7d,
+0xb7,0x46,0xde,0xb6,0x68,0x98,0x77,0x87,
+0x66,0x64,0x23,0x8e,0xfa,0x99,0xba,0x65,
+0x67,0x78,0xab,0xa6,0x00,0x39,0xdb,0x88,
+0xbc,0xa7,0x56,0x54,0x46,0x89,0x89,0xa8,
+0x42,0x5b,0xb8,0x7a,0xcb,0x74,0x57,0x66,
+0x78,0x77,0x8a,0x73,0x15,0xbb,0x88,0x99,
+0xba,0x85,0x25,0x87,0x76,0x79,0x87,0x9b,
+0x62,0x49,0xac,0xcd,0xb7,0x56,0x76,0x68,
+0xbc,0xa9,0x30,0x17,0xdb,0x77,0xee,0x84,
+0x44,0x57,0x88,0x66,0xab,0x98,0x52,0x03,
+0x9d,0xcb,0xbb,0x86,0x77,0x66,0x78,0x89,
+0x99,0x20,0x4e,0xc6,0x36,0xde,0x96,0x44,
+0x79,0x65,0x79,0x98,0x78,0x84,0x22,0x7c,
+0xaa,0xcc,0x97,0x66,0x55,0x89,0x9a,0xa5,
+0x03,0xac,0x86,0x8c,0xd9,0x44,0x68,0x86,
+0x67,0xab,0x78,0x83,0x04,0xaa,0x69,0xfc,
+0x65,0x67,0x79,0xa8,0x79,0x84,0x26,0xc9,
+0x66,0xae,0xb5,0x56,0x79,0x75,0x68,0x99,
+0x89,0x72,0x27,0x96,0x7b,0xb9,0x76,0x78,
+0x77,0x88,0x98,0x62,0x17,0xea,0x34,0xcf,
+0xa4,0x67,0x99,0x66,0x79,0x98,0x86,0x23,
+0xba,0x56,0xce,0x95,0x67,0x88,0x77,0x89,
+0x96,0x01,0xad,0x62,0x6e,0xf7,0x48,0x98,
+0x75,0x58,0xa8,0x68,0x98,0x55,0x79,0x67,
+0x89,0xa9,0x89,0x87,0x67,0x88,0x75,0x14,
+0xcc,0x43,0xae,0xc5,0x59,0x97,0x66,0x8a,
+0x95,0x6a,0x95,0x48,0xa8,0x78,0xaa,0x87,
+0x88,0x76,0x89,0x87,0x52,0x5c,0x94,0x7c,
+0xc8,0x68,0x87,0x64,0x68,0x97,0x68,0xba,
+0x55,0x7a,0x84,0x4b,0xc7,0x5a,0xa8,0x68,
+0x88,0x77,0x50,0x4e,0xc1,0x5d,0xc5,0x4b,
+0xa5,0x58,0x87,0x77,0x87,0xa8,0x47,0x88,
+0x55,0x9b,0x87,0x8a,0x97,0x88,0x88,0x76,
+0x34,0xda,0x17,0xec,0x46,0xc9,0x46,0x77,
+0x67,0x88,0x99,0x87,0x77,0x75,0x57,0xa8,
+0x6a,0xb9,0x98,0x98,0x78,0x63,0x28,0xb4,
+0x3b,0xf9,0x4b,0xc6,0x58,0x85,0x67,0x78,
+0x66,0x89,0x86,0x79,0x87,0x66,0x99,0x88,
+0x88,0x56,0x88,0x62,0x5c,0x63,0x6e,0xb4,
+0x9d,0x85,0x7a,0x74,0x67,0x88,0x77,0x87,
+0x89,0x66,0x8a,0x75,0x9b,0x87,0x98,0x66,
+0x98,0x74,0x28,0xa5,0x4b,0xe8,0x5d,0xc6,
+0x69,0x84,0x48,0x76,0x77,0x57,0xb6,0x5b,
+0xa6,0x78,0x86,0x8a,0x87,0x9a,0x88,0x48,
+0x94,0x49,0xa8,0x6b,0xb6,0x8b,0x86,0x67,
+0x65,0x87,0x99,0x77,0x89,0x75,0x99,0x47,
+0xb9,0x69,0xb8,0x68,0x88,0x53,0x6c,0x52,
+0x8d,0x54,0xec,0x57,0xb8,0x67,0x87,0x46,
+0x88,0x65,0x99,0x75,0x8b,0x64,0xba,0x58,
+0xa8,0x79,0x97,0x66,0x62,0x69,0x35,0xd9,
+0x7b,0xb9,0x88,0x97,0x67,0x75,0x58,0x87,
+0x78,0x88,0x97,0x89,0x98,0x78,0x98,0x9a,
+0x77,0x97,0x67,0x76,0x58,0x75,0x79,0x79,
+0xa9,0xa9,0x68,0x76,0x86,0x66,0x78,0x78,
+0x89,0x87,0x77,0x79,0x87,0x88,0x79,0x77,
+0x86,0x88,0x77,0x98,0x77,0x66,0x87,0x66,
+0x89,0x78,0x89,0x89,0x97,0x78,0x76,0x87,
+0x66,0x87,0x78,0x86,0x77,0x99,0x98,0x88,
+0x87,0x79,0x87,0x89,0x77,0x77,0x86,0x77,
+0x76,0x78,0x99,0x87,0x78,0x77,0x98,0x77,
+0x87,0x67,0x88,0x99,0x67,0x86,0x77,0x87,
+0x89,0x76,0x78,0x87,0x88,0x88,0x88,0x78,
+0x76,0x77,0x78,0x87,0x7a,0x98,0x76,0x67,
+0x77,0x77,0x87,0x69,0x89,0x98,0x78,0x99,
+0x87,0x89,0x88,0x78,0x88,0x75,0x67,0x89,
+0x88,0x77,0x76,0x78,0x98,0x77,0x88,0x87,
+0x77,0x78,0x87,0x77,0x78,0x77,0x77,0x77,
+0x88,0x87,0x78,0x87,0x78,0x77,0x89,0x87,
+0x78,0x88,0x87,0x56,0x88,0x78,0x89,0x99,
+0x77,0x77,0x77,0x87,0x77,0x88,0x89,0x76,
+0x78,0x9a,0x87,0x89,0x97,0x77,0x98,0x86,
+0x77,0x88,0x87,0x89,0x76,0x78,0x98,0x66,
+0x78,0x87,0x77,0x78,0x77,0x68,0x99,0x78,
+0x98,0x67,0x79,0x98,0x77,0x87,0x76,0x77,
+0x88,0x86,0x78,0x87,0x77,0x66,0x77,0x88,
+0x88,0x88,0x77,0x87,0x67,0x77,0x67,0x88,
+0x9a,0x87,0x87,0x89,0x87,0x78,0x98,0x87,
+0x77,0x77,0x77,0x88,0x88,0x88,0x76,0x67,
+0x98,0x66,0x77,0x77,0x77,0x89,0x77,0x88,
+0x88,0x88,0x88,0x76,0x79,0x98,0x77,0x78,
+0x98,0x89,0x88,0x66,0x78,0x98,0x87,0x76,
+0x67,0x89,0x89,0x99,0x87,0x66,0x68,0x77,
+0x76,0x78,0x98,0x77,0x87,0x99,0x99,0x87,
+0x78,0x87,0x79,0x77,0x77,0x78,0x89,0x89,
+0x87,0x78,0x88,0x66,0x77,0x98,0x67,0x87,
+0x67,0x76,0x89,0x79,0x98,0x76,0x78,0x89,
+0x86,0x68,0x87,0x68,0x78,0x87,0x68,0x87,
+0x78,0x87,0x77,0x89,0x88,0x87,0x87,0x76,
+0x78,0x87,0x66,0x78,0x89,0x98,0x88,0x88,
+0x8a,0x88,0x78,0x88,0x77,0x78,0x77,0x68,
+0x89,0x88,0x87,0x87,0x78,0x76,0x77,0x88,
+0x77,0x88,0x77,0x76,0x78,0x89,0x88,0x77,
+0x98,0x98,0x77,0x68,0x98,0x78,0x87,0x75,
+0x67,0x88,0x88,0x78,0x67,0x89,0x98,0x77,
+0x87,0x56,0x87,0x76,0x86,0x78,0x87,0x98,
+0x89,0x89,0x99,0x87,0x78,0x98,0x78,0x86,
+0x87,0x77,0x8b,0x79,0x99,0x66,0x66,0x86,
+0x78,0x97,0x76,0x87,0x98,0x78,0x5a,0x97,
+0x99,0x87,0x99,0x78,0xa7,0x46,0xa6,0x68,
+0x78,0x76,0x76,0x79,0x99,0x99,0x77,0x9a,
+0x77,0x96,0x76,0x87,0x56,0x78,0x65,0x77,
+0x99,0xb8,0x88,0x9a,0xa9,0xa9,0x76,0x65,
+0x75,0x78,0x87,0x57,0x79,0x6b,0x9c,0x79,
+0x88,0x89,0x85,0x78,0x95,0x35,0x86,0x84,
+0x54,0xa9,0xb9,0x9a,0xbb,0x88,0x9c,0x95,
+0x35,0x78,0x74,0x44,0x78,0x84,0x79,0xec,
+0x99,0xbb,0xaa,0x67,0x88,0x64,0x12,0x06,
+0x86,0x41,0x7e,0xfc,0xaa,0xfd,0xa3,0x47,
+0x99,0x21,0x48,0x71,0x56,0xb7,0x87,0xbf,
+0xfa,0x98,0x99,0x54,0x37,0x76,0x42,0x04,
+0x7d,0x76,0x8c,0xfa,0x87,0x9d,0x77,0x18,
+0x76,0x65,0x60,0x68,0xa8,0x78,0xbe,0xa8,
+0x87,0x87,0x85,0x56,0x77,0x89,0x77,0x66,
+0x68,0x86,0x77,0x8a,0x99,0x88,0x9a,0x87,
+0x78,0x98,0x61,0x03,0xac,0xb8,0x9d,0xeb,
+0x74,0x58,0x95,0x44,0x38,0xb9,0x67,0xbc,
+0xba,0x74,0x34,0x77,0x76,0x9e,0xdb,0x67,
+0x98,0x77,0x53,0x57,0x76,0x69,0xab,0xbc,
+0xa7,0x77,0x54,0x58,0x79,0xa8,0x79,0xa8,
+0x40,0x27,0x99,0x89,0xbc,0xb8,0x56,0x89,
+0x64,0x35,0x7a,0x99,0xaa,0xb9,0x76,0x42,
+0x25,0x88,0x9b,0xdd,0xc9,0x65,0x66,0x53,
+0x26,0x9a,0x76,0x7a,0xb9,0x75,0x79,0x97,
+0x67,0x99,0x98,0x88,0x88,0x86,0x31,0x48,
+0x98,0x79,0xee,0xd9,0x66,0x77,0x76,0x52,
+0x25,0x8b,0xb9,0xab,0xa9,0x76,0x43,0x35,
+0x77,0x57,0xce,0xda,0x99,0x87,0x77,0x54,
+0x69,0x97,0x55,0xaa,0x85,0x46,0x9b,0xba,
+0x86,0x68,0x99,0x75,0x69,0x78,0x88,0x41,
+0x15,0xbb,0x76,0x9c,0xca,0x98,0x77,0x88,
+0x86,0x54,0x57,0x87,0x89,0x98,0x87,0x88,
+0x88,0x88,0x86,0x55,0x8a,0x87,0x89,0x98,
+0x88,0x76,0x67,0x77,0x88,0x88,0x66,0x77,
+0x77,0x77,0x88,0x89,0x98,0x89,0x98,0x87,
+0x77,0x77,0x77,0x77,0x88,0x87,0x67,0x88,
+0x98,0x87,0x77,0x77,0x66,0x89,0x99,0x88,
+0x88,0x88,0x77,0x87,0x67,0x77,0x77,0x77,
+0x77,0x77,0x99,0x89,0x88,0x88,0x88,0x87,
+0x76,0x67,0x77,0x66,0x77,0x66,0x78,0x89,
+0x87,0x88,0x88,0x88,0x89,0x87,0x88,0x87,
+0x78,0x67,0x77,0x88,0x89,0x87,0x77,0x77,
+0x77,0x88,0x88,0x98,0x88,0x98,0x78,0x87,
+0x88,0x87,0x77,0x78,0x87,0x78,0x76,0x78,
+0x77,0x88,0x78,0x88,0x99,0x89,0x98,0x77,
+0x77,0x76,0x67,0x77,0x77,0x67,0x77,0x67,
+0x77,0x88,0x88,0x88,0x88,0x98,0x99,0x98,
+0x89,0x87,0x77,0x77,0x66,0x77,0x78,0x77,
+0x78,0x77,0x88,0x78,0x88,0x89,0x77,0x87,
+0x78,0x87,0x78,0x87,0x76,0x78,0x87,0x78,
+0x87,0x77,0x77,0x87,0x77,0x88,0x88,0x99,
+0x97,0x88,0x78,0x86,0x67,0x76,0x77,0x67,
+0x86,0x78,0x77,0x89,0x88,0x87,0x88,0x88,
+0x99,0x98,0x98,0x88,0x76,0x77,0x76,0x77,
+0x88,0x87,0x77,0x77,0x98,0x77,0x88,0x88,
+0x87,0x87,0x88,0x77,0x79,0x98,0x87,0x78,
+0x77,0x67,0x77,0x77,0x78,0x76,0x77,0x87,
+0x77,0x88,0x98,0x88,0x87,0x89,0x76,0x87,
+0x67,0x77,0x77,0x67,0x77,0x67,0x87,0x78,
+0x78,0x99,0x88,0x88,0x99,0x88,0x77,0x78,
+0x87,0x77,0x89,0x98,0x87,0x87,0x88,0x76,
+0x77,0x77,0x77,0x78,0x78,0x87,0x77,0x99,
+0x99,0x88,0x98,0x78,0x88,0x88,0x77,0x87,
+0x67,0x77,0x77,0x77,0x88,0x77,0x87,0x88,
+0x76,0x78,0x87,0x87,0x78,0x88,0x87,0x77,
+0x98,0x88,0x77,0x88,0x77,0x77,0x88,0x77,
+0x76,0x67,0x77,0x78,0x78,0x99,0x88,0x87,
+0x89,0x88,0x88,0x77,0x88,0x78,0x77,0x77,
+0x77,0x87,0x78,0x77,0x88,0x66,0x89,0x98,
+0x87,0x88,0x78,0x87,0x77,0x78,0x98,0x87,
+0x88,0x98,0x66,0x67,0x77,0x76,0x67,0x77,
+0x77,0x66,0x78,0x89,0x88,0x89,0x88,0x98,
+0x98,0x88,0x87,0x77,0x77,0x88,0x88,0x78,
+0x88,0x77,0x77,0x77,0x77,0x77,0x77,0x78,
+0x88,0x77,0x7a,0xaa,0xa9,0x88,0x87,0x65,
+0x77,0x88,0x88,0x66,0x89,0x9a,0x84,0x98,
+0x87,0x66,0x45,0x65,0x76,0x87,0x89,0x99,
+0xac,0xb9,0x85,0x57,0x47,0x65,0x54,0x78,
+0x77,0xaa,0x9b,0xbc,0xbb,0x96,0x43,0x42,
+0x43,0x45,0x67,0x89,0xac,0xab,0x8b,0xa9,
+0x97,0x78,0x89,0x8a,0xa8,0x85,0x65,0x56,
+0x56,0x55,0x55,0x89,0x89,0x86,0x99,0xbb,
+0xa8,0xa9,0x79,0xaa,0x97,0x78,0x66,0x45,
+0x68,0x87,0x55,0x44,0x54,0x66,0x68,0x7a,
+0xbb,0xaa,0x99,0x9a,0xbd,0xa8,0x55,0x47,
+0x66,0x55,0x44,0x45,0x68,0x8a,0x7a,0x97,
+0x75,0x89,0x88,0x99,0xaa,0x9a,0x78,0x88,
+0x89,0x77,0x54,0x46,0x77,0x99,0xa9,0x78,
+0x67,0x78,0x85,0x55,0x66,0x98,0xa9,0x98,
+0x88,0x89,0xaa,0x99,0x99,0x88,0x77,0x87,
+0x64,0x54,0x58,0x89,0x66,0x45,0x69,0xcd,
+0xb8,0x67,0x88,0x97,0x65,0x46,0x78,0x9a,
+0xb9,0xb9,0x87,0x79,0xa9,0xaa,0x76,0x65,
+0x86,0x65,0x24,0x22,0x54,0x69,0x9a,0xba,
+0xc9,0xdc,0x98,0x66,0x97,0x73,0x02,0x28,
+0xbb,0xc6,0xb7,0x88,0x7a,0x98,0x87,0x76,
+0x78,0x58,0x88,0x85,0x63,0x13,0x59,0xcc,
+0xb9,0x89,0xab,0xab,0xa9,0xa6,0x10,0x01,
+0x6a,0xff,0xdc,0x98,0x78,0x76,0x55,0x67,
+0x77,0x79,0x98,0x87,0x55,0x67,0x9a,0xab,
+0x99,0x88,0x87,0x89,0x98,0x50,0x12,0x29,
+0xdd,0xdb,0xa5,0x68,0x66,0x68,0x57,0x87,
+0x88,0x89,0x76,0x43,0x57,0x9a,0xb9,0x98,
+0x98,0x76,0x65,0x88,0x9a,0x60,0x03,0x7e,
+0xfe,0xa7,0x75,0x56,0x78,0x99,0x88,0x67,
+0x66,0x99,0x85,0x54,0x59,0xbc,0xb9,0x88,
+0x88,0x88,0x77,0x89,0x88,0x40,0x36,0xad,
+0xee,0x87,0x41,0x46,0x99,0xa9,0x9a,0x77,
+0x45,0x79,0x98,0x74,0x57,0x99,0xa9,0x56,
+0x88,0x99,0x87,0x77,0x77,0x98,0x11,0x68,
+0xef,0xb7,0x46,0x46,0x88,0x89,0x87,0x99,
+0x77,0x66,0x77,0x56,0x7a,0xba,0xa6,0x55,
+0x68,0xaa,0xa8,0x77,0x88,0x96,0x03,0x79,
+0xee,0xb8,0x44,0x25,0x9a,0xaa,0x97,0x76,
+0x78,0x88,0x75,0x39,0xbb,0xc8,0x42,0x56,
+0x9b,0xa7,0x77,0x67,0x88,0x89,0x60,0x3a,
+0xad,0xe7,0x37,0x76,0x89,0x67,0x97,0x69,
+0x87,0x78,0x88,0x55,0x67,0xbb,0xa7,0x64,
+0x58,0x8a,0xa9,0x77,0x77,0x88,0x41,0x78,
+0xdf,0xb8,0x46,0x56,0xa8,0x88,0x98,0x76,
+0x65,0x78,0x9a,0x76,0x77,0x78,0x87,0x79,
+0x87,0x76,0x67,0x98,0x88,0x66,0x87,0x23,
+0xab,0xad,0x84,0x88,0x66,0x86,0x8a,0x86,
+0x77,0x67,0x88,0x75,0x57,0x9b,0xa8,0x76,
+0x77,0x98,0x98,0x98,0x77,0x77,0x77,0x22,
+0xae,0xcb,0x71,0x3a,0xa8,0x97,0x69,0x96,
+0x68,0x77,0x99,0x75,0x67,0x89,0x98,0x67,
+0x89,0x97,0x57,0x9a,0x87,0x65,0x8a,0x71,
+0x17,0xdd,0xb6,0x35,0xaa,0x76,0x79,0xb9,
+0x54,0x68,0x97,0x65,0x35,0xde,0x97,0x66,
+0x7a,0x74,0x68,0xbb,0x85,0x68,0x76,0x78,
+0x88,0x42,0x8d,0x97,0x97,0x59,0xc8,0x58,
+0x87,0x77,0x78,0xa8,0x67,0x63,0x5b,0xdb,
+0x96,0x57,0x76,0x58,0xaa,0xb9,0x56,0x67,
+0x77,0x86,0x65,0xbb,0x94,0x47,0x9b,0xa8,
+0x79,0x86,0x56,0x89,0x98,0x77,0x53,0x4c,
+0xb6,0x9b,0x88,0x95,0x48,0x86,0x99,0x7a,
+0x95,0x58,0x87,0x87,0x43,0x9e,0x95,0x78,
+0x8a,0x95,0x69,0x87,0x67,0x78,0x87,0x63,
+0x17,0xeb,0x87,0x78,0x86,0x46,0xaa,0x88,
+0x68,0x97,0x57,0x89,0x96,0x45,0x99,0x77,
+0x8a,0xb9,0x65,0x68,0x98,0x77,0x98,0x65,
+0x21,0x7f,0xc8,0xa9,0x77,0x63,0x5a,0xa9,
+0x98,0x77,0x76,0x78,0x64,0x6d,0xd8,0x68,
+0x88,0x75,0x68,0xa9,0x97,0x87,0x65,0x78,
+0x98,0x64,0x8c,0xa6,0x58,0xba,0x86,0x79,
+0x85,0x68,0x97,0x78,0x88,0x43,0x69,0x9b,
+0xa7,0x78,0x66,0x55,0x7b,0xb9,0x99,0x77,
+0x65,0x10,0x5e,0xca,0xaa,0xa8,0x54,0x67,
+0x78,0x89,0xa9,0x77,0x76,0x54,0x49,0xb9,
+0x9a,0xa9,0x66,0x57,0x76,0x78,0xaa,0x88,
+0x78,0x76,0x66,0x46,0xbb,0x68,0xa8,0x98,
+0x67,0x88,0x79,0x99,0x98,0x85,0x28,0x95,
+0x7a,0x9a,0xa6,0x79,0x67,0x75,0x78,0x76,
+0x89,0x78,0x76,0x56,0x77,0x68,0x98,0x79,
+0x99,0x96,0x68,0x77,0x76,0x79,0x85,0x7a,
+0x87,0x77,0x89,0x97,0x78,0x98,0x67,0x88,
+0x77,0x78,0x88,0x88,0x88,0x88,0x77,0x66,
+0x76,0x68,0x98,0xa9,0x79,0x97,0x77,0x86,
+0x57,0x87,0x77,0x88,0x87,0x79,0x88,0x87,
+0x78,0x87,0x88,0x77,0x76,0x67,0x87,0x78,
+0x88,0x77,0x78,0x98,0x88,0x88,0x77,0x87,
+0x77,0x78,0x99,0x77,0x89,0x87,0x77,0x88,
+0x77,0x88,0x88,0x88,0x87,0x66,0x78,0x88,
+0x88,0x88,0x77,0x77,0x77,0x88,0x88,0x78,
+0x77,0x77,0x76,0x87,0x78,0x87,0x77,0x87,
+0x88,0x67,0x87,0x78,0x78,0x87,0x77,0x66,
+0x77,0x89,0x77,0x77,0x78,0x78,0x89,0x88,
+0x88,0x88,0x87,0x88,0x88,0x88,0xa9,0x87,
+0x88,0x78,0x77,0x78,0x98,0x88,0x98,0x78,
+0x86,0x78,0x78,0x88,0x77,0x77,0x78,0x77,
+0x88,0x98,0x88,0x88,0x77,0x67,0x77,0x88,
+0x77,0x88,0x77,0x77,0x77,0x78,0x88,0x67,
+0x86,0x67,0x78,0x88,0x87,0x77,0x87,0x78,
+0x88,0x76,0x78,0x87,0x79,0x87,0x78,0x77,
+0x89,0x88,0x88,0x88,0x77,0x78,0x78,0x98,
+0x77,0x77,0x77,0x67,0x98,0x88,0x76,0x68,
+0x87,0x77,0x77,0x66,0x87,0x78,0x87,0x78,
+0x88,0x88,0x89,0x87,0x87,0x77,0x77,0x88,
+0x88,0x98,0x77,0x76,0x68,0x86,0x78,0x87,
+0x77,0x78,0x88,0x88,0x77,0x88,0x78,0x88,
+0x88,0x77,0x89,0x88,0x87,0x78,0x87,0x77,
+0x88,0x88,0x88,0x77,0x77,0x68,0x78,0x99,
+0x77,0x66,0x89,0x76,0x77,0x77,0x78,0x88,
+0x87,0x77,0x87,0x78,0x89,0x86,0x68,0x87,
+0x67,0x68,0x87,0x78,0x88,0x88,0x77,0x78,
+0x77,0x89,0x76,0x68,0x87,0x87,0x77,0x78,
+0x88,0x88,0x87,0x88,0x88,0x88,0x88,0x77,
+0x98,0x77,0x78,0x88,0x88,0x88,0x88,0x77,
+0x88,0x78,0x88,0x76,0x78,0x87,0x77,0x77,
+0x77,0x76,0x78,0x77,0x88,0x78,0x87,0x88,
+0x67,0x88,0x77,0x87,0x77,0x87,0x79,0x88,
+0x87,0x78,0x88,0x99,0x87,0x77,0x79,0x87,
+0x77,0x78,0x77,0x78,0x77,0x78,0x88,0x87,
+0x77,0x78,0x88,0x88,0x77,0x78,0x88,0x78,
+0x87,0x77,0x78,0x89,0x99,0x98,0x87,0x78,
+0x77,0x87,0x77,0x76,0x67,0x77,0x77,0x89,
+0x98,0x77,0x88,0x88,0x88,0x87,0x75,0x67,
+0x67,0x96,0x77,0x57,0x88,0x9a,0x9a,0xa9,
+0xa9,0x79,0x75,0x55,0x66,0x67,0x67,0x78,
+0x99,0x98,0x98,0x88,0x88,0xa8,0x88,0x67,
+0x86,0x66,0x88,0x77,0x88,0x77,0x79,0xa7,
+0x78,0x98,0x89,0x86,0x88,0x66,0x56,0x78,
+0x66,0x88,0x76,0x78,0x87,0x88,0x99,0x89,
+0xa9,0x88,0x75,0x57,0x75,0x55,0x67,0x67,
+0x88,0x87,0x99,0x99,0xa9,0xa9,0x78,0x74,
+0x57,0x65,0x76,0x57,0x87,0x88,0x89,0x89,
+0x97,0x89,0x89,0x98,0x89,0x85,0x67,0x66,
+0x78,0x88,0x76,0x99,0x78,0x98,0x99,0x99,
+0x98,0x98,0x67,0x66,0x77,0x75,0x67,0x66,
+0x78,0x88,0x88,0x88,0x89,0xa9,0xa8,0x87,
+0x45,0x75,0x67,0x76,0x77,0x67,0x87,0x89,
+0x87,0x9b,0xa9,0x99,0x88,0x75,0x67,0x65,
+0x56,0x77,0x87,0x88,0x98,0x77,0x89,0xb9,
+0xa9,0x88,0x77,0x65,0x66,0x66,0x67,0x75,
+0x68,0x88,0x89,0x99,0xaa,0x9a,0x99,0xa9,
+0x75,0x56,0x66,0x67,0x67,0x56,0x77,0x89,
+0x98,0x89,0x99,0x89,0x99,0x87,0x66,0x67,
+0x67,0x76,0x65,0x57,0x89,0x98,0x9a,0xaa,
+0xaa,0x9a,0x98,0x77,0x56,0x65,0x46,0x76,
+0x57,0x99,0x78,0x78,0x88,0x99,0x99,0x88,
+0x77,0x75,0x56,0x77,0x66,0x77,0x77,0x77,
+0x89,0xa9,0x89,0xa9,0x99,0x98,0x76,0x56,
+0x75,0x66,0x67,0x67,0x76,0x79,0x98,0x9a,
+0xa9,0x99,0xaa,0x87,0x65,0x67,0x76,0x66,
+0x65,0x57,0x88,0x99,0xaa,0x9a,0x9a,0xaa,
+0x97,0x65,0x56,0x56,0x76,0x76,0x67,0x77,
+0x78,0x99,0x98,0x99,0x8a,0x99,0x77,0x76,
+0x68,0x77,0x67,0x66,0x87,0x78,0x89,0x99,
+0x98,0x99,0x88,0x87,0x67,0x75,0x66,0x56,
+0x65,0x68,0x66,0x78,0x99,0x99,0x89,0x99,
+0x9a,0x87,0x66,0x67,0x66,0x66,0x66,0x76,
+0x77,0xab,0xa9,0x99,0x99,0xa8,0x88,0x65,
+0x55,0x56,0x66,0x77,0x77,0x68,0x89,0xa9,
+0x99,0x99,0x99,0x99,0x66,0x46,0x77,0x67,
+0x76,0x67,0x76,0x99,0x99,0x89,0xaa,0x99,
+0xa9,0x96,0x66,0x55,0x76,0x57,0x66,0x77,
+0x88,0x98,0x9a,0xb9,0x9a,0xaa,0x97,0x55,
+0x66,0x57,0x56,0x66,0x76,0x77,0x98,0xaa,
+0xb9,0xa9,0xb9,0x95,0x55,0x55,0x45,0x56,
+0x67,0x79,0x87,0x88,0x99,0x9b,0x9a,0xaa,
+0x97,0x64,0x45,0x56,0x67,0x76,0x67,0x77,
+0x88,0xaa,0xba,0xba,0xa9,0xa6,0x67,0x47,
+0x24,0x27,0x47,0x87,0xa6,0xa7,0xa9,0xcb,
+0xba,0xca,0xa8,0x65,0x46,0x36,0x46,0x58,
+0x65,0xa7,0xa8,0xab,0xbb,0xaa,0xaa,0x97,
+0x75,0x35,0x33,0x36,0x65,0x98,0xa9,0x98,
+0x89,0xaa,0xbb,0xaa,0x86,0x74,0x42,0x45,
+0x37,0x58,0x77,0x89,0xa7,0xa9,0xaa,0xba,
+0xaa,0x66,0x55,0x43,0x45,0x24,0x47,0x78,
+0xb9,0xd8,0x99,0xb9,0xcd,0xc9,0x75,0xa2,
+0x53,0x36,0x46,0x4a,0x69,0x8b,0x9a,0xaa,
+0xab,0xdb,0xa9,0x64,0xa3,0x32,0x62,0x44,
+0x57,0x79,0xac,0xaa,0x99,0xb9,0xcc,0xb6,
+0x77,0x64,0x32,0x42,0x44,0x78,0x69,0x9b,
+0x98,0xac,0xb8,0xcc,0xa6,0x75,0x83,0x30,
+0x44,0x25,0x39,0x58,0x9d,0xba,0xdd,0xda,
+0xca,0xc9,0x55,0xa1,0x20,0x61,0x35,0x4a,
+0x78,0xbb,0xda,0xdd,0xfa,0xa8,0xc7,0x05,
+0x53,0x01,0x43,0x51,0x6b,0xa8,0xbf,0xed,
+0xdc,0xea,0x76,0x86,0x05,0x23,0x02,0x36,
+0x73,0xac,0xca,0xde,0xdd,0xba,0xb9,0x65,
+0x40,0x33,0x30,0x26,0x58,0x6a,0xac,0xce,
+0xec,0xcb,0xa9,0x86,0x52,0x03,0x54,0x24,
+0x88,0x88,0xdd,0xed,0xdb,0xab,0x87,0x75,
+0x54,0x02,0x25,0x22,0x6a,0xab,0xbd,0xdd,
+0xba,0x89,0x76,0x54,0x56,0x02,0x37,0x53,
+0x6a,0xdc,0xdc,0xdd,0xb9,0x77,0x75,0x43,
+0x55,0x16,0x57,0x76,0x87,0xbc,0xcb,0xbb,
+0xca,0x65,0x56,0x44,0x45,0x55,0x57,0x78,
+0x88,0x9c,0xbb,0xba,0xb9,0x96,0x55,0x78,
+0x76,0x42,0x58,0x86,0x67,0x8c,0xcb,0x98,
+0x98,0x98,0x65,0x77,0x66,0x65,0x35,0x79,
+0x87,0x8a,0xbc,0xa8,0x88,0x78,0x86,0x67,
+0x78,0x75,0x36,0x77,0x78,0x76,0x8b,0xcc,
+0xa8,0x68,0x87,0x66,0x77,0x68,0x75,0x67,
+0x64,0x68,0x78,0x88,0x98,0x88,0x78,0x97,
+0x88,0x78,0x98,0x77,0x88,0x89,0x77,0x87,
+0x77,0x78,0x99,0x87,0x88,0x77,0x78,0x88,
+0x98,0x77,0x77,0x66,0x77,0x87,0x68,0x87,
+0x77,0x78,0x88,0x88,0x88,0x88,0x88,0x89,
+0x97,0x67,0x76,0x78,0x89,0x97,0x66,0x66,
+0x67,0x78,0x99,0x87,0x77,0x78,0x76,0x78,
+0x87,0x77,0x67,0x76,0x78,0x77,0x88,0x98,
+0x88,0x88,0x99,0x87,0x89,0x88,0x78,0x99,
+0x77,0x66,0x66,0x67,0x88,0x88,0x87,0x77,
+0x87,0x77,0x78,0x88,0x77,0x88,0x77,0x98,
+0x78,0x88,0x88,0x77,0x76,0x77,0x66,0x77,
+0x88,0x99,0x98,0x87,0x78,0x77,0x89,0x98,
+0x88,0x76,0x67,0x66,0x67,0x88,0x66,0x67,
+0x77,0x88,0x88,0x89,0x99,0x98,0x88,0x99,
+0x88,0x88,0x87,0x88,0x88,0x97,0x66,0x76,
+0x67,0x88,0x78,0x87,0x77,0x88,0x76,0x68,
+0x88,0x78,0x88,0x88,0x78,0x77,0x78,0x77,
+0x88,0x89,0x88,0x77,0x78,0x78,0x98,0x88,
+0x76,0x67,0x76,0x77,0x88,0x87,0x78,0x78,
+0x86,0x67,0x99,0x76,0x88,0x88,0x88,0x87,
+0x78,0x99,0x88,0x88,0x88,0x87,0x78,0x87,
+0x88,0x88,0x97,0x78,0x78,0x78,0x98,0x88,
+0x88,0x77,0x67,0x66,0x77,0x76,0x77,0x78,
+0x87,0x78,0x87,0x88,0x98,0x88,0x88,0x77,
+0x77,0x78,0x77,0x87,0x88,0x76,0x67,0x76,
+0x78,0x87,0x78,0x78,0x76,0x76,0x58,0x87,
+0x67,0x88,0x78,0x88,0x88,0x78,0x89,0x88,
+0x88,0x98,0x88,0x88,0x78,0x88,0x88,0x88,
+0x77,0x77,0x76,0x77,0x88,0x78,0x88,0x77,
+0x76,0x77,0x77,0x78,0x77,0x88,0x88,0x87,
+0x78,0x98,0x88,0x98,0x77,0x78,0x87,0x79,
+0x88,0x88,0x87,0x77,0x67,0x67,0x88,0x77,
+0x99,0x77,0x77,0x67,0x88,0x77,0x77,0x79,
+0x88,0x77,0x88,0x98,0x88,0x88,0x98,0x88,
+0x98,0x77,0x88,0x87,0x88,0x87,0x76,0x76,
+0x67,0x87,0x78,0x98,0x77,0x77,0x66,0x78,
+0x78,0x66,0x88,0x88,0x78,0x78,0x88,0x88,
+0x99,0x87,0x88,0x87,0x89,0x98,0x88,0x88,
+0x77,0x66,0x77,0x78,0x88,0x89,0x88,0x77,
+0x76,0x78,0x86,0x76,0x79,0x98,0x88,0x88,
+0x78,0x89,0x88,0x99,0x87,0x77,0x77,0x88,
+0x78,0x98,0x98,0x77,0x77,0x76,0x88,0x78,
+0x88,0x78,0x67,0x77,0x67,0x77,0x77,0x77,
+0x88,0x76,0x78,0x79,0x98,0x89,0x87,0x78,
+0x77,0x78,0x97,0x89,0x88,0x87,0x76,0x67,
+0x68,0x87,0x88,0x88,0x76,0x77,0x67,0x88,
+0x67,0x77,0x89,0x97,0x79,0x98,0x98,0x79,
+0x99,0x88,0x77,0x87,0x78,0x88,0x89,0x98,
+0x87,0x66,0x76,0x67,0x78,0x88,0x86,0x78,
+0x77,0x77,0x77,0x66,0x79,0x88,0x77,0x78,
+0x78,0x89,0x98,0x88,0x77,0x78,0x78,0x99,
+0x88,0x99,0x97,0x76,0x67,0x77,0x88,0x78,
+0x77,0x77,0x76,0x67,0x77,0x66,0x68,0x89,
+0x88,0x78,0x88,0x88,0x98,0x88,0x89,0x86,
+0x78,0x77,0x87,0x78,0x99,0x78,0x77,0x66,
+0x77,0x88,0x88,0x89,0x66,0x77,0x68,0x76,
+0x77,0x88,0x88,0x87,0x77,0x88,0x88,0x89,
+0x88,0x87,0x57,0x87,0x79,0x88,0x9a,0x88,
+0x77,0x66,0x67,0x78,0x88,0x88,0x76,0x77,
+0x77,0x87,0x76,0x67,0x88,0x89,0x87,0x78,
+0x87,0x89,0x88,0x89,0x77,0x89,0x77,0x88,
+0x79,0x88,0x99,0x76,0x66,0x77,0x77,0x88,
+0x77,0x78,0x77,0x76,0x67,0x65,0x68,0x87,
+0x86,0x68,0x97,0x78,0x99,0x98,0x76,0x77,
+0x88,0x88,0x89,0x89,0x98,0x77,0x76,0x68,
+0x87,0x89,0x88,0x87,0x77,0x77,0x78,0x66,
+0x77,0x98,0x89,0x87,0x88,0x77,0x89,0x98,
+0x78,0x87,0x77,0x88,0x89,0x88,0x89,0x98,
+0x76,0x66,0x77,0x78,0x88,0x88,0x88,0x76,
+0x68,0x76,0x66,0x78,0x88,0x88,0x77,0x78,
+0x88,0x98,0x88,0x86,0x66,0x79,0x87,0x89,
+0x88,0x88,0x77,0x76,0x78,0x88,0x88,0x88,
+0x87,0x77,0x77,0x77,0x66,0x67,0x79,0x89,
+0x87,0x88,0x88,0x89,0xa8,0x77,0x76,0x87,
+0x99,0xa6,0x87,0x8a,0x78,0x77,0x85,0x69,
+0x67,0x87,0x7a,0x99,0x57,0x87,0x77,0x66,
+0x96,0x67,0x89,0x78,0x78,0x7a,0x97,0x78,
+0x87,0x67,0x78,0x86,0x88,0x87,0x78,0x86,
+0x58,0x68,0xaa,0x98,0xaa,0x87,0x75,0x67,
+0x68,0x95,0x66,0x66,0x58,0xa7,0x9a,0xab,
+0xa8,0x65,0x53,0x57,0x79,0xaa,0xa7,0x55,
+0x59,0xad,0xdc,0xb9,0x94,0x41,0x03,0x67,
+0xdc,0x79,0x85,0x43,0x59,0xdc,0xbd,0x9a,
+0x72,0x10,0x13,0x8c,0xde,0xb6,0x44,0x57,
+0xdf,0xdd,0xaa,0xb6,0x00,0x00,0x29,0xcd,
+0xe9,0x78,0x88,0xbd,0xa9,0x88,0x76,0x21,
+0x00,0x37,0xcd,0xdc,0x99,0x8a,0x9b,0xa9,
+0x87,0x74,0x01,0x11,0x69,0xbe,0xed,0x9a,
+0x87,0x86,0x78,0x78,0x73,0x20,0x03,0x7b,
+0xcf,0xdb,0xb8,0x76,0x66,0x67,0x77,0x63,
+0x13,0x47,0xac,0xbd,0xca,0x98,0x75,0x57,
+0x8b,0xb8,0x10,0x01,0x59,0xde,0xdc,0x9a,
+0x98,0x97,0x55,0x44,0x57,0x66,0x75,0x68,
+0x9a,0xdd,0xaa,0x85,0x69,0x8b,0xcb,0x82,
+0x00,0x14,0x9c,0xde,0xbb,0xa9,0x76,0x64,
+0x45,0x68,0x99,0x77,0x64,0x77,0x9a,0xa8,
+0x67,0x67,0xaa,0xab,0x97,0x50,0x01,0x37,
+0x9b,0xfd,0xcc,0x97,0x54,0x44,0x66,0x8a,
+0xaa,0x75,0x54,0x66,0x9a,0x9a,0x99,0x89,
+0xa8,0x88,0x77,0x30,0x22,0x4b,0xcf,0xec,
+0xa8,0x65,0x56,0x56,0x78,0x9b,0xb8,0x66,
+0x44,0x56,0x9b,0xba,0xa8,0x88,0x99,0xa8,
+0x76,0x01,0x23,0x9c,0xce,0xca,0x86,0x55,
+0x56,0x57,0x89,0xbb,0xa8,0x43,0x12,0x57,
+0xce,0xcc,0xb8,0x65,0x77,0x89,0x77,0x21,
+0x43,0xae,0xae,0xc8,0x76,0x65,0x57,0x48,
+0xa8,0xba,0x84,0x23,0x15,0xaa,0xcd,0xbb,
+0x76,0x56,0x99,0xba,0x72,0x12,0x29,0xdb,
+0xec,0x88,0x76,0x56,0x65,0x89,0x9c,0xba,
+0x63,0x20,0x37,0x8d,0xeb,0xa8,0x65,0x69,
+0x89,0xa7,0x40,0x14,0x5c,0xdd,0xda,0x87,
+0x56,0x57,0x76,0x99,0x9b,0xa7,0x44,0x34,
+0x79,0xbc,0xca,0x86,0x56,0x89,0x89,0x87,
+0x12,0x42,0xcd,0xad,0xb8,0x86,0x55,0x68,
+0x7b,0x99,0xc9,0x54,0x32,0x37,0x9a,0xed,
+0xaa,0x66,0x67,0x99,0xa8,0x40,0x21,0x5d,
+0xbd,0xd9,0x77,0x55,0x67,0x67,0x97,0xaa,
+0x98,0x53,0x23,0x68,0xbf,0xcc,0xa6,0x54,
+0x68,0x9b,0x98,0x20,0x43,0xae,0xae,0xa7,
+0x84,0x55,0x78,0x6a,0x89,0xb8,0x86,0x35,
+0x26,0x9a,0xeb,0xa9,0x57,0x79,0xa9,0xb9,
+0x51,0x12,0x2a,0xea,0xfb,0x88,0x56,0x66,
+0x76,0x98,0x8c,0x97,0x54,0x22,0x56,0xae,
+0xbc,0xa6,0x65,0x78,0xa9,0x75,0x02,0x46,
+0xed,0xde,0x77,0x64,0x65,0x88,0x69,0x7a,
+0xb9,0xa6,0x23,0x03,0x79,0xed,0xcb,0x77,
+0x54,0x78,0xa9,0x73,0x14,0x48,0xdb,0xeb,
+0x67,0x45,0x79,0x97,0x98,0x69,0x97,0x75,
+0x43,0x47,0x8b,0xcb,0xc9,0x65,0x56,0x9a,
+0xb9,0x50,0x23,0x4b,0xcd,0xe8,0x87,0x45,
+0x68,0x78,0x95,0x78,0x79,0x97,0x55,0x66,
+0x9b,0xab,0x97,0x77,0x79,0x99,0x95,0x13,
+0x14,0xba,0xff,0x98,0x64,0x54,0x77,0x89,
+0x59,0xa8,0xa8,0x65,0x44,0x36,0xaa,0xdc,
+0x99,0x66,0x78,0x89,0x71,0x24,0x39,0xcd,
+0xfb,0x97,0x34,0x47,0x88,0xb9,0x88,0x78,
+0x86,0x64,0x45,0x6a,0xcc,0xc9,0x76,0x56,
+0x79,0x97,0x55,0x53,0x8a,0xbf,0xb9,0x74,
+0x55,0x78,0x99,0x87,0x97,0x78,0x76,0x76,
+0x66,0x89,0xbb,0x98,0x86,0x78,0x88,0x64,
+0x33,0x38,0x9b,0xf9,0xa9,0x55,0x36,0x78,
+0xa8,0x88,0x78,0x86,0x67,0x66,0x88,0x8a,
+0xa9,0x99,0x88,0x76,0x75,0x34,0x34,0x9a,
+0xee,0xaa,0x64,0x33,0x66,0xab,0x9a,0x96,
+0x64,0x57,0x88,0x99,0x88,0xa8,0x79,0x88,
+0x88,0x76,0x33,0x34,0xaa,0xcd,0xaa,0x85,
+0x55,0x67,0x8a,0x88,0x95,0x46,0x55,0x88,
+0x9b,0xaa,0xa7,0x67,0x88,0x9a,0x97,0x53,
+0x32,0x5a,0xad,0xdb,0xa7,0x55,0x58,0x89,
+0x87,0x86,0x25,0x65,0xaa,0xbb,0x98,0x74,
+0x46,0x88,0xaa,0x99,0x63,0x42,0x39,0x8c,
+0xea,0xb9,0x77,0x46,0x68,0x88,0x97,0x44,
+0x54,0x9b,0xbc,0xb8,0x87,0x54,0x76,0x79,
+0xa8,0x98,0x32,0x34,0x68,0xac,0xcb,0xb9,
+0x66,0x76,0x78,0x97,0x64,0x35,0x47,0xaa,
+0xcc,0xa9,0x66,0x67,0x9a,0xa9,0x85,0x32,
+0x34,0x8b,0xcf,0xea,0xa6,0x43,0x45,0x69,
+0x98,0xba,0x77,0x63,0x58,0x8a,0xb9,0x9a,
+0x87,0xa9,0x88,0x67,0x51,0x23,0x47,0xdd,
+0xce,0xb9,0x85,0x35,0x55,0x78,0x78,0x96,
+0x69,0x86,0x97,0x68,0x77,0x99,0x9b,0xba,
+0xb9,0x63,0x00,0x01,0x59,0xbf,0xed,0xc9,
+0x66,0x56,0x56,0x65,0x77,0x68,0x98,0xaa,
+0x89,0x76,0x45,0x67,0xb9,0xac,0xa8,0x75,
+0x32,0x14,0x79,0xdd,0xcd,0xb8,0x74,0x55,
+0x66,0x67,0x77,0x78,0x8a,0xba,0x88,0x86,
+0x66,0x79,0xaa,0xba,0x97,0x32,0x22,0x37,
+0xab,0xfd,0xbc,0x85,0x76,0x67,0x87,0x66,
+0x43,0x45,0x8a,0xbd,0xc9,0x87,0x67,0x78,
+0x89,0x87,0x74,0x23,0x44,0xab,0xce,0xca,
+0x96,0x56,0x55,0x87,0x78,0x86,0x43,0x46,
+0xbb,0xcd,0xa8,0x76,0x58,0xa9,0xaa,0x85,
+0x31,0x03,0x68,0xbe,0xcc,0xd9,0x77,0x55,
+0x56,0x56,0x96,0x67,0x66,0x78,0x8a,0xbb,
+0x98,0x66,0x78,0x9a,0x98,0x86,0x31,0x23,
+0x4a,0xbd,0xeb,0xcb,0x87,0x66,0x44,0x65,
+0x67,0x67,0x87,0x9a,0x99,0xa7,0x57,0x75,
+0x9a,0x9c,0xca,0x84,0x00,0x03,0x78,0xae,
+0xec,0xd9,0x9a,0x76,0x66,0x54,0x55,0x44,
+0x66,0xaa,0xad,0xa9,0x97,0x66,0x66,0x7a,
+0x99,0x84,0x22,0x14,0x6a,0xdd,0xec,0xa9,
+0x77,0x66,0x65,0x56,0x45,0x66,0x77,0xaa,
+0xac,0xa9,0x96,0x67,0x67,0x9a,0xa9,0x84,
+0x32,0x04,0x67,0xcc,0xef,0xcb,0xa8,0x76,
+0x76,0x44,0x45,0x66,0x87,0xaa,0xac,0xaa,
+0xa7,0x67,0x66,0x9a,0x98,0x95,0x22,0x02,
+0x77,0xbe,0xee,0xdb,0x86,0x65,0x44,0x44,
+0x66,0x77,0x89,0x89,0x87,0xa9,0x98,0x8a,
+0x87,0x76,0x89,0x88,0x75,0x31,0x33,0x69,
+0xcf,0xed,0xea,0x86,0x45,0x43,0x25,0x66,
+0x88,0x78,0x87,0x88,0x98,0x9b,0x89,0x87,
+0x89,0x88,0x98,0x53,0x11,0x25,0x78,0xff,
+0xef,0xd8,0x76,0x43,0x44,0x47,0x76,0x99,
+0x87,0x97,0x7a,0x88,0xa9,0x79,0x98,0x88,
+0x78,0x87,0x55,0x43,0x46,0x8a,0xbd,0xed,
+0xda,0x66,0x44,0x45,0x65,0x78,0x77,0x89,
+0x89,0x97,0x98,0x57,0x87,0x89,0x88,0x88,
+0x76,0x74,0x24,0x33,0x67,0xae,0xff,0xed,
+0x96,0x42,0x24,0x44,0x67,0x77,0x99,0x79,
+0x99,0xb9,0x88,0x87,0x68,0x77,0x98,0x88,
+0x74,0x32,0x23,0x79,0xbe,0xde,0xdb,0x76,
+0x54,0x45,0x55,0x56,0x69,0xbb,0xba,0x87,
+0x54,0x66,0x8a,0xab,0xba,0x88,0x86,0x77,
+0x75,0x22,0x11,0x47,0x9f,0xff,0xee,0x96,
+0x54,0x34,0x45,0x78,0x8a,0xa8,0x77,0x66,
+0x77,0x68,0x87,0x9a,0xa8,0x88,0x68,0x76,
+0x64,0x34,0x35,0x8a,0xcf,0xdd,0xb7,0x55,
+0x43,0x45,0x45,0x78,0x9a,0xba,0xa9,0x76,
+0x53,0x45,0x8a,0xbc,0xb9,0x96,0x67,0x67,
+0x77,0x54,0x32,0x48,0xac,0xff,0xec,0x85,
+0x32,0x33,0x66,0x69,0x98,0xaa,0xaa,0x86,
+0x55,0x55,0x79,0xab,0xbb,0xaa,0x86,0x55,
+0x57,0x77,0x44,0x54,0x58,0xcd,0xfe,0xba,
+0x74,0x32,0x46,0x76,0x68,0x89,0xbb,0xa9,
+0x85,0x44,0x33,0x7a,0xbd,0xdb,0xa8,0x66,
+0x67,0x56,0x66,0x54,0x44,0x58,0xcd,0xef,
+0xca,0x85,0x34,0x54,0x68,0x66,0x76,0x8a,
+0xbb,0xa8,0x54,0x43,0x58,0x9c,0xdc,0xcb,
+0x86,0x65,0x56,0x75,0x43,0x24,0x49,0xbb,
+0xff,0xdd,0x85,0x44,0x44,0x67,0x88,0x67,
+0xaa,0xab,0xca,0x86,0x41,0x22,0x48,0xbe,
+0xfd,0xca,0x96,0x44,0x34,0x66,0x66,0x88,
+0xab,0xab,0x96,0x56,0x67,0x89,0x9b,0xa8,
+0x78,0x77,0x78,0x66,0x53,0x24,0x38,0xcc,
+0xff,0xca,0x74,0x34,0x56,0x78,0x66,0x55,
+0x79,0xbc,0xba,0x86,0x52,0x23,0x59,0xbc,
+0xdc,0x97,0x54,0x45,0x56,0x8b,0xab,0xba,
+0x88,0x76,0x55,0x45,0x77,0x67,0x88,0xad,
+0xca,0xa8,0x54,0x55,0x68,0x89,0xa9,0x76,
+0x54,0x56,0x57,0x99,0xbd,0xbc,0xca,0x65,
+0x43,0x36,0x78,0x99,0x88,0x98,0x9a,0x86,
+0x64,0x25,0x8a,0xdd,0xba,0x85,0x34,0x55,
+0x78,0x89,0x85,0x45,0x56,0x9b,0xce,0xc8,
+0x76,0x45,0x56,0x89,0x76,0x76,0x79,0xa9,
+0x99,0x77,0x65,0x66,0x55,0x67,0x8b,0xbb,
+0xdc,0x97,0x44,0x45,0x66,0x76,0x68,0x9b,
+0xcc,0xb8,0x53,0x21,0x25,0x9c,0xee,0xdd,
+0xa7,0x55,0x45,0x56,0x89,0x88,0x75,0x67,
+0x78,0xa9,0xbb,0x87,0x86,0x56,0x77,0x98,
+0x67,0x78,0x87,0x89,0x99,0x67,0x77,0x56,
+0x54,0x45,0x8b,0xef,0xfc,0x95,0x34,0x44,
+0x67,0x66,0x78,0xbd,0xca,0x87,0x32,0x21,
+0x35,0x48,0xbc,0xff,0xdc,0xa7,0x55,0x43,
+0x56,0x67,0x78,0x99,0x99,0x87,0x55,0x23,
+0x56,0xae,0xed,0xca,0x88,0x64,0x55,0x34,
+0x67,0x89,0xab,0xba,0x97,0x43,0x33,0x56,
+0x7b,0xcc,0xcb,0xb9,0x65,0x55,0x43,0x46,
+0x8a,0xbc,0xa9,0x87,0x76,0x66,0x43,0x45,
+0x5b,0xcd,0xfd,0xb9,0x64,0x45,0x45,0x54,
+0x58,0x9b,0xcb,0xb9,0x64,0x35,0x55,0x54,
+0x44,0x7a,0xdf,0xfd,0xa6,0x43,0x56,0x88,
+0x87,0x67,0x79,0xcb,0x97,0x44,0x33,0x57,
+0x76,0x76,0x69,0xac,0xfe,0xb8,0x64,0x45,
+0x67,0x87,0x65,0x65,0x8b,0xcc,0xa8,0x54,
+0x34,0x77,0x78,0x65,0x79,0xcf,0xfd,0xb7,
+0x32,0x33,0x58,0x9a,0xa8,0x77,0x66,0x88,
+0x9a,0xa8,0x75,0x66,0x66,0x67,0x66,0x89,
+0xcc,0xbb,0x87,0x55,0x78,0x98,0x97,0x76,
+0x68,0x88,0x88,0x65,0x44,0x56,0x7a,0xba,
+0x99,0x99,0x99,0x98,0x75,0x55,0x57,0x98,
+0x87,0x87,0x78,0x99,0x76,0x54,0x45,0x66,
+0x9a,0xac,0xa8,0x99,0x77,0x77,0x66,0x57,
+0x98,0x89,0x77,0x77,0x77,0x88,0x75,0x55,
+0x67,0x8a,0xaa,0x85,0x54,0x57,0x8b,0xbb,
+0xa8,0x77,0x78,0x88,0x98,0x77,0x67,0x67,
+0x77,0x88,0x87,0x65,0x44,0x68,0xbd,0xcc,
+0xa8,0x77,0x66,0x99,0x87,0x76,0x68,0x88,
+0x98,0x76,0x66,0x68,0x87,0x97,0x77,0x77,
+0x99,0x88,0x87,0x66,0x77,0x78,0x87,0x89,
+0x99,0x99,0xa9,0x77,0x65,0x56,0x76,0x66,
+0x55,0x68,0x89,0x99,0x88,0x76,0x66,0x56,
+0x77,0x9b,0xcd,0xd9,0x97,0x64,0x67,0x88,
+0x98,0x76,0x65,0x79,0x89,0x98,0x67,0x65,
+0x78,0x88,0x89,0x88,0x89,0x99,0x88,0x77,
+0x87,0x87,0x65,0x56,0x78,0xbc,0xa9,0x98,
+0x67,0x77,0x88,0x77,0x76,0x67,0x87,0x79,
+0x86,0x77,0x67,0x88,0x77,0x77,0x77,0x77,
+0x88,0x98,0x99,0x99,0x99,0x98,0x78,0x67,
+0x87,0x66,0x67,0x78,0x88,0x88,0x77,0x77,
+0x68,0x88,0x78,0x66,0x86,0x68,0x97,0x78,
+0x77,0x88,0x78,0x88,0x77,0x78,0x99,0xa9,
+0x87,0x67,0x67,0x87,0x67,0x77,0x87,0x77,
+0x87,0x77,0x77,0x87,0x68,0x98,0x78,0x77,
+0x99,0x77,0x87,0x88,0x89,0x99,0x87,0x78,
+0x88,0x99,0x99,0x86,0x77,0x67,0x65,0x67,
+0x67,0x89,0x88,0x87,0x87,0x78,0x77,0x88,
+0x77,0x87,0x78,0x88,0x87,0x77,0x88,0x98,
+0x88,0x76,0x77,0x88,0x98,0x87,0x67,0x88,
+0x88,0x76,0x66,0x78,0x88,0x88,0x77,0x77,
+0x77,0x79,0x98,0x78,0x77,0x77,0x77,0x77,
+0x78,0x89,0x97,0x88,0x78,0x89,0x99,0x98,
+0x77,0x78,0x88,0x87,0x76,0x67,0x88,0x88,
+0x98,0x77,0x67,0x88,0x87,0x78,0x77,0x67,
+0x88,0x77,0x78,0x88,0x88,0x88,0x77,0x88,
+0x98,0x98,0x87,0x77,0x78,0x97,0x77,0x77,
+0x88,0x88,0x98,0x77,0x77,0x78,0x78,0x87,
+0x67,0x66,0x77,0x77,0x77,0x77,0x77,0x78,
+0x87,0x77,0x88,0x99,0x88,0x77,0x77,0x88,
+0x77,0x77,0x78,0x88,0x99,0x89,0x88,0x78,
+0x87,0x88,0x77,0x77,0x67,0x77,0x77,0x77,
+0x78,0x89,0x88,0x77,0x87,0x78,0x88,0x87,
+0x77,0x88,0x88,0x77,0x77,0x88,0x89,0x98,
+0x88,0x88,0x87,0x78,0x88,0x77,0x87,0x77,
+0x77,0x77,0x77,0x78,0x88,0x77,0x78,0x77,
+0x78,0x88,0x77,0x78,0x88,0x76,0x66,0x77,
+0x78,0x99,0x88,0x87,0x77,0x78,0x98,0x87,
+0x78,0x77,0x77,0x78,0x78,0x77,0x88,0x88,
+0x88,0x77,0x77,0x88,0x87,0x77,0x88,0x77,
+0x77,0x77,0x77,0x88,0x88,0x77,0x77,0x77,
+0x88,0x88,0x77,0x77,0x77,0x87,0x77,0x77,
+0x77,0x88,0x88,0x88,0x87,0x88,0x88,0x88,
+0x88,0x88,0x88,0x77,0x78,0x88,0x88,0x88,
+0x87,0x77,0x78,0x87,0x77,0x77,0x77,0x78,
+0x77,0x77,0x77,0x78,0x88,0x97,0x77,0x77,
+0x78,0x88,0x88,0x88,0x88,0x77,0x78,0x88,
+0x88,0x88,0x88,0x78,0x88,0x88,0x88,0x87,
+0x78,0x77,0x87,0x77,0x77,0x77,0x78,0x88,
+0x87,0x77,0x77,0x88,0x88,0x87,0x88,0x77,
+0x77,0x78,0x78,0x88,0x88,0x88,0x78,0x78,
+0x88,0x88,0x77,0x88,0x87,0x77,0x78,0x77,
+0x88,0x88,0x88,0x77,0x77,0x78,0x88,0x77,
+0x88,0x87,0x77,0x78,0x88,0x88,0x88,0x88,
+0x77,0x87,0x78,0x88,0x77,0x78,0x87,0x78,
+0x77,0x77,0x77,0x78,0x78,0x88,0x77,0x78,
+0x88,0x88,0x88,0x87,0x88,0x77,0x88,0x78,
+0x88,0x88,0x88,0x77,0x78,0x88,0x77,0x77,
+0x78,0x77,0x87,0x77,0x78,0x87,0x88,0x88,
+0x77,0x77,0x77,0x88,0x88,0x87,0x77,0x88,
+0x77,0x88,0x88,0x88,0x88,0x88,0x87,0x88,
+0x88,0x88,0x88,0x88,0x87,0x77,0x77,0x77,
+0x88,0x78,0x88,0x77,0x78,0x88,0x88,0x88,
+0x77,0x77,0x77,0x77,0x88,0x88,0x88,0x88,
+0x87,0x77,0x88,0x77,0x88,0x77,0x77,0x78,
+0x77,0x78,0x87,0x78,0x88,0x87,0x77,0x77,
+0x88,0x88,0x87,0x77,0x88,0x77,0x88,0x88,
+0x88,0x88,0x87,0x87,0x88,0x88,0x88,0x87,
+0x77,0x88,0x87,0x78,0x77,0x77,0x77,0x88,
+0x87,0x78,0x78,0x88,0x88,0x77,0x88,0x77,
+0x87,0x88,0x88,0x87,0x88,0x88,0x78,0x88,
+0x78,0x87,0x78,0x88,0x88,0x77,0x78,0x88,
+0x77,0x88,0x87,0x77,0x77,0x77,0x88,0x87,
+0x78,0x88,0x88,0x88,0x88,0x88,0x88,0x88,
+0x88,0x88,0x87,0x88,0x88,0x88,0x88,0x77,
+0x77,0x77,0x88,0x77,0x88,0x88,0x88,0x88,
+0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,
+0x88,0x88,0x88,0x88
+};
diff --git a/gbdk/gbdk-lib/examples/gb/scroller/Makefile b/gbdk/gbdk-lib/examples/gb/scroller/Makefile
new file mode 100644
index 00000000..5e2e8405
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/scroller/Makefile
@@ -0,0 +1,17 @@
+CC = ../../../bin/lcc -Wa-l -Wl-m -Wl-j
+
+BINS = text_scroller.gb
+
+all: $(BINS)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+# Compile and link single file in one pass
+%.gb: %.c
+ $(CC) -o $@ $<
+
+clean:
+ rm -f *.o *.lst *.map *.gb *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi
+
diff --git a/gbdk/gbdk-lib/examples/gb/scroller/text_scroller.c b/gbdk/gbdk-lib/examples/gb/scroller/text_scroller.c
new file mode 100644
index 00000000..0c136200
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/scroller/text_scroller.c
@@ -0,0 +1,72 @@
+#include <gb/gb.h>
+#include <stdint.h>
+#include <stdio.h>
+
+#include <gb/emu_debug.h>
+
+const uint8_t scanline_offsets_tbl[] = {0, 1, 2, 3, 3, 2, 1, 0, 0, 1, 2, 3, 3, 2, 1, 0};
+const uint8_t * scanline_offsets = scanline_offsets_tbl;
+
+#define SCROLL_POS 15
+#define SCROLL_POS_PIX_START (SCROLL_POS * 8) - 1
+#define SCROLL_POS_PIX_END ((SCROLL_POS + 1) * 8) - 1
+
+uint8_t scroller_x = 0;
+
+void scanline_isr() {
+ switch (LYC_REG) {
+ case 0:
+ SCX_REG = 0;
+ LYC_REG = SCROLL_POS_PIX_START;
+ break;
+ case SCROLL_POS_PIX_START:
+ SCX_REG = scroller_x;
+ LYC_REG = SCROLL_POS_PIX_END;
+ break;
+ case SCROLL_POS_PIX_END:
+ SCX_REG = LYC_REG = 0;
+ break;
+ }
+}
+
+const uint8_t scroller_text[] = "This is a text scroller demo for GBDK-2020. You can use ideas, that are "\
+"shown in this demo, to make different parallax effects, scrolling of tilemaps which are larger than 32x32 "\
+"tiles and TEXT SCROLLERS, of course! Need to write something else to make this text longer than 256 characters. "\
+"The quick red fox jumps over the lazy brown dog. 0123456789. ";
+
+const uint8_t * scroller_next_char = scroller_text;
+uint8_t * scroller_vram_addr;
+uint16_t base, limit;
+
+void main() {
+ printf("Scrolling %d chars", sizeof(scroller_text) - 1);
+
+ CRITICAL {
+ STAT_REG |= STATF_LYC; LYC_REG = 0;
+ add_LCD(scanline_isr);
+ }
+ set_interrupts(VBL_IFLAG | LCD_IFLAG);
+
+ scroller_vram_addr = get_bkg_xy_addr(20, SCROLL_POS);
+ set_vram_byte(scroller_vram_addr, *scroller_next_char - 0x20);
+
+ base = (uint16_t) scroller_vram_addr & 0xffe0;
+ limit = base + 0x20;
+
+ while (1) {
+ scroller_x++;
+ if ((scroller_x & 0x07) == 0) {
+ // next letter
+ scroller_next_char++;
+ if (*scroller_next_char == 0) scroller_next_char = scroller_text;
+
+ // next vram position
+ scroller_vram_addr++;
+ if (scroller_vram_addr == (uint8_t *)limit) scroller_vram_addr = (uint8_t *)base;
+
+ // put next char
+ set_vram_byte(scroller_vram_addr, *scroller_next_char - 0x20);
+ }
+ wait_vbl_done();
+ }
+} \ No newline at end of file
diff --git a/gbdk/gbdk-lib/examples/gb/sgb_border/Makefile b/gbdk/gbdk-lib/examples/gb/sgb_border/Makefile
new file mode 100644
index 00000000..986b9dfd
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/sgb_border/Makefile
@@ -0,0 +1,13 @@
+CC = ../../../bin/lcc
+PNG2ASSET = ../../../bin/png2asset
+
+all:
+ $(PNG2ASSET) gb_border.png -map -bpp 4 -max_palettes 4 -pack_mode sgb -use_map_attributes -c border_data.c
+ $(CC) -Wm-ys -o border.gb border.c sgb_border.c border_data.c
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+clean:
+ rm -f *.o *.lst *.map *.gb *.ihx *.sym *.cdb *.adb *.asm
diff --git a/gbdk/gbdk-lib/examples/gb/sgb_border/border.c b/gbdk/gbdk-lib/examples/gb/sgb_border/border.c
new file mode 100644
index 00000000..3c3990e6
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/sgb_border/border.c
@@ -0,0 +1,18 @@
+#include <gb/gb.h>
+#include <stdint.h>
+#include "sgb_border.h"
+
+#include "border_data.h"
+
+void main(void) {
+
+ // Wait 4 frames
+ // For SGB on PAL SNES this delay is required on startup, otherwise borders don't show up
+ for (uint8_t i = 4; i != 0; i--) wait_vbl_done();
+
+ DISPLAY_ON;
+ set_sgb_border(border_data_tiles, sizeof(border_data_tiles), border_data_map, sizeof(border_data_map), border_data_palettes, sizeof(border_data_palettes));
+ while(1) {
+ wait_vbl_done();
+ }
+} \ No newline at end of file
diff --git a/gbdk/gbdk-lib/examples/gb/sgb_border/gb_border.png b/gbdk/gbdk-lib/examples/gb/sgb_border/gb_border.png
new file mode 100644
index 00000000..b7821f67
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/sgb_border/gb_border.png
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/gb/sgb_border/sgb_border.c b/gbdk/gbdk-lib/examples/gb/sgb_border/sgb_border.c
new file mode 100644
index 00000000..1280b191
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/sgb_border/sgb_border.c
@@ -0,0 +1,69 @@
+#include "sgb_border.h"
+
+#include <gb/gb.h>
+#include <stdint.h>
+#include <gb/sgb.h>
+#include <string.h>
+
+#define SGB_CHR_BLOCK0 0
+#define SGB_CHR_BLOCK1 1
+
+#define SGB_SCR_FREEZE 1
+#define SGB_SCR_UNFREEZE 0
+
+#define SGB_TRANSFER(A,B) map_buf[0]=(A),map_buf[1]=(B),sgb_transfer(map_buf)
+
+void set_sgb_border(unsigned char * tiledata, size_t tiledata_size,
+ unsigned char * tilemap, size_t tilemap_size,
+ unsigned char * palette, size_t palette_size) {
+ if (sgb_check()) {
+ unsigned char map_buf[20];
+ memset(map_buf, 0, sizeof(map_buf));
+
+ SGB_TRANSFER((SGB_MASK_EN << 3) | 1, SGB_SCR_FREEZE);
+
+ BGP_REG = OBP0_REG = OBP1_REG = 0xE4U;
+ SCX_REG = SCY_REG = 0U;
+
+ uint8_t tmp_lcdc = LCDC_REG;
+
+ HIDE_SPRITES, HIDE_WIN, SHOW_BKG;
+ DISPLAY_ON;
+ // prepare tilemap for SGB_BORDER_CHR_TRN (should display all 256 tiles)
+ uint8_t i = 0U;
+ for (uint8_t y = 0; y != 14U; ++y) {
+ uint8_t * dout = map_buf;
+ for (uint8_t x = 0U; x != 20U; ++x) {
+ *dout++ = i++;
+ }
+ set_bkg_tiles(0, y, 20, 1, map_buf);
+ }
+ memset(map_buf, 0, sizeof(map_buf));
+
+ // transfer tile data
+ uint8_t ntiles = (tiledata_size > 256 * 32) ? 0 : tiledata_size >> 5;
+ if ((!ntiles) || (ntiles > 128U)) {
+ set_bkg_data(0, 0, tiledata);
+ SGB_TRANSFER((SGB_CHR_TRN << 3) | 1, SGB_CHR_BLOCK0);
+ if (ntiles) ntiles -= 128U;
+ tiledata += (128 * 32);
+ set_bkg_data(0, ntiles << 1, tiledata);
+ SGB_TRANSFER((SGB_CHR_TRN << 3) | 1, SGB_CHR_BLOCK1);
+ } else {
+ set_bkg_data(0, ntiles << 1, tiledata);
+ SGB_TRANSFER((SGB_CHR_TRN << 3) | 1, SGB_CHR_BLOCK0);
+ }
+
+ // transfer map and palettes
+ set_bkg_data(0, (uint8_t)(tilemap_size >> 4), tilemap);
+ set_bkg_data(128, (uint8_t)(palette_size >> 4), palette);
+ SGB_TRANSFER((SGB_PCT_TRN << 3) | 1, 0);
+
+ LCDC_REG = tmp_lcdc;
+
+ // clear SCREEN
+ fill_bkg_rect(0, 0, 20, 18, 0);
+
+ SGB_TRANSFER((SGB_MASK_EN << 3) | 1, SGB_SCR_UNFREEZE);
+ }
+}
diff --git a/gbdk/gbdk-lib/examples/gb/sgb_border/sgb_border.h b/gbdk/gbdk-lib/examples/gb/sgb_border/sgb_border.h
new file mode 100644
index 00000000..a1967cab
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/sgb_border/sgb_border.h
@@ -0,0 +1,24 @@
+#ifndef __SGB_BORDER_H_INCLUDE
+#define __SGB_BORDER_H_INCLUDE
+
+#include <gb/gb.h>
+#include <stdint.h>
+
+#define SNES_RGB(R,G,B) (uint16_t)((B) << 10 | (G) << 5 | (R))
+
+/** sets SGB border
+
+ When using the SGB with a PAL SNES, a delay should be added
+ just after program startup such as:
+
+ \code{.c}
+ // Wait 4 frames
+ // For PAL SNES this delay is required on startup
+ for (uint8_t i = 4; i != 0; i--) wait_vbl_done();
+ \endcode
+*/
+void set_sgb_border(unsigned char * tiledata, size_t tiledata_size,
+ unsigned char * tilemap, size_t tilemap_size,
+ unsigned char * palette, size_t palette_size);
+
+#endif \ No newline at end of file
diff --git a/gbdk/gbdk-lib/examples/gb/sgb_multiplayer/Makefile b/gbdk/gbdk-lib/examples/gb/sgb_multiplayer/Makefile
new file mode 100644
index 00000000..1a92aa04
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/sgb_multiplayer/Makefile
@@ -0,0 +1,17 @@
+CC = ../../../bin/lcc -Wa-l -Wl-m -Wl-j -Wm-ys
+
+BINS = sgb_multiplayer.gb
+
+all: $(BINS)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+# Compile and link single file in one pass
+%.gb: %.c
+ $(CC) -o $@ $<
+
+clean:
+ rm -f *.o *.lst *.map *.gb *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi
+
diff --git a/gbdk/gbdk-lib/examples/gb/sgb_multiplayer/sgb_multiplayer.c b/gbdk/gbdk-lib/examples/gb/sgb_multiplayer/sgb_multiplayer.c
new file mode 100644
index 00000000..bd50fbb2
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/sgb_multiplayer/sgb_multiplayer.c
@@ -0,0 +1,47 @@
+#include <gb/gb.h>
+#include <stdint.h>
+#include <gb/sgb.h>
+
+uint8_t sprite_data[] = {
+ 0x3C,0x3C,0x42,0x7E,0x99,0xFF,0xA9,0xFF,0x89,0xFF,0x89,0xFF,0x42,0x7E,0x3C,0x3C,
+ 0x3C,0x3C,0x42,0x7E,0xB9,0xFF,0x89,0xFF,0x91,0xFF,0xB9,0xFF,0x42,0x7E,0x3C,0x3C,
+ 0x3C,0x3C,0x42,0x7E,0x99,0xFF,0x89,0xFF,0x99,0xFF,0x89,0xFF,0x5A,0x7E,0x3C,0x3C,
+ 0x3C,0x3C,0x42,0x7E,0xA9,0xFF,0xA9,0xFF,0xB9,0xFF,0x89,0xFF,0x42,0x7E,0x3C,0x3C
+};
+
+joypads_t joypads;
+
+void main(void) {
+ BGP_REG = OBP0_REG = OBP1_REG = 0xE4;
+ set_sprite_data(0, 4, sprite_data);
+ for (uint8_t i = 0; i < 4; i++) {
+ set_sprite_tile(i, i);
+ move_sprite(i, (i << 3) + 64, 64);
+ }
+ SHOW_SPRITES;
+
+ // Wait 4 frames
+ // For SGB on PAL SNES this delay is required on startup, otherwise borders don't show up
+ for (uint8_t i = 4; i != 0; i--) wait_vbl_done();
+
+ // init joypads
+ joypad_init(4, &joypads);
+
+ while(1) {
+ // poll joypads
+ joypad_ex(&joypads);
+ // iterate joypads, move sprites
+ for (uint8_t i = 0; i < joypads.npads; i++) {
+ uint8_t joy = joypads.joypads[i];
+ if (joy & J_LEFT) scroll_sprite(i, -1, 0);
+ if (joy & J_RIGHT) scroll_sprite(i, 1, 0);
+ if (joy & J_UP) scroll_sprite(i, 0, -1);
+ if (joy & J_DOWN) scroll_sprite(i, 0, 1);
+ }
+ // start on joypad 1 resets position
+ if (joypads.joy0 & J_START) {
+ for (uint8_t i = 0; i < 4; i++) move_sprite(i, (i << 3) + 64, 64);
+ }
+ wait_vbl_done();
+ }
+} \ No newline at end of file
diff --git a/gbdk/gbdk-lib/examples/gb/sgb_pong/Makefile b/gbdk/gbdk-lib/examples/gb/sgb_pong/Makefile
new file mode 100644
index 00000000..2ea801e3
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/sgb_pong/Makefile
@@ -0,0 +1,17 @@
+CC = ../../../bin/lcc -Wa-l -Wl-m -Wl-j -Wm-ys
+
+BINS = sgb_pong.gb
+
+all: $(BINS)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+# Compile and link single file in one pass
+%.gb: %.c
+ $(CC) -o $@ $<
+
+clean:
+ rm -f *.o *.lst *.map *.gb *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi
+
diff --git a/gbdk/gbdk-lib/examples/gb/sgb_pong/sgb_pong.c b/gbdk/gbdk-lib/examples/gb/sgb_pong/sgb_pong.c
new file mode 100644
index 00000000..6b62718b
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/sgb_pong/sgb_pong.c
@@ -0,0 +1,144 @@
+#include <gb/gb.h>
+#include <gb/sgb.h>
+#include <gbdk/console.h>
+
+#include <stdint.h>
+#include <stdio.h>
+
+uint8_t sprite_data[] = {
+ 0x3C,0x3C,0x42,0x7E,0x99,0xFF,0xA9,0xFF,0x89,0xFF,0x89,0xFF,0x42,0x7E,0x3C,0x3C,
+ 0x3C,0x3C,0x42,0x7E,0xB9,0xFF,0x89,0xFF,0x91,0xFF,0xB9,0xFF,0x42,0x7E,0x3C,0x3C,
+ 0x3C,0x3C,0x42,0x7E,0x99,0xFF,0x89,0xFF,0x99,0xFF,0x89,0xFF,0x5A,0x7E,0x3C,0x3C,
+ 0x3C,0x3C,0x42,0x7E,0xA9,0xFF,0xA9,0xFF,0xB9,0xFF,0x89,0xFF,0x42,0x7E,0x3C,0x3C
+
+};
+
+// initializes sprites for pad. every pad uses 3 sprites which id's are aligned by 4
+void init_pad(uint8_t n) {
+ set_sprite_tile(n << 2, n);
+ set_sprite_tile((n << 2) + 1, n);
+ set_sprite_tile((n << 2) + 2, n);
+}
+
+// inline function for moving pads; code of this function will be inlined with the code of main()
+inline void draw_pad(uint8_t n, uint8_t x, uint8_t y) {
+ move_sprite(n << 2, x, y);
+ move_sprite((n << 2) + 1, x, y + 8);
+ move_sprite((n << 2) + 2, x, y + 16);
+}
+
+joypads_t joypads;
+
+// absolute Y coordinates of player 1 & 2
+uint8_t player1, player2;
+uint16_t player1_score, player2_score;
+
+// player constraints
+#define YMIN 28
+#define YMAX 100
+#define PLAYER1_X 16
+#define PLAYER2_X (uint8_t)((20 * 8) - 8)
+
+// coordinates and speeds of ball
+uint8_t ballX, ballY;
+int8_t spd_ballX, spd_ballY;
+
+#define INITBALLX 80 + 4
+#define INITBALLY 64 + 8
+
+const unsigned char HUD[] = " p1: %d p2: %d";
+
+// main funxction
+void main(void) {
+ // init palettes
+ BGP_REG = OBP0_REG = OBP1_REG = 0xE4;
+
+ // load tile data into VRAM
+ set_sprite_data(0, 4, sprite_data);
+
+ // init pad sprites
+ init_pad(0);
+ init_pad(1);
+
+ // init ball sprite
+ set_sprite_tile(3, 2);
+
+ // show bkg and sprites
+ SHOW_BKG; SHOW_SPRITES;
+
+ // init 2 joypads
+ if (joypad_init(2, &joypads) != 2) {
+ printf(" This program must\n be executed on\n Super GameBoy");
+ return;
+ }
+
+ // init players
+ player1 = 64, player2 = 64;
+ player1_score = player2_score = 0;
+
+ // draw score
+ printf(HUD, player1_score, player2_score);
+
+ // init ball
+ ballX = INITBALLX, ballY = INITBALLY;
+ spd_ballX = 1, spd_ballY = 1;
+
+ while(1) {
+ // poll joypads
+ joypad_ex(&joypads);
+
+ // player 1
+ if (joypads.joy0 & J_UP) {
+ player1 -= 2;
+ if (player1 < YMIN) player1 = YMIN;
+ } else if (joypads.joy0 & J_DOWN) {
+ player1 += 2;
+ if (player1 > YMAX) player1 = YMAX;
+ }
+ draw_pad(0, PLAYER1_X, player1);
+
+ // player 2
+ if (joypads.joy1 & J_UP) {
+ player2 -= 2;
+ if (player2 < YMIN) player2 = YMIN;
+ } else if (joypads.joy1 & J_DOWN) {
+ player2 += 2;
+ if (player2 > YMAX) player2 = YMAX;
+ }
+ draw_pad(1, PLAYER2_X, player2);
+
+ // move ball
+ ballX += spd_ballX, ballY += spd_ballY;
+ // check bounce from limits
+ if ((ballY < YMIN) || (ballY > (YMAX + 24))) {
+ spd_ballY = -spd_ballY;
+ }
+ // check bounce from bats
+ if (ballX < (PLAYER1_X + 8)) {
+ if ((ballY > player1) && (ballY < (player1 + 24)) && (spd_ballX < 0))
+ spd_ballX = -spd_ballX;
+ } else if (ballX > (PLAYER2_X - 8)) {
+ if ((ballY > player2) && (ballY < (player2 + 24)) && (spd_ballX > 0))
+ spd_ballX = -spd_ballX;
+ }
+ // check player1 or 2 wins, update scores, start from center
+ if (ballX < PLAYER1_X) {
+ // player2 wins
+ ballX = INITBALLX, ballY = INITBALLY;
+ spd_ballX = -spd_ballX;
+ player2_score++;
+ gotoxy(0, 0); printf(HUD, player1_score, player2_score);
+ } else if (ballX > PLAYER2_X) {
+ // player1 wins
+ ballX = INITBALLX, ballY = INITBALLY;
+ spd_ballX = -spd_ballX;
+ player1_score++;
+ gotoxy(0, 0); printf(HUD, player1_score, player2_score);
+ }
+ // move ball sprite
+ move_sprite(3, ballX, ballY);
+
+ // wait for VBlank to slow down everything
+ wait_vbl_done();
+ }
+} \ No newline at end of file
diff --git a/gbdk/gbdk-lib/examples/gb/simple_physics/Makefile b/gbdk/gbdk-lib/examples/gb/simple_physics/Makefile
new file mode 100644
index 00000000..447327a5
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/simple_physics/Makefile
@@ -0,0 +1,17 @@
+CC = ../../../bin/lcc -Wl-m -Wl-j -Wm-yS
+
+BINS = phys.gb
+
+all: $(BINS)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+# Compile and link single file in one pass
+%.gb: %.c
+ $(CC) -o $@ $<
+
+clean:
+ rm -f *.o *.lst *.map *.gb *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi
+
diff --git a/gbdk/gbdk-lib/examples/gb/simple_physics/Readme.md b/gbdk/gbdk-lib/examples/gb/simple_physics/Readme.md
new file mode 100644
index 00000000..8f4ba140
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/simple_physics/Readme.md
@@ -0,0 +1,3 @@
+
+A simple sub-pixel / fixed point physics movement example.
+
diff --git a/gbdk/gbdk-lib/examples/gb/simple_physics/phys.c b/gbdk/gbdk-lib/examples/gb/simple_physics/phys.c
new file mode 100644
index 00000000..e5a4672b
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/simple_physics/phys.c
@@ -0,0 +1,93 @@
+#include <gb/gb.h>
+#include <gb/sgb.h>
+
+#include <stdio.h>
+#include <gbdk/console.h>
+
+// A simple sub-pixel / fixed point example
+// Postion values are calculated as 16 bit numbers and their
+// lower 4 bits are dropped when applying them to the sprite
+
+UINT8 sprite_data[] = {
+ 0x3C,0x3C,0x42,0x7E,0x99,0xFF,0xA9,0xFF,0x89,0xFF,0x89,0xFF,0x42,0x7E,0x3C,0x3C,
+ 0x3C,0x3C,0x42,0x7E,0xB9,0xFF,0x89,0xFF,0x91,0xFF,0xB9,0xFF,0x42,0x7E,0x3C,0x3C,
+ 0x3C,0x3C,0x42,0x7E,0x99,0xFF,0x89,0xFF,0x99,0xFF,0x89,0xFF,0x5A,0x7E,0x3C,0x3C,
+ 0x3C,0x3C,0x42,0x7E,0xA9,0xFF,0xA9,0xFF,0xB9,0xFF,0x89,0xFF,0x42,0x7E,0x3C,0x3C
+
+};
+
+joypads_t joypads;
+
+// sprite coords
+UINT16 PosX, PosY;
+INT16 SpdX, SpdY;
+UINT8 Jump;
+
+// main funxction
+void main(void) {
+ // init palettes
+ BGP_REG = OBP0_REG = OBP1_REG = 0xE4;
+
+ // load tile data into VRAM
+ set_sprite_data(0, 4, sprite_data);
+
+ // set sprite tile
+ set_sprite_tile(0, 0);
+
+ // show bkg and sprites
+ SHOW_BKG; SHOW_SPRITES;
+
+ // init 2 joypads
+ joypad_init(1, &joypads);
+
+ PosX = PosY = 64 << 4;
+ Jump = SpdX = SpdY = 0;
+
+ while(1) {
+ // poll joypads
+ joypad_ex(&joypads);
+
+ // game object
+ if (joypads.joy0 & J_UP) {
+ SpdY -= 2;
+ if (SpdY < -64) SpdY = -64;
+ } else if (joypads.joy0 & J_DOWN) {
+ SpdY += 2;
+ if (SpdY > 64) SpdY = 64;
+ }
+ if (joypads.joy0 & J_LEFT) {
+ SpdX -= 2;
+ if (SpdX < -64) SpdX = -64;
+ } else if (joypads.joy0 & J_RIGHT) {
+ SpdX += 2;
+ if (SpdX > 64) SpdX = 64;
+ }
+ if ((joypads.joy0 & J_A) && (!Jump)) {
+ Jump = 3;
+ }
+
+ // jump
+ if (Jump) {
+ SpdY -= 8;
+ if (SpdY < -32) SpdY = -32;
+ Jump--;
+ }
+
+ PosX += SpdX, PosY += SpdY;
+
+ // Translate to pixels and move sprite
+ // Downshift by 4 bits to use the whole number values
+ move_sprite(0, PosX >> 4, PosY >> 4);
+
+ // decelerate
+ if (SpdY >= 0) {
+ if (SpdY) SpdY--;
+ } else SpdY ++;
+ if (SpdX >= 0) {
+ if (SpdX) SpdX--;
+ } else SpdX ++;
+
+ // Done processing, yield CPU and wait for start of next frame (VBlank)
+ wait_vbl_done();
+ }
+}
diff --git a/gbdk/gbdk-lib/examples/gb/sound/Makefile b/gbdk/gbdk-lib/examples/gb/sound/Makefile
new file mode 100644
index 00000000..80c73463
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/sound/Makefile
@@ -0,0 +1,17 @@
+CC = ../../../bin/lcc -Wa-l -Wl-m -Wl-j
+
+BINS = sound.gb
+
+all: $(BINS)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+# Compile and link single file in one pass
+%.gb: %.c
+ $(CC) -o $@ $<
+
+clean:
+ rm -f *.o *.lst *.map *.gb *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi
+
diff --git a/gbdk/gbdk-lib/examples/gb/sound/readme.md b/gbdk/gbdk-lib/examples/gb/sound/readme.md
new file mode 100644
index 00000000..cc9a9faf
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/sound/readme.md
@@ -0,0 +1,13 @@
+Updated version of the original Sound Sample that merges
+in changes made at: https://github.com/gbdk-2020/GBSoundDemo
+
+Keys:
+- Select: change current channel menu
+- Start: play current Sound
+- Start + A: play a song
+- Arrows: navigate throught options
+- Arrows + A: Increments/Decrements current value by 10
+- Arrows + B: Increments/Decrements current value by 100
+- Arrows + A + B: set Min/Max value to current option
+- Select + A: Dump Registers
+
diff --git a/gbdk/gbdk-lib/examples/gb/sound/sound.c b/gbdk/gbdk-lib/examples/gb/sound/sound.c
new file mode 100644
index 00000000..57193f37
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/sound/sound.c
@@ -0,0 +1,1067 @@
+#include <gb/gb.h>
+#include <gbdk/console.h>
+#include <stdint.h>
+#include <stdio.h>
+
+#define ARROW_CHAR '>'
+#define SPACE_CHAR ' '
+
+#define ARROW_X 0
+#define VAL_X 15
+#define TITLE_Y 0
+#define FIRST_X (ARROW_X+1)
+#define FIRST_Y (TITLE_Y+2)
+
+#define PLAY 0x20
+#define FREQUENCY 0x21
+
+#define MIN(x,y) ((x) > (y) ? (y) : (x))
+#define MAX(x,y) ((x) < (y) ? (y) : (x))
+
+#define NB_MODES 5
+
+#define UNSIGNED 0
+
+uint8_t previous_keys = 0;
+int8_t keys = 0;
+#define UPDATE_KEYS() previous_keys = keys; keys = joypad()
+#define KEY_PRESSED(K) (keys & (K))
+#define KEY_TICKED(K) ((keys & (K)) && !(previous_keys & (K)))
+
+void show_register_channel(uint8_t mode);
+
+void clss() {
+ uint8_t i = 0;
+ for(i = 0; i < 18; ++i) {
+ gotoxy(0, i);
+ printf(" ");
+ }
+}
+
+void print(const char* str) {
+ printf("%s", str);
+}
+
+const char hex[] = "0123456789ABCDEF";
+void printn(uint16_t n, uint8_t base, uint8_t sign) {
+ (void) sign;
+ if(base == 16u) {
+ printf("%c", hex[0x000Fu & (n >> 4u)]);
+ printf("%c", hex[0x000Fu & (n)]);
+ } else {
+ printf("%d", n);
+ }
+}
+
+
+void println(uint16_t n, uint8_t base, uint8_t sign) {
+ printn(n, base, sign);
+ printf("\n");
+}
+
+enum notes {
+ C0, Cd0, D0, Dd0, E0, F0, Fd0, G0, Gd0, A0, Ad0, B0,
+ C1, Cd1, D1, Dd1, E1, F1, Fd1, G1, Gd1, A1, Ad1, B1,
+ C2, Cd2, D2, Dd2, E2, F2, Fd2, G2, Gd2, A2, Ad2, B2,
+ C3, Cd3, D3, Dd3, E3, F3, Fd3, G3, Gd3, A3, Ad3, B3,
+ C4, Cd4, D4, Dd4, E4, F4, Fd4, G4, Gd4, A4, Ad4, B4,
+ C5, Cd5, D5, Dd5, E5, F5, Fd5, G5, Gd5, A5, Ad5, B5,
+ SILENCE, END
+};
+
+const uint16_t frequencies[] = {
+ 44, 156, 262, 363, 457, 547, 631, 710, 786, 854, 923, 986,
+ 1046, 1102, 1155, 1205, 1253, 1297, 1339, 1379, 1417, 1452, 1486, 1517,
+ 1546, 1575, 1602, 1627, 1650, 1673, 1694, 1714, 1732, 1750, 1767, 1783,
+ 1798, 1812, 1825, 1837, 1849, 1860, 1871, 1881, 1890, 1899, 1907, 1915,
+ 1923, 1930, 1936, 1943, 1949, 1954, 1959, 1964, 1969, 1974, 1978, 1982,
+ 1985, 1988, 1992, 1995, 1998, 2001, 2004, 2006, 2009, 2011, 2013, 2015
+};
+
+const uint8_t music[] = {
+ C3, C3, G3, G3, A3, A3, G3, SILENCE,
+ F3, F3, E3, E3, D3, D3, C3, SILENCE,
+ G3, G3, F3, F3, E3, E3, D3, D3,
+ G3, G3, F3, F3, E3, E3, D3, D3,
+ C3, C3, G3, G3, A3, A3, G3, SILENCE,
+ F3, F3, E3, E3, D3, D3, C3, SILENCE,
+ END
+};
+
+struct Params {
+ char *name;
+ uint16_t max;
+};
+
+const struct Params params_0[] = {
+ { "Main Controls" , 0 },
+ { "All On/Off" , 1 },
+ { "Vin->SO1" , 1 },
+ { "Vin->SO2" , 1 },
+ { "SO1 Volume" , 7 },
+ { "SO2 Volume" , 7 },
+ { NULL , 0 }
+};
+
+const struct Params params_1[] = {
+ { "Sound Mode #1" , 0 },
+ { "Swp Time" , 7 },
+ { "Swp Mode" , 1 },
+ { "Swp Shifts" , 7 },
+ { "Pat Duty" , 3 },
+ { "Sound Len" , 63 },
+ { "Env Init" , 15 },
+ { "Env Mode" , 1 },
+ { "Env Nb Swp" , 7 },
+ { "Frequency" , 2047 },
+ { "Cons Sel" , 1 },
+ { "Out to SO1" , 1 },
+ { "Out to SO2" , 1 },
+ { "On/Off" , 1 },
+ { NULL , 0 }
+};
+
+const struct Params params_2[] = {
+ { "Sound Mode #2" , 0 },
+ { "Pat Duty" , 3 },
+ { "Sound Len" , 63 },
+ { "Env Init" , 15 },
+ { "Env Mode" , 1 },
+ { "Env Nb Step" , 7 },
+ { "Frequency" , 2047 },
+ { "Cons Sel" , 1 },
+ { "Out to SO1" , 1 },
+ { "Out to SO2" , 1 },
+ { "On/Off" , 1 },
+ { NULL , 0 }
+};
+
+const struct Params params_3[] = {
+ { "Sound Mode #3" , 0 },
+ { "Sound On/Off" , 1 },
+ { "Sound Len" , 255 },
+ { "Sel Out Level" , 3 },
+ { "Frequency" , 2047 },
+ { "Cons Sel" , 1 },
+ { "Out to SO1" , 1 },
+ { "Out to SO2" , 1 },
+ { "On/Off" , 1 },
+ { NULL , 0 }
+};
+
+const struct Params params_4[] = {
+ { "Sound Mode #4" , 0 },
+ { "Sound Len" , 63 },
+ { "Env Init" , 15 },
+ { "Env Mode" , 1 },
+ { "Env Nb Step" , 7 },
+ { "Poly Cnt Freq" , 15 },
+ { "Poly Cnt Step" , 1 },
+ { "Poly Cnt Div" , 7 },
+ { "Cons Sel" , 1 },
+ { "Out to SO1" , 1 },
+ { "Out to SO2" , 1 },
+ { "On/Off" , 1 },
+ { NULL , 0 }
+};
+
+const struct Params *params_array[] = {
+ params_0,
+ params_1,
+ params_2,
+ params_3,
+ params_4,
+};
+
+const struct Params *params;
+
+struct SoundReg {
+ struct {
+ //NR10 0xFF10
+ uint16_t sweepShifts ;//: 3;
+ uint16_t sweepMode ;//: 1;
+ uint16_t sweepTime ;//: 3;
+ uint16_t unused_1 ;//: 1;
+
+ //NR11 0xFF11
+ uint16_t soundLength ;//: 6;
+ uint16_t patternDuty ;//: 2;
+
+ //NR12 0xFF12
+ uint16_t envNbSweep ;//: 3;
+ uint16_t envMode ;//: 1;
+ uint16_t envInitialValue ;//: 4;
+
+ //NR13 0xFF13
+ uint16_t frequencyLow;
+
+ //NR14 0xFF14
+ uint16_t frequencyHigh ;//: 3;
+ uint16_t unused_2 ;//: 3;
+ uint16_t counter_ConsSel ;//: 1;
+ uint16_t restart ;//: 1;
+ } mode1;
+ struct {
+ //NR20 0xFF15
+ uint16_t unused_1;
+
+ //NR21 0xFF16
+ uint16_t soundLength ;//: 6;
+ uint16_t patternDuty ;//: 2;
+
+ //NR22 0xFF17
+ uint16_t envNbStep ;//: 3;
+ uint16_t envMode ;//: 1;
+ uint16_t envInitialValue ;//: 4;
+
+ //NR23 0xFF18
+ uint16_t frequencyLow;
+
+ //NR24 0xFF19
+ uint16_t frequencyHigh ;//: 3;
+ uint16_t unused_2 ;//: 3;
+ uint16_t counter_ConsSel ;//: 1;
+ uint16_t restart ;//: 1;
+ } mode2;
+ struct {
+ //NR30 0xFF1A
+ uint16_t unused_1 ;//: 7;
+ uint16_t on_Off ;//: 1;
+
+ //NR31 0xFF1B
+ uint16_t soundLength;
+
+ //NR32 0xFF1C
+ uint16_t unused_2 ;//: 5;
+ uint16_t selOutputLevel ;//: 2;
+ uint16_t unused_3 ;//: 1;
+
+ //NR33 0xFF1D
+ uint16_t frequencyLow;
+
+ //NR34 0xFF1E
+ uint16_t frequencyHigh ;//: 3;
+ uint16_t unused_4 ;//: 3;
+ uint16_t counter_ConsSel ;//: 1;
+ uint16_t restart ;//: 1;
+ } mode3;
+ struct {
+ //NR40 0xFF1F
+ uint16_t unused_1;
+
+ //NR41 0xFF20
+ uint16_t soundLength ;//: 6;
+ uint16_t unused_2 ;//: 2;
+
+ //NR42 0xFF21
+ uint16_t envNbStep ;//: 3;
+ uint16_t envMode ;//: 1;
+ uint16_t envInitialValue ;//: 4;
+
+ //NR43 0xFF22
+ uint16_t polyCounterDiv ;//: 3;
+ uint16_t polyCounterStep ;//: 1;
+ uint16_t polyCounterFreq ;//: 4;
+
+ //NR44 0xFF23
+ uint16_t unused_3 ;//: 6;
+ uint16_t counter_ConsSel ;//: 1;
+ uint16_t restart ;//: 1;
+ } mode4;
+ struct {
+ // NR50 0xFF24
+ uint16_t SO1_OutputLevel ;//: 3;
+ uint16_t Vin_SO1 ;//: 1;
+ uint16_t SO2_OutputLevel ;//: 3;
+ uint16_t Vin_SO2 ;//: 1;
+
+ // NR51 0xFF25
+ uint16_t Sound1_To_SO1 ;//: 1;
+ uint16_t Sound2_To_SO1 ;//: 1;
+ uint16_t Sound3_To_SO1 ;//: 1;
+ uint16_t Sound4_To_SO1 ;//: 1;
+ uint16_t Sound1_To_SO2 ;//: 1;
+ uint16_t Sound2_To_SO2 ;//: 1;
+ uint16_t Sound3_To_SO2 ;//: 1;
+ uint16_t Sound4_To_SO2 ;//: 1;
+
+ // NR52 0xFF26
+ uint16_t Sound1_On_Off ;//: 1;
+ uint16_t Sound2_On_Off ;//: 1;
+ uint16_t Sound3_On_Off ;//: 1;
+ uint16_t Sound4_On_Off ;//: 1;
+ uint16_t unused_1 ;//: 3;
+ uint16_t global_On_Off ;//: 1;
+ } control;
+};
+
+struct SoundReg *soundReg;
+
+struct SoundReg s = {
+ { 0u, 0u, 0u, 0u,
+ 1, 2,
+ 3, 0, 4,
+ 0x73U,
+ 6, 0, 0, 0 },
+ { 0,
+ 1, 2,
+ 4, 0, 8,
+ 0xD7U,
+ 6, 0, 0, 0 },
+ { 0, 1,
+ 0,
+ 0, 3, 0,
+ 0xD6U,
+ 6, 0, 1, 0 },
+ { 0,
+ 58, 0,
+ 1, 0, 10,
+ 0, 0, 0,
+ 0, 1, 0 },
+ { 7, 0, 7, 0,
+ 1, 1, 1, 1, 1, 1, 1, 1,
+ 0, 0, 0, 0, 0, 1 }
+};
+
+uint8_t NR10() {
+ return soundReg->mode1.sweepShifts | (soundReg->mode1.sweepMode << 3) | (soundReg->mode1.sweepTime << 4);
+}
+
+uint8_t NR11() {
+ return soundReg->mode1.soundLength | (soundReg->mode1.patternDuty << 6);
+}
+
+uint8_t NR12() {
+ return soundReg->mode1.envNbSweep | (soundReg->mode1.envMode << 3) | (soundReg->mode1.envInitialValue << 4);
+}
+
+uint8_t NR13() {
+ return soundReg->mode1.frequencyLow;
+}
+
+uint8_t NR14() {
+ return soundReg->mode1.frequencyHigh | (soundReg->mode1.counter_ConsSel << 6) | (soundReg->mode1.restart << 7);
+}
+
+//--------------------------
+uint8_t NR21() {
+ return soundReg->mode2.soundLength | (soundReg->mode2.patternDuty << 6);
+}
+
+uint8_t NR22() {
+ return soundReg->mode2.envNbStep | (soundReg->mode2.envMode << 3) | (soundReg->mode2.envInitialValue << 4);
+}
+
+uint8_t NR23() {
+ return soundReg->mode2.frequencyLow;
+}
+
+uint8_t NR24() {
+ return soundReg->mode2.frequencyHigh | (soundReg->mode2.counter_ConsSel << 6) | (soundReg->mode2.restart << 7);
+}
+
+//-------------------------------
+uint8_t NR30() {
+ return soundReg->mode3.on_Off << 7;
+}
+
+uint8_t NR31() {
+ return soundReg->mode3.soundLength;
+}
+
+uint8_t NR32() {
+ return soundReg->mode3.selOutputLevel << 5;
+}
+
+uint8_t NR33() {
+ return soundReg->mode3.frequencyLow;
+}
+
+uint8_t NR34() {
+ return soundReg->mode3.frequencyHigh | (soundReg->mode3.counter_ConsSel << 6) | (soundReg->mode3.restart << 7);
+}
+
+//-------------------------------
+uint8_t NR41() {
+ return soundReg->mode4.soundLength;
+}
+
+uint8_t NR42() {
+ return soundReg->mode4.envNbStep | (soundReg->mode4.envMode << 3) | (soundReg->mode4.envInitialValue << 4);
+}
+
+uint8_t NR43() {
+ return soundReg->mode4.polyCounterDiv | (soundReg->mode4.polyCounterStep << 3) | (soundReg->mode4.polyCounterFreq << 4);
+}
+
+uint8_t NR44() {
+ return (soundReg->mode4.counter_ConsSel << 6) | (soundReg->mode4.restart << 7);
+}
+
+//-------------------------------
+uint8_t NR50() {
+ return soundReg->control.SO1_OutputLevel | (soundReg->control.Vin_SO1 << 3u) | (soundReg->control.SO2_OutputLevel << 4u) |
+ (soundReg->control.Vin_SO2 << 7u);
+}
+
+uint8_t NR51() {
+ return soundReg->control.Sound1_To_SO1 | (soundReg->control.Sound2_To_SO1 << 1) | (soundReg->control.Sound3_To_SO1 << 2) |
+ (soundReg->control.Sound4_To_SO1 << 3) | (soundReg->control.Sound1_To_SO2 << 4) | (soundReg->control.Sound2_To_SO2 << 5) |
+ (soundReg->control.Sound3_To_SO2 << 6)| (soundReg->control.Sound4_To_SO2 << 7);
+}
+
+uint8_t NR52() {
+ return soundReg->control.global_On_Off << 7;
+}
+
+//---------------------------------------------------------------------------------
+uint16_t current_value(uint8_t mode, uint8_t line)
+{
+ if(mode == 0) {
+ switch(line)
+ {
+ case 0: // global_On_Off
+ return soundReg->control.global_On_Off;
+ case 1: // Vin_SO1
+ return soundReg->control.Vin_SO1;
+ case 2: // Vin_SO2
+ return soundReg->control.Vin_SO2;
+ case 3: // SO1_OutputLevel
+ return soundReg->control.SO1_OutputLevel;
+ case 4: // SO2_OutputLevel
+ return soundReg->control.SO2_OutputLevel;
+ }
+ } else if(mode == 1) {
+ switch(line)
+ {
+ case 0: // sweepTime
+ return soundReg->mode1.sweepTime;
+ case 1: // sweepMode
+ return soundReg->mode1.sweepMode;
+ case 2: // sweepShifts
+ return soundReg->mode1.sweepShifts;
+ case 3: // patternDuty
+ return soundReg->mode1.patternDuty;
+ case 4: // soundLength
+ return soundReg->mode1.soundLength;
+ case 5: // envInitialValue
+ return soundReg->mode1.envInitialValue;
+ case 6: // envMode
+ return soundReg->mode1.envMode;
+ case 7: // envNbSweep
+ return soundReg->mode1.envNbSweep;
+ case 8: // frequency
+ case FREQUENCY:
+ return (soundReg->mode1.frequencyHigh << 8) | soundReg->mode1.frequencyLow;
+ case 9: // counter_ConsSel
+ return soundReg->mode1.counter_ConsSel;
+ case 10: // Sound1_To_SO1
+ return soundReg->control.Sound1_To_SO1;
+ case 11: // Sound1_To_SO2
+ return soundReg->control.Sound1_To_SO2;
+ case 12: // Sound1_On_Off
+ return soundReg->control.Sound1_On_Off;
+ }
+ } else if(mode == 2) {
+ switch(line)
+ {
+ case 0: // patternDuty
+ return soundReg->mode2.patternDuty;
+ case 1: // soundLength
+ return soundReg->mode2.soundLength;
+ case 2: // envInitialValue
+ return soundReg->mode2.envInitialValue;
+ case 3: // envMode
+ return soundReg->mode2.envMode;
+ case 4: // envNbStep
+ return soundReg->mode2.envNbStep;
+ case 5: // frequency
+ case FREQUENCY:
+ return (soundReg->mode2.frequencyHigh << 8) | soundReg->mode2.frequencyLow;
+ case 6: // counter_ConsSel
+ return soundReg->mode2.counter_ConsSel;
+ case 7: // Sound2_To_SO1
+ return soundReg->control.Sound2_To_SO1;
+ case 8: // Sound2_To_SO2
+ return soundReg->control.Sound2_To_SO2;
+ case 9: // Sound2_On_Off
+ return soundReg->control.Sound2_On_Off;
+ }
+ } else if(mode == 3) {
+ switch(line)
+ {
+ case 0: // on_Off
+ return soundReg->mode3.on_Off;
+ case 1: // soundLength
+ return soundReg->mode3.soundLength;
+ case 2: // selOutputLevel
+ return soundReg->mode3.selOutputLevel;
+ case 3: // frequency
+ case FREQUENCY:
+ return (soundReg->mode3.frequencyHigh << 8) | soundReg->mode3.frequencyLow;
+ case 4: // counter_ConsSel
+ return soundReg->mode3.counter_ConsSel;
+ case 5: // Sound3_To_SO1
+ return soundReg->control.Sound3_To_SO1;
+ case 6: // Sound3_To_SO2
+ return soundReg->control.Sound3_To_SO2;
+ case 7: // Sound3_On_Off
+ return soundReg->control.Sound3_On_Off;
+ }
+ } else if(mode == 4) {
+ switch(line)
+ {
+ case 0: // soundLength
+ return soundReg->mode4.soundLength;
+ case 1: // envInitialValue
+ return soundReg->mode4.envInitialValue;
+ case 2: // envMode
+ return soundReg->mode4.envMode;
+ case 3: // envNbStep
+ return soundReg->mode4.envNbStep;
+ case 4: // polyCounterFreq
+ return soundReg->mode4.polyCounterFreq;
+ case 5: // polyCounterStep
+ return soundReg->mode4.polyCounterStep;
+ case 6: // polyCounterDiv
+ return soundReg->mode4.polyCounterDiv;
+ case 7: // counter_ConsSel
+ return soundReg->mode4.counter_ConsSel;
+ case 8: // Sound4_To_SO1
+ return soundReg->control.Sound4_To_SO1;
+ case 9: // Sound4_To_SO2
+ return soundReg->control.Sound4_To_SO2;
+ case 10: // Sound4_On_Off
+ return soundReg->control.Sound4_On_Off;
+ }
+ }
+ return 0;
+}
+
+void update_value(uint8_t mode, uint8_t line, uint16_t value)
+{
+ if(mode == 0) {
+ switch(line)
+ {
+ case 0: // global_On_Off
+ soundReg->control.global_On_Off = value;
+ NR52_REG = NR52();
+ break;
+ case 1: // Vin_SO1
+ soundReg->control.Vin_SO1 = value;
+ NR50_REG = NR50();
+ break;
+ case 2: // Vin_SO2
+ soundReg->control.Vin_SO2 = value;
+ NR50_REG = NR50();
+ break;
+ case 3: // SO1_OutputLevel
+ soundReg->control.SO1_OutputLevel = value;
+ NR50_REG = NR50();
+ break;
+ case 4: // SO2_OutputLevel
+ soundReg->control.SO2_OutputLevel = value;
+ NR50_REG = NR50();
+ break;
+ case FREQUENCY:
+ update_value(1, FREQUENCY, value);
+ update_value(2, FREQUENCY, value);
+ update_value(3, FREQUENCY, value);
+ break;
+ case PLAY: // restart
+ update_value(1, FREQUENCY, current_value(1, FREQUENCY));
+ update_value(2, FREQUENCY, current_value(2, FREQUENCY));
+ update_value(3, FREQUENCY, current_value(3, FREQUENCY));
+ soundReg->mode1.restart = value;
+ soundReg->mode2.restart = value;
+ soundReg->mode3.restart = value;
+ soundReg->mode4.restart = value;
+ NR14_REG = NR14();
+ NR24_REG = NR24();
+ NR34_REG = NR34();
+ NR44_REG = NR44();
+ soundReg->mode1.restart = 0;
+ soundReg->mode2.restart = 0;
+ soundReg->mode3.restart = 0;
+ soundReg->mode4.restart = 0;
+ break;
+ }
+ } else if(mode == 1) {
+ switch(line)
+ {
+ case 0: // sweepTime
+ soundReg->mode1.sweepTime = value;
+ NR10_REG = NR10();
+ break;
+ case 1: // sweepMode
+ soundReg->mode1.sweepMode = value;
+ NR10_REG = NR10();
+ break;
+ case 2: // sweepShifts
+ soundReg->mode1.sweepShifts = value;
+ NR10_REG = NR10();
+ break;
+ case 3: // patternDuty
+ soundReg->mode1.patternDuty = value;
+ NR11_REG = NR11();
+ break;
+ case 4: // soundLength
+ soundReg->mode1.soundLength = value;
+ NR11_REG = NR11();
+ break;
+ case 5: // envInitialValue
+ soundReg->mode1.envInitialValue = value;
+ NR12_REG = NR12();
+ break;
+ case 6: // envMode
+ soundReg->mode1.envMode = value;
+ NR12_REG = NR12();
+ break;
+ case 7: // envNbSweep
+ soundReg->mode1.envNbSweep = value;
+ NR12_REG = NR12();
+ break;
+ case 8: // frequency
+ case FREQUENCY:
+ soundReg->mode1.frequencyHigh = value >> 8;
+ soundReg->mode1.frequencyLow = 0xFF & value;
+ NR13_REG = NR13();
+ NR14_REG = NR14();
+ break;
+ case 9: // counter_ConsSel
+ soundReg->mode1.counter_ConsSel = value;
+ NR14_REG = NR14();
+ break;
+ case 10: // Sound1_To_SO1
+ soundReg->control.Sound1_To_SO1 = value;
+ NR51_REG = NR51();
+ break;
+ case 11: // Sound1_To_SO2
+ soundReg->control.Sound1_To_SO2 = value;
+ NR51_REG = NR51();
+ break;
+ case 12: // Sound1_On_Off
+ soundReg->control.Sound1_On_Off = value;
+ NR52_REG = NR52();
+ break;
+ case PLAY: // restart
+ update_value(mode, FREQUENCY, current_value(mode, FREQUENCY));
+ soundReg->mode1.restart = value;
+ NR14_REG = NR14();
+ soundReg->mode1.restart = 0;
+ break;
+ }
+ } else if(mode == 2) {
+ switch(line)
+ {
+ case 0: // patternDuty
+ soundReg->mode2.patternDuty = value;
+ NR21_REG = NR21();
+ break;
+ case 1: // soundLength
+ soundReg->mode2.soundLength = value;
+ NR21_REG = NR21();
+ break;
+ case 2: // envInitialValue
+ soundReg->mode2.envInitialValue = value;
+ NR22_REG = NR22();
+ break;
+ case 3: // envMode
+ soundReg->mode2.envMode = value;
+ NR22_REG = NR22();
+ break;
+ case 4: // envNbStep
+ soundReg->mode2.envNbStep = value;
+ NR22_REG = NR22();
+ break;
+ case 5: // frequency
+ case FREQUENCY:
+ soundReg->mode2.frequencyHigh = value >> 8;
+ soundReg->mode2.frequencyLow = 0xFF & value;
+ NR23_REG = NR23();
+ NR24_REG = NR24();
+ break;
+ case 6: // counter_ConsSel
+ soundReg->mode2.counter_ConsSel = value;
+ NR24_REG = NR24();
+ break;
+ case 7: // Sound2_To_SO1
+ soundReg->control.Sound2_To_SO1 = value;
+ NR51_REG = NR51();
+ break;
+ case 8: // Sound2_To_SO2
+ soundReg->control.Sound2_To_SO2 = value;
+ NR51_REG = NR51();
+ break;
+ case 9: // Sound2_On_Off
+ soundReg->control.Sound2_On_Off = value;
+ NR52_REG = NR52();
+ break;
+ case PLAY: // restart
+ update_value(mode, FREQUENCY, current_value(mode, FREQUENCY));
+ soundReg->mode2.restart = value;
+ NR24_REG = NR24();
+ soundReg->mode2.restart = 0;
+ break;
+ }
+ } else if(mode == 3) {
+ switch(line)
+ {
+ case 0: // on_Off
+ soundReg->mode3.on_Off = value;
+ NR30_REG = NR30();
+ break;
+ case 1: // soundLength
+ soundReg->mode3.soundLength = value;
+ NR31_REG = NR31();
+ break;
+ case 2: // selOutputLevel
+ soundReg->mode3.selOutputLevel = value;
+ NR32_REG = NR32();
+ break;
+ case 3: // frequency
+ case FREQUENCY:
+ soundReg->mode3.frequencyHigh = value >> 8;
+ soundReg->mode3.frequencyLow = 0xFF & value;
+ NR33_REG = NR33();
+ NR34_REG = NR34();
+ break;
+ case 4: // counter_ConsSel
+ soundReg->mode3.counter_ConsSel = value;
+ NR34_REG = NR34();
+ break;
+ case 5: // Sound3_To_SO1
+ soundReg->control.Sound3_To_SO1 = value;
+ NR51_REG = NR51();
+ break;
+ case 6: // Sound3_To_SO2
+ soundReg->control.Sound3_To_SO2 = value;
+ NR51_REG = NR51();
+ break;
+ case 7: // Sound3_On_Off
+ soundReg->control.Sound3_On_Off = value;
+ NR52_REG = NR52();
+ break;
+ case PLAY: // restart
+ update_value(mode, FREQUENCY, current_value(mode, FREQUENCY));
+ soundReg->mode3.restart = value;
+ NR34_REG = NR34();
+ soundReg->mode3.restart = 0;
+ break;
+ }
+ } else if(mode == 4) {
+ switch(line)
+ {
+ case 0: // soundLength
+ soundReg->mode4.soundLength = value;
+ NR41_REG = NR41();
+ break;
+ case 1: // envInitialValue
+ soundReg->mode4.envInitialValue = value;
+ NR42_REG = NR42();
+ break;
+ case 2: // envMode
+ soundReg->mode4.envMode = value;
+ NR42_REG = NR42();
+ break;
+ case 3: // envNbStep
+ soundReg->mode4.envNbStep = value;
+ NR42_REG = NR42();
+ break;
+ case 4: // polyCounterFreq
+ soundReg->mode4.polyCounterFreq = value;
+ NR43_REG = NR43();
+ break;
+ case 5: // polyCounterStep
+ soundReg->mode4.polyCounterStep = value;
+ NR43_REG = NR43();
+ break;
+ case 6: // polyCounterDiv
+ soundReg->mode4.polyCounterDiv = value;
+ NR43_REG = NR43();
+ break;
+ case 7: // counter_ConsSel
+ soundReg->mode4.counter_ConsSel = value;
+ NR44_REG = NR44();
+ break;
+ case 8: // Sound4_To_SO1
+ soundReg->control.Sound4_To_SO1 = value;
+ NR51_REG = NR51();
+ break;
+ case 9: // Sound4_To_SO2
+ soundReg->control.Sound4_To_SO2 = value;
+ NR51_REG = NR51();
+ break;
+ case 10: // Sound4_On_Off
+ soundReg->control.Sound4_On_Off = value;
+ NR52_REG = NR52();
+ break;
+ case PLAY: // restart
+ soundReg->mode4.restart = value;
+ NR44_REG = NR44();
+ soundReg->mode4.restart = 0;
+ break;
+ }
+ }
+}
+
+uint8_t draw_screen(uint8_t mode)
+{
+ uint8_t i;
+
+ clss();
+ gotoxy(FIRST_X, TITLE_Y);
+ print(params[0].name);
+
+ for(i = 0; params[i+1].name; i++) {
+ gotoxy(FIRST_X, FIRST_Y+i);
+ print(params[i+1].name);
+ gotoxy(VAL_X, FIRST_Y+i);
+ println(current_value(mode, i), 10, UNSIGNED);
+ }
+
+ return i-1;
+}
+
+
+void play_music(uint8_t mode)
+{
+ uint8_t i = 0;
+
+ while(music[i] != END) {
+ if(music[i] != SILENCE) {
+ update_value(mode, FREQUENCY, frequencies[music[i]]);
+ update_value(mode, PLAY, 1);
+ }
+ delay(500);
+ i++;
+ }
+}
+
+
+void show_register_channel(uint8_t mode) {
+
+ switch (mode) {
+ case 1:
+ gotoxy(0, 16);
+ print("NR10-14:");
+
+ gotoxy(1, 17); // Last line
+ printn(NR10(), 16, UNSIGNED); print(", ");
+ printn(NR11(), 16, UNSIGNED); print(", ");
+ printn(NR12(), 16, UNSIGNED); print(", ");
+ printn(NR13(), 16, UNSIGNED); print(", ");
+ printn(0x80 | NR14(), 16, UNSIGNED);
+
+ break;
+
+ case 2:
+ gotoxy(0, 16);
+ print("NR21-24:");
+
+ gotoxy(1, 17); // Last line
+ printn(NR21(), 16, UNSIGNED); print(", ");
+ printn(NR22(), 16, UNSIGNED); print(", ");
+ printn(NR23(), 16, UNSIGNED); print(", ");
+ printn(0x80 | NR24(), 16, UNSIGNED);
+
+ break;
+
+ case 3:
+ gotoxy(0, 16);
+ print("NR30-34:");
+
+ gotoxy(1, 17); // Last line
+ printn(NR30(), 16, UNSIGNED); print(", ");
+ printn(NR31(), 16, UNSIGNED); print(", ");
+ printn(NR32(), 16, UNSIGNED); print(", ");
+ printn(NR33(), 16, UNSIGNED); print(", ");
+ printn(0x80 | NR34(), 16, UNSIGNED);
+
+ break;
+
+ case 4:
+ gotoxy(0, 16);
+ print("NR41-44:");
+
+ gotoxy(1, 17); // Last line
+ printn(NR41(), 16, UNSIGNED); print(", ");
+ printn(NR42(), 16, UNSIGNED); print(", ");
+ printn(NR43(), 16, UNSIGNED); print(", ");
+ printn(0x80 | NR44(), 16, UNSIGNED);
+
+ break;
+
+ case 0:
+ gotoxy(0, 16);
+ print("NR50-52:");
+
+ gotoxy(1, 17); // Last line
+ printn(NR50(), 16, UNSIGNED); print(", ");
+ printn(NR51(), 16, UNSIGNED); print(", ");
+ printn(NR52(), 16, UNSIGNED); print(", ");
+
+ break;
+
+ }
+}
+
+
+void dump_registers()
+{
+ clss();
+ gotoxy(FIRST_X, TITLE_Y);
+ print("Register Dump\n\n");
+
+ print("NR10:");println(NR10(), 16, UNSIGNED);
+ print("NR11:");printn(NR11(), 16, UNSIGNED); print(" NR21:");println(NR21(), 16, UNSIGNED);
+ print("NR12:");printn(NR12(), 16, UNSIGNED); print(" NR22:");println(NR22(), 16, UNSIGNED);
+ print("NR13:");printn(NR13(), 16, UNSIGNED); print(" NR23:");println(NR23(), 16, UNSIGNED);
+ print("NR14:");printn(0x80 | NR14(), 16, UNSIGNED); print(" NR24:");println(0x80 | NR24(), 16, UNSIGNED);
+ printf("\n");
+
+ print("NR30:");println(NR30(), 16, UNSIGNED);
+ print("NR31:");printn(NR31(), 16, UNSIGNED); print(" NR41:");println(NR41(), 16, UNSIGNED);
+ print("NR32:");printn(NR32(), 16, UNSIGNED); print(" NR42:");println(NR42(), 16, UNSIGNED);
+ print("NR33:");printn(NR33(), 16, UNSIGNED); print(" NR43:");println(NR43(), 16, UNSIGNED);
+ print("NR34:");printn(0x80 | NR34(), 16, UNSIGNED); print(" NR44:");println(0x80 | NR44(), 16, UNSIGNED);
+ printf("\n");
+
+ print("NR50:");println(NR50(), 16, UNSIGNED);
+ print("NR51:");println(NR51(), 16, UNSIGNED);
+ print("NR52:");println(NR52(), 16, UNSIGNED);
+}
+
+void wait_event(uint8_t mode)
+{
+ uint8_t y, last_y;
+ uint16_t l = 0;
+ uint16_t m = 0;
+
+ while(1) {
+ params = params_array[mode];
+ last_y = draw_screen(mode) + FIRST_Y;
+ y = FIRST_Y;
+ gotoxy(ARROW_X, y);
+ setchar(ARROW_CHAR);
+
+ show_register_channel(mode);
+
+ while(1) {
+ if(KEY_TICKED(J_UP)) {
+ gotoxy(ARROW_X, y); setchar(SPACE_CHAR);
+ if(--y < FIRST_Y)
+ y = last_y;
+ gotoxy(ARROW_X, y); setchar(ARROW_CHAR);
+
+ } else if(KEY_TICKED(J_DOWN)) {
+ gotoxy(ARROW_X, y); setchar(SPACE_CHAR);
+ if(++y > last_y)
+ y = FIRST_Y;
+ gotoxy(ARROW_X, y); setchar(ARROW_CHAR);
+
+ } else if(KEY_TICKED(J_LEFT)) {
+ l = current_value(mode, y-FIRST_Y);
+ if(l != 0) {
+ if(KEY_PRESSED(J_A) && KEY_PRESSED(J_B))
+ l = 0;
+ else if(KEY_PRESSED(J_A))
+ l = (l > 10) ? (l - 10) : 0;
+ else if(KEY_PRESSED(J_B))
+ l = (l > 100) ? (l - 100) : 0;
+ else
+ l--;
+ update_value(mode, y-FIRST_Y, l);
+ }
+ gotoxy(VAL_X, y); print(" ");
+ gotoxy(VAL_X, y); println(l, 10, UNSIGNED);
+
+ show_register_channel(mode);
+
+ } else if(KEY_TICKED(J_RIGHT)) {
+ l = current_value(mode, y-FIRST_Y);
+ m = params[y-(FIRST_Y-1)].max;
+ if(l != m) {
+ if(KEY_PRESSED(J_A) && KEY_PRESSED(J_B)) {
+ l = m;
+ }
+ else if(KEY_PRESSED(J_A)) {
+ l += 10;
+ if(l > m)
+ l = m;
+ } else if(KEY_PRESSED(J_B)) {
+ l += 100;
+ if(l > m)
+ l = m;
+ }
+ else
+ l++;
+ update_value(mode, y-FIRST_Y, l);
+ }
+ gotoxy(VAL_X, y); print(" ");
+ gotoxy(VAL_X, y); println(l, 10, UNSIGNED);
+
+ show_register_channel(mode);
+
+ } else if(KEY_TICKED(J_START)) {
+ if (KEY_PRESSED(J_A))
+ play_music(mode);
+ else
+ update_value(mode, PLAY, 1);
+
+ } else if(KEY_PRESSED(J_SELECT)) {
+ if(KEY_PRESSED(J_A))
+ dump_registers();
+ else {
+ mode = (mode+1) % NB_MODES;
+ }
+ waitpadup();
+ keys = 0;
+ break;
+ }
+ wait_vbl_done();
+ UPDATE_KEYS();
+ }
+ }
+}
+
+void main()
+{
+ //
+ // Before modifying any sound register, sound must be turned on!
+ // (it is turned off by default to save batteries)
+ //
+ NR52_REG = 0x80;
+
+ soundReg = &s;
+ NR10_REG = NR10();
+ NR11_REG = NR11();
+ NR12_REG = NR12();
+ NR13_REG = NR13();
+ NR14_REG = NR14();
+
+ NR21_REG = NR21();
+ NR22_REG = NR22();
+ NR23_REG = NR23();
+ NR24_REG = NR24();
+
+ NR30_REG = NR30();
+ NR31_REG = NR31();
+ NR32_REG = NR32();
+ NR33_REG = NR33();
+ NR34_REG = NR34();
+
+ NR41_REG = NR41();
+ NR42_REG = NR42();
+ NR43_REG = NR43();
+ NR44_REG = NR44();
+
+ NR50_REG = NR50();
+ NR51_REG = NR51();
+ NR52_REG = NR52();
+
+ clss();
+
+ wait_event(1);
+}
+
diff --git a/gbdk/gbdk-lib/examples/gb/space/Makefile b/gbdk/gbdk-lib/examples/gb/space/Makefile
new file mode 100644
index 00000000..7fb43903
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/space/Makefile
@@ -0,0 +1,19 @@
+GBDK = ../../..
+LIB = $(GBDK)/lib/small/asxxxx/
+CC = $(GBDK)/bin/lcc -Wa-I$(LIB) -Wa-l -Wl-m -Wl-j
+
+BINS = space.gb
+
+all: $(BINS)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+# Compile and link single file in one pass
+%.gb: %.s
+ $(CC) -o $@ $<
+
+clean:
+ rm -f *.o *.lst *.map *.gb *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi
+
diff --git a/gbdk/gbdk-lib/examples/gb/space/space.s b/gbdk/gbdk-lib/examples/gb/space/space.s
new file mode 100644
index 00000000..02aab15c
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/space/space.s
@@ -0,0 +1,1296 @@
+ ;; Little demo illustrating how to use the graphical possibilities
+ ;; of the GB (background, window and animated sprite)
+ ;; I have used fixed-point values for both the position and
+ ;; speed of objects to get smooth movements
+ ;;
+ ;; OBJ data : 0x8000 -> 0x8FFF (unsigned)
+ ;; Window data : 0x8800 -> 0x97FF (signed)
+ ;; Background data : 0x8800 -> 0x97FF (signed)
+ ;;
+ ;; Tiled 0xFC -> 0xFF are standard tiles (all black -> all white)
+ ;;
+ ;; Keys:
+ ;; Arrow keys : Change the speed (and direction) of the sprite
+ ;; Arrow keys + A : Change the speed (and direction) of the window
+ ;; Arrow keys + B : Change the speed (and direction) of the background
+ ;; START : Open/close the door
+ ;; SELECT : Basic fading effect
+ ;;
+ ;; Note that the window is kept in the lower right part of the screen
+ ;; since it can't be made transparent
+
+ .include "global.s"
+
+ .globl .init_vram
+ .globl .copy_vram
+ .globl .init_wtt
+ .globl .init_btt
+ .globl .set_xy_wtt
+ .globl .mv_sprite
+ .globl .set_sprite_prop
+ .globl .set_sprite_tile
+ .globl .jpad
+
+ .NBDFRAMES = .endfilm-.film ; Nb frames for the door
+ .NBSFRAMES = 0x07 ; Nb frames for the sprite
+ .WINSZX = 0x80 ; Size of the picture in the window
+ .WINSZY = 0x50
+ .MINWINX = .MAXWNDPOSX-.WINSZX+1 ; Bounds of the window origin
+ .MINWINY = .MAXWNDPOSY-.WINSZY+1
+ .MAXWINX = .MAXWNDPOSX
+ .MAXWINY = .MAXWNDPOSY
+ .FADESTEP = 0x10 ; Nb steps for the fading effect
+ .STARTFADE = 0x06*.FADESTEP ; Initial value for the fading effect
+
+ .CLOSED = 0x00
+ .OPENING = 0x01
+ .OPENED = 0x02
+ .CLOSING = 0x03
+
+ .module Space
+
+ .area _DATA
+
+.time: ; Global "time" value (counter)
+ .ds 0x01
+
+.doorstate: ; State of the door (OPENED, CLOSED...)
+ .ds 0x01
+.doorpos: ; Current position in the door animation
+ .ds 0x01
+
+.color: ; Current color for fading effect
+ .ds 0x01
+
+.sframe: ; Current frame of the sprite
+ .ds 0x01
+
+.bposx: ; Background position (fixed point)
+ .ds 0x02
+.bposy:
+ .ds 0x02
+.bspx: ; Background speed (fixed point)
+ .ds 0x02
+.bspy:
+ .ds 0x02
+
+.wposx: ; Window position (fixed point)
+ .ds 0x02
+.wposy:
+ .ds 0x02
+.wspx: ; Window speed (fixed point)
+ .ds 0x02
+.wspy:
+ .ds 0x02
+
+.sposx: ; Sprite position (fixed point)
+ .ds 0x02
+.sposy:
+ .ds 0x02
+.sspx: ; Sprite speed (fixed point)
+ .ds 0x02
+.sspy:
+ .ds 0x02
+
+ .area _CODE
+
+_main::
+ DI ; Disable interrupts
+ ;; Turn the screen off
+ CALL .display_off
+
+ XOR A
+ LD (.time),A
+ LD (.color),A
+
+ LD A,#0b11100100
+ LDH (.BGP),A
+ LDH (.OBP0),A
+
+ ; Initialize tiles
+ LD HL,#0x8000
+ LD DE,#0x1000
+ LD B,#0x00
+ CALL .init_vram ; Init the tile set at 0x8000 with 0x00
+ LD B,#0xFF
+ CALL .init_btt ; Init the tiles tables with 0xFF
+ CALL .init_wtt
+
+ LD BC,#.tp0 ; Move tiles (standard tiles)
+ LD HL,#0x9000-(.endtp0-.tp0)
+ LD DE,#.endtp0-.tp0
+ CALL .copy_vram
+
+ LD BC,#.tp1 ; Move tiles (earth)
+ LD HL,#0x8000
+ LD DE,#.endtp1-.tp1
+ CALL .copy_vram
+
+ LD BC,#.tp2 ; Move tiles (door)
+ LD HL,#0x8800
+ LD DE,#.endtp2-.tp2
+ CALL .copy_vram
+
+ LD BC,#.tp3 ; Move tiles (background)
+ LD HL,#0x9000
+ LD DE,#.endtp3-.tp3
+ CALL .copy_vram
+
+ ;; Draw the background
+ LD BC,#.bkg_tiles
+ LD HL,#0x9800
+ LD DE,#0x0400 ; One whole GB Screen
+ CALL .copy_vram
+
+ ;; Draw the frame in the window
+ LD BC,#.frame_tiles
+ LD DE,#0x0000/8 ; Place image at (0x00,0x00)
+ LD HL,#0x8050/8 ; Image size is 0x80 x 0x50
+ CALL .set_xy_wtt
+
+ ;; Draw the door in the window
+ LD BC,#.door1_tiles
+ LD DE,#0x1010/8 ; Place image at (0x10,0x10)
+ LD HL,#0x6030/8 ; Image size is 0x60 x 0x30
+ CALL .set_xy_wtt
+ LD A,#.CLOSED
+ LD (.doorstate),A
+
+ ; Initialize background
+ XOR A
+ LD (.bposx),A
+ LDH (.SCX),A
+ LD (.bposx+1),A
+ LD (.bposy),A
+ LDH (.SCY),A
+ LD (.bposy+1),A
+ LD A,#-0x01
+ LD (.bspx),A
+ XOR A
+ LD (.bspx+1),A
+ XOR A
+ LD (.bspy),A
+ LD A,#0x80
+ LD (.bspy+1),A
+
+ ; Initialize window
+ LD A,#.MAXWNDPOSX
+ LD (.wposx),A
+ LDH (.WX),A
+ XOR A
+ LD (.wposx+1),A
+ LD A,#.MAXWNDPOSY
+ LD (.wposy),A
+ LDH (.WY),A
+ XOR A
+ LD (.wposy+1),A
+ LD A,#-0x01
+ LD (.wspx),A
+ LD A,#0x80
+ LD (.wspx+1),A
+ LD A,#-0x01
+ LD (.wspy),A
+ LD A,#0xC0
+ LD (.wspy+1),A
+
+ ; Initialize sprite
+ XOR A
+ LD (.sframe),A
+ LD C,#0x00 ; Sprite 0x00
+ LD D,#0x00 ; Default sprite properties
+ CALL .set_sprite_prop
+ LD C,#0x01 ; Sprite 0x01
+ LD D,#0x00 ; Default sprite properties
+ CALL .set_sprite_prop
+
+ LD A,#0x10
+ LD (.sposx),A
+ XOR A
+ LD (.sposx+1),A
+ LD A,#0x10
+ LD (.sposy),A
+ XOR A
+ LD (.sposy+1),A
+ XOR A
+ LD (.sspx),A
+ LD A,#0x40
+ LD (.sspx+1),A
+ XOR A
+ LD (.sspy),A
+ LD A,#0x40
+ LD (.sspy+1),A
+ CALL .tile_sprite ; Set sprite tiles
+ CALL .place_sprite ; Place sprites
+
+ LD A,#0b11100111 ; LCD = On
+ ; WindowBank = 0x9C00
+ ; Window = On
+ ; BG Chr = 0x8800
+ ; BG Bank = 0x9800
+ ; OBJ = 8x16
+ ; OBJ = On
+ ; BG = On
+ LDH (.LCDC),A
+ EI ; Enable interrupts
+1$:
+ LD A,(.time)
+ INC A
+ LD (.time),A
+
+ LD B,#0x04 ; Skip four VBLs (slow down animation)
+2$:
+ CALL .wait_vbl_done
+ DEC B
+ JR NZ,2$
+
+ CALL .fade
+ CALL .door
+ CALL .scroll
+ CALL .animate_sprite
+
+ CALL .jpad
+ LD D,A
+
+ AND #.B ; Is B pressed ?
+ JP NZ,10$
+
+ LD A,D
+ AND #.A ; Is A pressed ?
+ JP NZ,20$
+
+ LD A,D
+ AND #.SELECT ; Is SELECT pressed ?
+ JR Z,3$
+ LD A,#.STARTFADE
+ LD (.color),A
+3$:
+ LD A,D
+ AND #.START ; Is START pressed ?
+ JR Z,5$
+ LD A,(.doorstate)
+ CP #.CLOSED
+ JR NZ,4$
+ LD A,#.OPENING
+ LD (.doorstate),A
+ XOR A
+ LD (.doorpos),A
+ JR 5$
+4$:
+ CP #.OPENED
+ JR NZ,5$
+ LD A,#.CLOSING
+ LD (.doorstate),A
+ LD A,#.NBDFRAMES
+ LD (.doorpos),A
+5$:
+ LD A,D
+ AND #.UP ; Is UP pressed ?
+ JR Z,6$
+ LD BC,#0x0010
+ LD A,(.sspy) ; Load speed into HL
+ LD H,A
+ LD A,(.sspy+1)
+ LD L,A
+ LD A,L ; Substract BC from HL
+ SUB C
+ LD (.sspy+1),A
+ LD A,H
+ SBC B
+ LD (.sspy),A ; Store new speed
+ JR 7$
+6$:
+ LD A,D
+ AND #.DOWN ; Is DOWN pressed ?
+ JR Z,7$
+ LD BC,#0x0010
+ LD A,(.sspy) ; Load speed into HL
+ LD H,A
+ LD A,(.sspy+1)
+ LD L,A
+ ADD HL,BC ; Add them
+ LD A,H ; Store new speed
+ LD (.sspy),A
+ LD A,L
+ LD (.sspy+1),A
+7$:
+ LD A,D
+ AND #.LEFT ; Is LEFT pressed ?
+ JR Z,8$
+ LD BC,#0x0010
+ LD A,(.sspx) ; Load speed into HL
+ LD H,A
+ LD A,(.sspx+1)
+ LD L,A
+ LD A,L ; Substract BC from HL
+ SUB C
+ LD (.sspx+1),A
+ LD A,H
+ SBC B
+ LD (.sspx),A ; Store new speed
+ JP 1$
+8$:
+ LD A,D
+ AND #.RIGHT ; Is RIGHT pressed ?
+ JP Z,1$
+ LD BC,#0x0010
+ LD A,(.sspx) ; Load speed into HL
+ LD H,A
+ LD A,(.sspx+1)
+ LD L,A
+ ADD HL,BC ; Add them
+ LD A,H ; Store new speed
+ LD (.sspx),A
+ LD A,L
+ LD (.sspx+1),A
+ JP 1$
+
+10$:
+ LD A,D
+ AND #.UP ; Is UP pressed ?
+ JP Z,11$
+ LD BC,#0x0010
+ LD A,(.bspy) ; Load speed into HL
+ LD H,A
+ LD A,(.bspy+1)
+ LD L,A
+ LD A,L ; Substract BC from HL
+ SUB C
+ LD (.bspy+1),A
+ LD A,H
+ SBC B
+ LD (.bspy),A ; Store new speed
+ JR 12$
+11$:
+ LD A,D
+ AND #.DOWN ; Is DOWN pressed ?
+ JP Z,12$
+ LD BC,#0x0010
+ LD A,(.bspy) ; Load speed into HL
+ LD H,A
+ LD A,(.bspy+1)
+ LD L,A
+ ADD HL,BC ; Add them
+ LD A,H ; Store new speed
+ LD (.bspy),A
+ LD A,L
+ LD (.bspy+1),A
+12$:
+ LD A,D
+ AND #.LEFT ; Is LEFT pressed ?
+ JP Z,13$
+ LD BC,#0x0010
+ LD A,(.bspx) ; Load speed into HL
+ LD H,A
+ LD A,(.bspx+1)
+ LD L,A
+ LD A,L ; Substract BC from HL
+ SUB C
+ LD (.bspx+1),A
+ LD A,H
+ SBC B
+ LD (.bspx),A ; Store new speed
+ JP 1$
+13$:
+ LD A,D
+ AND #.RIGHT ; Is RIGHT pressed ?
+ JP Z,1$
+ LD BC,#0x0010
+ LD A,(.bspx) ; Load speed into HL
+ LD H,A
+ LD A,(.bspx+1)
+ LD L,A
+ ADD HL,BC ; Add them
+ LD A,H ; Store new speed
+ LD (.bspx),A
+ LD A,L
+ LD (.bspx+1),A
+ JP 1$
+
+20$:
+ LD A,D
+ AND #.UP ; Is UP pressed ?
+ JP Z,21$
+ LD BC,#0x0010
+ LD A,(.wspy) ; Load speed into HL
+ LD H,A
+ LD A,(.wspy+1)
+ LD L,A
+ LD A,L ; Substract BC from HL
+ SUB C
+ LD (.wspy+1),A
+ LD A,H
+ SBC B
+ LD (.wspy),A ; Store new speed
+ JR 22$
+21$:
+ LD A,D
+ AND #.DOWN ; Is DOWN pressed ?
+ JP Z,22$
+ LD BC,#0x0010
+ LD A,(.wspy) ; Load speed into HL
+ LD H,A
+ LD A,(.wspy+1)
+ LD L,A
+ ADD HL,BC ; Add them
+ LD A,H ; Store new speed
+ LD (.wspy),A
+ LD A,L
+ LD (.wspy+1),A
+22$:
+ LD A,D
+ AND #.LEFT ; Is LEFT pressed ?
+ JP Z,23$
+ LD BC,#0x0010
+ LD A,(.wspx) ; Load speed into HL
+ LD H,A
+ LD A,(.wspx+1)
+ LD L,A
+ LD A,L ; Substract BC from HL
+ SUB C
+ LD (.wspx+1),A
+ LD A,H
+ SBC B
+ LD (.wspx),A ; Store new speed
+ JP 1$
+23$:
+ LD A,D
+ AND #.RIGHT ; Is RIGHT pressed ?
+ JP Z,1$
+ LD BC,#0x0010
+ LD A,(.wspx) ; Load speed into HL
+ LD H,A
+ LD A,(.wspx+1)
+ LD L,A
+ ADD HL,BC ; Add them
+ LD A,H ; Store new speed
+ LD (.wspx),A
+ LD A,L
+ LD (.wspx+1),A
+ JP 1$
+
+ RET
+
+ ;; Fade the screen (off and on)
+.fade:
+
+ LD A,(.color) ; Load color into A
+ CP #0x00
+ RET Z
+ CP #.STARTFADE
+ JR NZ,1$
+ LD A,#0b11111001
+ JR 6$
+1$:
+ CP #.STARTFADE-.FADESTEP
+ JR NZ,2$
+ LD A,#0b11111110
+ JR 6$
+2$:
+ CP #.STARTFADE-0x02*.FADESTEP
+ JR NZ,3$
+ LD A,#0b11111111
+ JR 6$
+3$:
+ CP #.STARTFADE-0x03*.FADESTEP
+ JR NZ,4$
+ LD A,#0b11111110
+ JR 6$
+4$:
+ CP #.STARTFADE-0x04*.FADESTEP
+ JR NZ,5$
+ LD A,#0b11111001
+ JR 6$
+5$:
+ CP #.STARTFADE-0x05*.FADESTEP
+ JR NZ,7$
+ LD A,#0b11100100
+6$:
+ LDH (.BGP),A
+7$:
+ LD A,(.color)
+ DEC A
+ LD (.color),A
+ RET
+
+ ;; Scroll the background, the window and the sprite
+.scroll:
+
+ ;; Update background
+ LD A,(.bposx) ; Load background position into HL
+ LD H,A
+ LD A,(.bposx+1)
+ LD L,A
+ LD A,(.bspx) ; Load background speed into BC
+ LD B,A
+ LD A,(.bspx+1)
+ LD C,A
+ ADD HL,BC ; Add them
+ LD A,L ; Store new background position
+ LD (.bposx+1),A
+ LD A,H
+ LD (.bposx),A
+ LDH (.SCX),A ; Update position
+
+ LD A,(.bposy) ; Load background position into HL
+ LD H,A
+ LD A,(.bposy+1)
+ LD L,A
+ LD A,(.bspy) ; Load background speed into BC
+ LD B,A
+ LD A,(.bspy+1)
+ LD C,A
+ ADD HL,BC ; Add them
+ LD A,L ; Store new background position
+ LD (.bposy+1),A
+ LD A,H
+ LD (.bposy),A
+ LDH (.SCY),A ; Update position
+
+ ;; Update window
+ LD A,(.wspx) ; Load window speed into BC
+ LD B,A
+ LD A,(.wspx+1)
+ LD C,A
+ LD A,(.wposx) ; Load window position into HL
+ LD H,A
+ LD A,(.wposx+1)
+ LD L,A
+ ADD HL,BC ; Add them
+ LD A,L ; Store new window position
+ LD (.wposx+1),A
+ LD A,H
+ LD (.wposx),A
+
+ ;; X position
+ LD A,(.wposx) ; Check window position
+ LD H,#0x00 ; We must use 16 bit registers since the
+ LD L,A ; window is not less than 0x80 pixels
+ LD BC,#.MAXWINX
+ LD A,L ; Substract BC from HL
+ SUB C
+ LD A,H
+ SBC B
+ AND #0x80
+ JR NZ,1$ ; Maximum value ?
+ LD A,#.MAXWINX
+ LD (.wposx),A ; Correct window position
+ LD A,(.wspx+1) ; Load window speed into BC
+ LD C,A
+ LD A,(.wspx)
+ LD B,A
+ AND #0x80 ; Speed is already negative ?
+ JR NZ,3$
+ JR 2$
+1$:
+ LD A,(.wposx) ; Check window position
+ LD H,#0x00 ; We must use 16 bit registers since the
+ LD L,A ; window is not less than 0x80 pixels
+ LD BC,#.MINWINX+1
+ LD A,L ; Substract BC from HL
+ SUB C
+ LD A,H
+ SBC B
+ AND #0x80
+ JR Z,3$ ; Minimum value ?
+ LD A,#.MINWINX
+ LD (.wposx),A ; Correct window position
+ LD A,(.wspx+1) ; Load window speed into BC
+ LD C,A
+ LD A,(.wspx)
+ LD B,A
+ AND #0x80 ; Speed is already positive ?
+ JR Z,3$
+2$:
+ LD HL,#0x00 ; Invert speed
+ LD A,L ; Substract BC from HL
+ SUB C
+ LD (.wspx+1),A
+ LD A,H
+ SBC B
+ LD (.wspx),A ; Store new speed
+3$:
+ LD A,(.wposx)
+ LDH (.WX),A ; Update position
+
+ LD A,(.wspy) ; Load window speed into BC
+ LD B,A
+ LD A,(.wspy+1)
+ LD C,A
+ LD A,(.wposy) ; Load window position into HL
+ LD H,A
+ LD A,(.wposy+1)
+ LD L,A
+ ADD HL,BC ; Add them
+ LD A,L ; Store new window position
+ LD (.wposy+1),A
+ LD A,H
+ LD (.wposy),A
+
+ ;; Y position
+ LD A,(.wposy) ; Check window position
+ LD H,#0x00 ; We must use 16 bit registers since the
+ LD L,A ; window is not less than 0x80 pixels
+ LD BC,#.MAXWINY
+ LD A,L ; Substract BC from HL
+ SUB C
+ LD A,H
+ SBC B
+ AND #0x80
+ JR NZ,4$ ; Maximum value ?
+ LD A,#.MAXWINY
+ LD (.wposy),A ; Correct window position
+ LD A,(.wspy+1) ; Load window speed into BC
+ LD C,A
+ LD A,(.wspy)
+ LD B,A
+ AND #0x80 ; Speed is already negative ?
+ JR NZ,6$
+ JR 5$
+4$:
+ LD A,(.wposy) ; Check window position
+ LD H,#0x00 ; We must use 16 bit registers since the
+ LD L,A ; window is not less than 0x80 pixels
+ LD BC,#.MINWINY+1
+ LD A,L ; Substract BC from HL
+ SUB C
+ LD A,H
+ SBC B
+ AND #0x80
+ JR Z,6$ ; Minimum value ?
+ LD A,#.MINWINY
+ LD (.wposy),A ; Correct window position
+ LD A,(.wspy+1) ; Load window speed into BC
+ LD C,A
+ LD A,(.wspy)
+ LD B,A
+ AND #0x80 ; Speed is already positive ?
+ JR Z,6$
+5$:
+ LD HL,#0x00 ; Invert speed
+ LD A,L ; Substract BC from HL
+ SUB C
+ LD (.wspy+1),A
+ LD A,H
+ SBC B
+ LD (.wspy),A ; Store new speed
+6$:
+ LD A,(.wposy)
+ LDH (.WY),A ; Update position
+
+ ;; Update sprite
+ LD A,(.sposx) ; Load sprite position into HL
+ LD H,A
+ LD A,(.sposx+1)
+ LD L,A
+ LD A,(.sspx) ; Load sprite speed into BC
+ LD B,A
+ LD A,(.sspx+1)
+ LD C,A
+ ADD HL,BC ; Add them
+ LD A,L ; Store new sprite position
+ LD (.sposx+1),A
+ LD A,H
+ LD (.sposx),A
+
+ LD A,(.sposy) ; Load sprite position into HL
+ LD H,A
+ LD A,(.sposy+1)
+ LD L,A
+ LD A,(.sspy) ; Load sprite speed into BC
+ LD B,A
+ LD A,(.sspy+1)
+ LD C,A
+ ADD HL,BC ; Add them
+ LD A,L ; Store new sprite position
+ LD (.sposy+1),A
+ LD A,H
+ LD (.sposy),A
+ CALL .place_sprite ; Update position
+
+ RET
+
+ ;; Open and close the door
+.door:
+ LD A,(.doorstate)
+ CP #.OPENING
+ JP Z,.open_door
+ CP #.CLOSING
+ JP Z,.close_door
+ RET
+
+.open_door:
+ LD A,(.doorpos)
+ LD HL,#.film+0x02
+ LD B,#0x00
+ LD C,A
+ ADD HL,BC
+ LD C,(HL)
+ INC HL
+ LD B,(HL)
+ LD DE,#0x1010/8 ; Place image at (0x10,0x10)
+ LD HL,#0x6030/8 ; Image size is 0x60 x 0x30
+ CALL .set_xy_wtt
+
+ LD A,(.doorpos)
+ ADD A,#0x02
+ LD (.doorpos),A
+ CP #.NBDFRAMES
+ RET NZ
+ LD A,#.OPENED
+ LD (.doorstate),A
+ RET
+
+.close_door:
+ LD A,(.doorpos)
+ LD HL,#.film-0x02
+ LD B,#0x00
+ LD C,A
+ ADD HL,BC
+ LD C,(HL)
+ INC HL
+ LD B,(HL)
+ LD DE,#0x1010/8 ; Place image at (0x10,0x10)
+ LD HL,#0x6030/8 ; Image size is 0x60 x 0x30
+ CALL .set_xy_wtt
+
+ LD A,(.doorpos)
+ SUB A,#0x02
+ LD (.doorpos),A
+ RET NZ
+ LD A,#.CLOSED
+ LD (.doorstate),A
+ RET
+
+ ;; Animate sprite
+.animate_sprite:
+ LD A,(.time)
+ AND #0x07
+ RET NZ
+
+ LD A,(.sframe)
+ INC A
+ CP #.NBSFRAMES
+ JR NZ,1$
+ XOR A
+1$:
+ LD (.sframe),A
+
+ CALL .tile_sprite
+ RET
+
+ ;; Set sprite tiles
+.tile_sprite:
+ LD A,(.sframe)
+ LD HL,#.earth_tiles
+ RLCA
+ LD B,#0x00
+ LD C,A
+ ADD HL,BC
+ LD C,#0x00 ; Sprite 0x00
+ LD A,(HL+)
+ LD D,A
+ PUSH HL
+ CALL .set_sprite_tile
+ POP HL
+
+ LD C,#0x01 ; Sprite 0x01
+ LD A,(HL+)
+ LD D,A
+ CALL .set_sprite_tile
+
+ RET
+
+ ;; Place sprite
+.place_sprite:
+ LD C,#0x00 ; Sprite 0x00
+ LD A,(.sposx)
+ LD D,A
+ LD A,(.sposy)
+ LD E,A
+ PUSH DE ; Store position
+ CALL .mv_sprite
+
+ LD C,#0x01 ; Sprite 0x01
+ POP DE ; Restore position
+ LD A,#0x08
+ ADD A,D
+ LD D,A
+ CALL .mv_sprite
+
+ RET
+
+ .area _LIT
+
+.tp0:
+
+.std_data:
+
+ ; Basic tiles (0xFC to 0xFF)
+
+ .byte 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF
+ .byte 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00
+ .byte 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF
+ .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+
+.endtp0:
+
+.tp1:
+
+.earth_data:
+
+ ; Tile 0x00
+ .byte 0x07,0x07,0x18,0x1F,0x32,0x2D,0x71,0x4E,0x70,0x4F,0xF8,0x87,0xF8,0x87,0xF8,0x87
+ .byte 0xFC,0x83,0xFE,0x81,0x7F,0x40,0x7F,0x40,0x3F,0x20,0x1F,0x18,0x07,0x07,0x00,0x00
+ .byte 0xC0,0xC0,0xF0,0x30,0x78,0x88,0x3C,0xC4,0x5C,0xA4,0x9E,0x62,0x3E,0xC2,0x3E,0xC2
+ .byte 0x5E,0xA2,0x7E,0x82,0x0C,0xF4,0x0C,0xF4,0x98,0x68,0xB0,0x70,0xC0,0xC0,0x00,0x00
+ .byte 0x07,0x07,0x1F,0x18,0x2F,0x30,0x4F,0x70,0x6F,0x50,0x9F,0xE0,0x9F,0xE0,0xBF,0xC0
+ .byte 0xFF,0x80,0xB7,0xC8,0x63,0x5C,0x43,0x7C,0x3F,0x20,0x1F,0x18,0x07,0x07,0x00,0x00
+ .byte 0xC0,0xC0,0xB0,0x70,0x18,0xE8,0x0C,0xF4,0x0C,0xF4,0x82,0x7E,0x82,0x7E,0x86,0x7A
+ .byte 0xC6,0x3A,0xE6,0x1A,0xF4,0x0C,0xFC,0x04,0xF8,0x08,0xF0,0x30,0xC0,0xC0,0x00,0x00
+
+ ; Tile 0x08
+ .byte 0x07,0x07,0x1E,0x19,0x20,0x3F,0x40,0x7F,0x42,0x7D,0x81,0xFE,0x81,0xFE,0x83,0xFC
+ .byte 0xD7,0xA8,0xBB,0xC4,0x6E,0x51,0x7C,0x43,0x3F,0x20,0x1F,0x18,0x07,0x07,0x00,0x00
+ .byte 0xC0,0xC0,0x70,0xB0,0xE8,0x18,0xF4,0x0C,0xF4,0x0C,0xFE,0x02,0xFE,0x02,0xFE,0x02
+ .byte 0xFE,0x02,0x7E,0x82,0x3C,0xC4,0x3C,0xC4,0xF8,0x08,0xF0,0x30,0xC0,0xC0,0x00,0x00
+ .byte 0x07,0x07,0x1B,0x1C,0x20,0x3F,0x40,0x7F,0x40,0x7F,0xE0,0x9F,0x90,0xEF,0x89,0xF6
+ .byte 0x8D,0xF2,0x9F,0xE0,0x5E,0x61,0x6F,0x50,0x3F,0x20,0x1F,0x18,0x07,0x07,0x00,0x00
+ .byte 0xC0,0xC0,0xB0,0x70,0x28,0xD8,0x04,0xFC,0x2C,0xD4,0x1E,0xE2,0x1E,0xE2,0x3E,0xC2
+ .byte 0x7E,0x82,0xB6,0x4A,0xE4,0x1C,0xC4,0x3C,0xF8,0x08,0xF0,0x30,0xC0,0xC0,0x00,0x00
+
+ ; Tile 0x10
+ .byte 0x07,0x07,0x18,0x1F,0x20,0x3F,0x40,0x7F,0x40,0x7F,0xEE,0x91,0xF1,0x8E,0xE0,0x9F
+ .byte 0xE0,0x9F,0xF1,0x8E,0x71,0x4E,0x72,0x4D,0x3F,0x20,0x1F,0x18,0x07,0x07,0x00,0x00
+ .byte 0xC0,0xC0,0xF0,0x30,0x08,0xF8,0x04,0xFC,0x04,0xFC,0x02,0xFE,0x02,0xFE,0x92,0x6E
+ .byte 0xD6,0x2A,0xFE,0x02,0xEC,0x14,0xFC,0x04,0xF8,0x08,0xF0,0x30,0xC0,0xC0,0x00,0x00
+ .byte 0x07,0x07,0x1D,0x1A,0x36,0x29,0x5C,0x63,0x6C,0x53,0xCE,0xB1,0x9F,0xE0,0x9E,0xE1
+ .byte 0xAE,0xD1,0xBF,0xC0,0x47,0x78,0x47,0x78,0x2F,0x30,0x1F,0x18,0x07,0x07,0x00,0x00
+ .byte 0xC0,0xC0,0x70,0xB0,0x08,0xF8,0x04,0xFC,0x04,0xFC,0xE2,0x1E,0x32,0xCE,0x0E,0xF2
+ .byte 0x0E,0xF2,0x1E,0xE2,0x1C,0xE4,0x2C,0xD4,0xF8,0x08,0xF0,0x30,0xC0,0xC0,0x00,0x00
+
+ ; Tile 0x18
+ .byte 0x07,0x07,0x1E,0x19,0x33,0x2C,0x49,0x76,0x42,0x7D,0xC4,0xBB,0xC1,0xBE,0xC1,0xBE
+ .byte 0xE2,0x9D,0xF3,0x8C,0x78,0x47,0x78,0x47,0x3C,0x23,0x1C,0x1B,0x07,0x07,0x00,0x00
+ .byte 0xC0,0xC0,0x70,0xB0,0x68,0x98,0xC4,0x3C,0xC4,0x3C,0xEE,0x12,0xF2,0x0E,0xE2,0x1E
+ .byte 0xE2,0x1E,0xF2,0x0E,0x7C,0x84,0x7C,0x84,0xF8,0x08,0xF0,0x30,0xC0,0xC0,0x00,0x00
+
+.endtp1:
+
+.tp2:
+
+.frame_data:
+
+ ; Tile 0x00
+ .byte 0xFF,0x00,0x80,0x7F,0x80,0x7F,0x80,0x7F,0x80,0x7F,0x80,0x7F,0x80,0x7F,0x80,0x7F
+ .byte 0xFF,0x00,0x01,0xFE,0x03,0xFC,0x07,0xF8,0x0F,0xF0,0x1F,0xE0,0x3F,0xC0,0x7F,0x80
+ .byte 0xFF,0x00,0xFE,0x01,0xFC,0x03,0xF8,0x07,0xF0,0x0F,0xE0,0x1F,0xC0,0x3F,0x80,0x7F
+ .byte 0xFF,0x00,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF
+ .byte 0xFF,0x00,0xFF,0x01,0xFD,0x03,0xF9,0x07,0xF1,0x0F,0xE1,0x1F,0xC1,0x3F,0x81,0x7F
+ .byte 0x80,0x7F,0x81,0x7E,0x83,0x7C,0x87,0x78,0x8F,0x70,0x9F,0x60,0xBF,0x40,0xFF,0x00
+ .byte 0xFF,0x70,0xFF,0x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,0x17,0xF9,0x1F,0xFF,0x0E
+ .byte 0x80,0x7F,0x81,0x7E,0x83,0x7C,0x87,0x78,0x8F,0x70,0x9F,0x60,0xBF,0x40,0xFF,0x7F
+ .byte 0x01,0xFF,0x01,0xFF,0x01,0xFF,0x01,0xFF,0x01,0xFF,0x01,0xFF,0x01,0xFF,0xFF,0xFF
+
+.door1_data:
+
+ ; Tile 0x15
+ .byte 0xFF,0x00,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0xFF
+ .byte 0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0xFF,0x00,0xFF,0x00,0xFF
+ .byte 0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0xFF
+
+.door2_data:
+
+ ; Tile 0x18
+ .byte 0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0xFF,0x00,0xFF,0x00,0xFF
+ .byte 0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0xFF
+ .byte 0xFF,0x00,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0xFF
+ .byte 0xFF,0x00,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF
+
+.door3_data:
+
+ ; Tile 0x1C
+ .byte 0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0xFF
+ .byte 0xFF,0x00,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0xFF
+ .byte 0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0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F
+ .byte 0xFF,0xFF,0xFF,0xFF,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF
+
+.endtp3:
+
+ ; Image size: 0x40 x 0x40
+ ; Number of tiles (total - unique): 0x40 - 0x2D
+
+.bkg_tiles:
+
+ .byte 0x00,0x01,0x02,0x03,0xFC,0xFC,0x04,0xFC
+ .byte 0x00,0x01,0x02,0x03,0xFC,0xFC,0x04,0xFC
+ .byte 0x00,0x01,0x02,0x03,0xFC,0xFC,0x04,0xFC
+ .byte 0x00,0x01,0x02,0x03,0xFC,0xFC,0x04,0xFC
+
+ .byte 0xFC,0x05,0x06,0xFC,0x07,0x08,0x09,0x0A
+ .byte 0xFC,0x05,0x06,0xFC,0x07,0x08,0x09,0x0A
+ .byte 0xFC,0x05,0x06,0xFC,0x07,0x08,0x09,0x0A
+ .byte 0xFC,0x05,0x06,0xFC,0x07,0x08,0x09,0x0A
+
+ .byte 0xFC,0xFC,0xFC,0x02,0x0B,0x0C,0x0D,0xFC
+ .byte 0xFC,0xFC,0xFC,0x02,0x0B,0x0C,0x0D,0xFC
+ .byte 0xFC,0xFC,0xFC,0x02,0x0B,0x0C,0x0D,0xFC
+ .byte 0xFC,0xFC,0xFC,0x02,0x0B,0x0C,0x0D,0xFC
+
+ .byte 0x0E,0x0F,0x10,0xFC,0x11,0x12,0x13,0x14
+ .byte 0x0E,0x0F,0x10,0xFC,0x11,0x12,0x13,0x14
+ .byte 0x0E,0x0F,0x10,0xFC,0x11,0x12,0x13,0x14
+ .byte 0x0E,0x0F,0x10,0xFC,0x11,0x12,0x13,0x14
+
+ .byte 0x15,0x16,0x17,0xFC,0x18,0x19,0x1A,0xFC
+ .byte 0x15,0x16,0x17,0xFC,0x18,0x19,0x1A,0xFC
+ .byte 0x15,0x16,0x17,0xFC,0x18,0x19,0x1A,0xFC
+ .byte 0x15,0x16,0x17,0xFC,0x18,0x19,0x1A,0xFC
+
+ .byte 0x1B,0x1C,0x1D,0xFC,0xFC,0x1E,0x1F,0x20
+ .byte 0x1B,0x1C,0x1D,0xFC,0xFC,0x1E,0x1F,0x20
+ .byte 0x1B,0x1C,0x1D,0xFC,0xFC,0x1E,0x1F,0x20
+ .byte 0x1B,0x1C,0x1D,0xFC,0xFC,0x1E,0x1F,0x20
+
+ .byte 0x21,0x22,0xFC,0x23,0x24,0x25,0xFC,0x26
+ .byte 0x21,0x22,0xFC,0x23,0x24,0x25,0xFC,0x26
+ .byte 0x21,0x22,0xFC,0x23,0x24,0x25,0xFC,0x26
+ .byte 0x21,0x22,0xFC,0x23,0x24,0x25,0xFC,0x26
+
+ .byte 0x27,0x13,0x28,0x29,0x2A,0x2B,0x2C,0x11
+ .byte 0x27,0x13,0x28,0x29,0x2A,0x2B,0x2C,0x11
+ .byte 0x27,0x13,0x28,0x29,0x2A,0x2B,0x2C,0x11
+ .byte 0x27,0x13,0x28,0x29,0x2A,0x2B,0x2C,0x11
+
+ .byte 0x00,0x01,0x02,0x03,0xFC,0xFC,0x04,0xFC
+ .byte 0x00,0x01,0x02,0x03,0xFC,0xFC,0x04,0xFC
+ .byte 0x00,0x01,0x02,0x03,0xFC,0xFC,0x04,0xFC
+ .byte 0x00,0x01,0x02,0x03,0xFC,0xFC,0x04,0xFC
+
+ .byte 0xFC,0x05,0x06,0xFC,0x07,0x08,0x09,0x0A
+ .byte 0xFC,0x05,0x06,0xFC,0x07,0x08,0x09,0x0A
+ .byte 0xFC,0x05,0x06,0xFC,0x07,0x08,0x09,0x0A
+ .byte 0xFC,0x05,0x06,0xFC,0x07,0x08,0x09,0x0A
+
+ .byte 0xFC,0xFC,0xFC,0x02,0x0B,0x0C,0x0D,0xFC
+ .byte 0xFC,0xFC,0xFC,0x02,0x0B,0x0C,0x0D,0xFC
+ .byte 0xFC,0xFC,0xFC,0x02,0x0B,0x0C,0x0D,0xFC
+ .byte 0xFC,0xFC,0xFC,0x02,0x0B,0x0C,0x0D,0xFC
+
+ .byte 0x0E,0x0F,0x10,0xFC,0x11,0x12,0x13,0x14
+ .byte 0x0E,0x0F,0x10,0xFC,0x11,0x12,0x13,0x14
+ .byte 0x0E,0x0F,0x10,0xFC,0x11,0x12,0x13,0x14
+ .byte 0x0E,0x0F,0x10,0xFC,0x11,0x12,0x13,0x14
+
+ .byte 0x15,0x16,0x17,0xFC,0x18,0x19,0x1A,0xFC
+ .byte 0x15,0x16,0x17,0xFC,0x18,0x19,0x1A,0xFC
+ .byte 0x15,0x16,0x17,0xFC,0x18,0x19,0x1A,0xFC
+ .byte 0x15,0x16,0x17,0xFC,0x18,0x19,0x1A,0xFC
+
+ .byte 0x1B,0x1C,0x1D,0xFC,0xFC,0x1E,0x1F,0x20
+ .byte 0x1B,0x1C,0x1D,0xFC,0xFC,0x1E,0x1F,0x20
+ .byte 0x1B,0x1C,0x1D,0xFC,0xFC,0x1E,0x1F,0x20
+ .byte 0x1B,0x1C,0x1D,0xFC,0xFC,0x1E,0x1F,0x20
+
+ .byte 0x21,0x22,0xFC,0x23,0x24,0x25,0xFC,0x26
+ .byte 0x21,0x22,0xFC,0x23,0x24,0x25,0xFC,0x26
+ .byte 0x21,0x22,0xFC,0x23,0x24,0x25,0xFC,0x26
+ .byte 0x21,0x22,0xFC,0x23,0x24,0x25,0xFC,0x26
+
+ .byte 0x27,0x13,0x28,0x29,0x2A,0x2B,0x2C,0x11
+ .byte 0x27,0x13,0x28,0x29,0x2A,0x2B,0x2C,0x11
+ .byte 0x27,0x13,0x28,0x29,0x2A,0x2B,0x2C,0x11
+ .byte 0x27,0x13,0x28,0x29,0x2A,0x2B,0x2C,0x11
+
+ .byte 0x00,0x01,0x02,0x03,0xFC,0xFC,0x04,0xFC
+ .byte 0x00,0x01,0x02,0x03,0xFC,0xFC,0x04,0xFC
+ .byte 0x00,0x01,0x02,0x03,0xFC,0xFC,0x04,0xFC
+ .byte 0x00,0x01,0x02,0x03,0xFC,0xFC,0x04,0xFC
+
+ .byte 0xFC,0x05,0x06,0xFC,0x07,0x08,0x09,0x0A
+ .byte 0xFC,0x05,0x06,0xFC,0x07,0x08,0x09,0x0A
+ .byte 0xFC,0x05,0x06,0xFC,0x07,0x08,0x09,0x0A
+ .byte 0xFC,0x05,0x06,0xFC,0x07,0x08,0x09,0x0A
+
+ .byte 0xFC,0xFC,0xFC,0x02,0x0B,0x0C,0x0D,0xFC
+ .byte 0xFC,0xFC,0xFC,0x02,0x0B,0x0C,0x0D,0xFC
+ .byte 0xFC,0xFC,0xFC,0x02,0x0B,0x0C,0x0D,0xFC
+ .byte 0xFC,0xFC,0xFC,0x02,0x0B,0x0C,0x0D,0xFC
+
+ .byte 0x0E,0x0F,0x10,0xFC,0x11,0x12,0x13,0x14
+ .byte 0x0E,0x0F,0x10,0xFC,0x11,0x12,0x13,0x14
+ .byte 0x0E,0x0F,0x10,0xFC,0x11,0x12,0x13,0x14
+ .byte 0x0E,0x0F,0x10,0xFC,0x11,0x12,0x13,0x14
+
+ .byte 0x15,0x16,0x17,0xFC,0x18,0x19,0x1A,0xFC
+ .byte 0x15,0x16,0x17,0xFC,0x18,0x19,0x1A,0xFC
+ .byte 0x15,0x16,0x17,0xFC,0x18,0x19,0x1A,0xFC
+ .byte 0x15,0x16,0x17,0xFC,0x18,0x19,0x1A,0xFC
+
+ .byte 0x1B,0x1C,0x1D,0xFC,0xFC,0x1E,0x1F,0x20
+ .byte 0x1B,0x1C,0x1D,0xFC,0xFC,0x1E,0x1F,0x20
+ .byte 0x1B,0x1C,0x1D,0xFC,0xFC,0x1E,0x1F,0x20
+ .byte 0x1B,0x1C,0x1D,0xFC,0xFC,0x1E,0x1F,0x20
+
+ .byte 0x21,0x22,0xFC,0x23,0x24,0x25,0xFC,0x26
+ .byte 0x21,0x22,0xFC,0x23,0x24,0x25,0xFC,0x26
+ .byte 0x21,0x22,0xFC,0x23,0x24,0x25,0xFC,0x26
+ .byte 0x21,0x22,0xFC,0x23,0x24,0x25,0xFC,0x26
+
+ .byte 0x27,0x13,0x28,0x29,0x2A,0x2B,0x2C,0x11
+ .byte 0x27,0x13,0x28,0x29,0x2A,0x2B,0x2C,0x11
+ .byte 0x27,0x13,0x28,0x29,0x2A,0x2B,0x2C,0x11
+ .byte 0x27,0x13,0x28,0x29,0x2A,0x2B,0x2C,0x11
+
+ .byte 0x00,0x01,0x02,0x03,0xFC,0xFC,0x04,0xFC
+ .byte 0x00,0x01,0x02,0x03,0xFC,0xFC,0x04,0xFC
+ .byte 0x00,0x01,0x02,0x03,0xFC,0xFC,0x04,0xFC
+ .byte 0x00,0x01,0x02,0x03,0xFC,0xFC,0x04,0xFC
+
+ .byte 0xFC,0x05,0x06,0xFC,0x07,0x08,0x09,0x0A
+ .byte 0xFC,0x05,0x06,0xFC,0x07,0x08,0x09,0x0A
+ .byte 0xFC,0x05,0x06,0xFC,0x07,0x08,0x09,0x0A
+ .byte 0xFC,0x05,0x06,0xFC,0x07,0x08,0x09,0x0A
+
+ .byte 0xFC,0xFC,0xFC,0x02,0x0B,0x0C,0x0D,0xFC
+ .byte 0xFC,0xFC,0xFC,0x02,0x0B,0x0C,0x0D,0xFC
+ .byte 0xFC,0xFC,0xFC,0x02,0x0B,0x0C,0x0D,0xFC
+ .byte 0xFC,0xFC,0xFC,0x02,0x0B,0x0C,0x0D,0xFC
+
+ .byte 0x0E,0x0F,0x10,0xFC,0x11,0x12,0x13,0x14
+ .byte 0x0E,0x0F,0x10,0xFC,0x11,0x12,0x13,0x14
+ .byte 0x0E,0x0F,0x10,0xFC,0x11,0x12,0x13,0x14
+ .byte 0x0E,0x0F,0x10,0xFC,0x11,0x12,0x13,0x14
+
+ .byte 0x15,0x16,0x17,0xFC,0x18,0x19,0x1A,0xFC
+ .byte 0x15,0x16,0x17,0xFC,0x18,0x19,0x1A,0xFC
+ .byte 0x15,0x16,0x17,0xFC,0x18,0x19,0x1A,0xFC
+ .byte 0x15,0x16,0x17,0xFC,0x18,0x19,0x1A,0xFC
+
+ .byte 0x1B,0x1C,0x1D,0xFC,0xFC,0x1E,0x1F,0x20
+ .byte 0x1B,0x1C,0x1D,0xFC,0xFC,0x1E,0x1F,0x20
+ .byte 0x1B,0x1C,0x1D,0xFC,0xFC,0x1E,0x1F,0x20
+ .byte 0x1B,0x1C,0x1D,0xFC,0xFC,0x1E,0x1F,0x20
+
+ .byte 0x21,0x22,0xFC,0x23,0x24,0x25,0xFC,0x26
+ .byte 0x21,0x22,0xFC,0x23,0x24,0x25,0xFC,0x26
+ .byte 0x21,0x22,0xFC,0x23,0x24,0x25,0xFC,0x26
+ .byte 0x21,0x22,0xFC,0x23,0x24,0x25,0xFC,0x26
+
+ .byte 0x27,0x13,0x28,0x29,0x2A,0x2B,0x2C,0x11
+ .byte 0x27,0x13,0x28,0x29,0x2A,0x2B,0x2C,0x11
+ .byte 0x27,0x13,0x28,0x29,0x2A,0x2B,0x2C,0x11
+ .byte 0x27,0x13,0x28,0x29,0x2A,0x2B,0x2C,0x11
+
+ ; Image size: 0x10 x 0x70
+ ; Number of tiles (total - unique): 0x1C - 0x1C
+
+.earth_tiles:
+
+ .byte 0x00,0x02
+ .byte 0x04,0x06
+ .byte 0x08,0x0A
+ .byte 0x0C,0x0E
+ .byte 0x10,0x12
+ .byte 0x14,0x16
+ .byte 0x18,0x1A
+
+ ; Image size: 0x80 x 0x50
+ ; Number of tiles (total - unique): 0xA0 - 0x15
+
+.frame_tiles:
+
+ .byte 0x80,0x81,0xFD,0x82,0x83,0x81,0xFD,0x82,0x83,0x81,0xFD,0x82,0x83,0x81,0xFD,0x84
+ .byte 0x85,0x86,0x87,0x88,0x89,0x8A,0x87,0x88,0x89,0x8A,0x87,0x88,0x89,0x8A,0x8B,0x8C
+ .byte 0xFD,0x8D,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x8E,0x8F
+ .byte 0x82,0x8C,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x85,0x90
+ .byte 0x8E,0x8F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFD,0x8D
+ .byte 0x85,0x90,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x82,0x8C
+ .byte 0xFD,0x8D,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x8E,0x8F
+ .byte 0x82,0x8C,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x85,0x90
+ .byte 0x8E,0x91,0xFD,0x82,0x83,0x81,0xFD,0x82,0x83,0x81,0xFD,0x82,0x83,0x81,0x92,0x8D
+ .byte 0x93,0x8A,0x87,0x88,0x89,0x8A,0x87,0x88,0x89,0x8A,0x87,0x88,0x89,0x8A,0x87,0x94
+
+ ; Image size: 0x60 x 0x30
+ ; Number of tiles (total - unique): 0x48 - 0x03
+
+.door1_tiles:
+
+ .byte 0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95
+ .byte 0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96
+ .byte 0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97
+ .byte 0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95
+ .byte 0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96
+ .byte 0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97
+
+ .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC
+ .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC
+ .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC
+ .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC
+ .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC
+ .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC
+
+ ; Image size: 0x60 x 0x30
+ ; Number of tiles (total - unique): 0x48 - 0x04
+
+.door2_tiles:
+
+ .byte 0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98
+ .byte 0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99
+ .byte 0x9A,0x9A,0x9A,0x9A,0x9A,0x9A,0x9A,0x9A,0x9A,0x9A,0x9A,0x9A
+ .byte 0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x98
+ .byte 0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99
+ .byte 0x9B,0x9B,0x9B,0x9B,0x9B,0x9B,0x9B,0x9B,0x9B,0x9B,0x9B,0x9B
+
+ .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC
+ .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC
+ .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC
+ .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC
+ .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC
+
+ ; Image size: 0x60 x 0x30
+ ; Number of tiles (total - unique): 0x48 - 0x04
+
+.door3_tiles:
+
+ .byte 0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C
+ .byte 0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D
+ .byte 0x9E,0x9E,0x9E,0x9E,0x9E,0x9E,0x9E,0x9E,0x9E,0x9E,0x9E,0x9E
+ .byte 0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C,0x9C
+ .byte 0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D
+ .byte 0x9F,0x9F,0x9F,0x9F,0x9F,0x9F,0x9F,0x9F,0x9F,0x9F,0x9F,0x9F
+
+ .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC
+ .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC
+ .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC
+ .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC
+ .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC
+
+ ; Image size: 0x60 x 0x30
+ ; Number of tiles (total - unique): 0x48 - 0x01
+
+.door4_tiles:
+
+ .byte 0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95
+ .byte 0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96
+ .byte 0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97,0x97
+ .byte 0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95
+ .byte 0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96
+ .byte 0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0,0xA0
+
+ .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC
+ .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC
+ .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC
+ .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC
+ .byte 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC
+
+.film:
+ .word .door1_tiles+0x0C*0
+ .word .door2_tiles+0x0C*0
+ .word .door3_tiles+0x0C*0
+ .word .door4_tiles+0x0C*0
+ .word .door1_tiles+0x0C*1
+ .word .door2_tiles+0x0C*1
+ .word .door3_tiles+0x0C*1
+ .word .door4_tiles+0x0C*1
+ .word .door1_tiles+0x0C*2
+ .word .door2_tiles+0x0C*2
+ .word .door3_tiles+0x0C*2
+ .word .door4_tiles+0x0C*2
+ .word .door1_tiles+0x0C*3
+ .word .door2_tiles+0x0C*3
+ .word .door3_tiles+0x0C*3
+ .word .door4_tiles+0x0C*3
+ .word .door1_tiles+0x0C*4
+ .word .door2_tiles+0x0C*4
+ .word .door3_tiles+0x0C*4
+ .word .door4_tiles+0x0C*4
+ .word .door1_tiles+0x0C*5
+ .word .door2_tiles+0x0C*5
+ .word .door3_tiles+0x0C*5
+ .word .door4_tiles+0x0C*5
+.endfilm:
+ .word .door1_tiles+0x0C*6
diff --git a/gbdk/gbdk-lib/examples/gb/template_minimal/Makefile b/gbdk/gbdk-lib/examples/gb/template_minimal/Makefile
new file mode 100644
index 00000000..3395b5ed
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/template_minimal/Makefile
@@ -0,0 +1,33 @@
+#
+# Simple Makefile that compiles all .c and .s files in the same folder
+#
+
+# If you move this project you can change the directory
+# to match your GBDK root directory (ex: GBDK_HOME = "C:/GBDK/"
+GBDK_HOME = ../../../
+
+LCC = $(GBDK_HOME)bin/lcc
+
+# You can uncomment the line below to turn on debug output
+# LCC = $(LCC) -debug
+
+# You can set the name of the .gb ROM file here
+PROJECTNAME = Example
+
+BINS = $(PROJECTNAME).gb
+CSOURCES := $(wildcard *.c)
+ASMSOURCES := $(wildcard *.s)
+
+all: $(BINS)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+# Compile and link all source files in a single call to LCC
+$(BINS): $(CSOURCES) $(ASMSOURCES)
+ $(LCC) -o $@ $(CSOURCES) $(ASMSOURCES)
+
+clean:
+ rm -f *.o *.lst *.map *.gb *.ihx *.sym *.cdb *.adb *.asm
+
diff --git a/gbdk/gbdk-lib/examples/gb/template_minimal/Readme.md b/gbdk/gbdk-lib/examples/gb/template_minimal/Readme.md
new file mode 100644
index 00000000..c7ffc4c5
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/template_minimal/Readme.md
@@ -0,0 +1,7 @@
+
+An minimal template project with a Makefile that only compiles files in the same directory
+
+The Makefile will automatically detect and compile new source files as long
+as they are placed in the same directory as the Makefile
+
+
diff --git a/gbdk/gbdk-lib/examples/gb/template_minimal/main.c b/gbdk/gbdk-lib/examples/gb/template_minimal/main.c
new file mode 100644
index 00000000..a01e9dd0
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/template_minimal/main.c
@@ -0,0 +1,17 @@
+#include <gb/gb.h>
+#include <stdint.h>
+
+
+void main(void)
+{
+ // Loop forever
+ while(1) {
+
+
+ // Game main loop processing goes here
+
+
+ // Done processing, yield CPU and wait for start of next frame
+ wait_vbl_done();
+ }
+}
diff --git a/gbdk/gbdk-lib/examples/gb/template_subfolders/Makefile b/gbdk/gbdk-lib/examples/gb/template_subfolders/Makefile
new file mode 100644
index 00000000..06e6bcaa
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/template_subfolders/Makefile
@@ -0,0 +1,60 @@
+#
+# A Makefile that compiles all .c and .s files in "src" and "res"
+# subdirectories and places the output in a "obj" subdirectory
+#
+
+# If you move this project you can change the directory
+# to match your GBDK root directory (ex: GBDK_HOME = "C:/GBDK/"
+GBDK_HOME = ../../../
+
+LCC = $(GBDK_HOME)bin/lcc
+
+# You can set flags for LCC here
+# For example, you can uncomment the line below to turn on debug output
+# LCCFLAGS = -debug
+
+# You can set the name of the .gb ROM file here
+PROJECTNAME = Example
+
+SRCDIR = src
+OBJDIR = obj
+RESDIR = res
+BINS = $(OBJDIR)/$(PROJECTNAME).gb
+CSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.c))) $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.c)))
+ASMSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.s)))
+OBJS = $(CSOURCES:%.c=$(OBJDIR)/%.o) $(ASMSOURCES:%.s=$(OBJDIR)/%.o)
+
+all: prepare $(BINS)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+# Compile .c files in "src/" to .o object files
+$(OBJDIR)/%.o: $(SRCDIR)/%.c
+ $(LCC) $(LCCFLAGS) -c -o $@ $<
+
+# Compile .c files in "res/" to .o object files
+$(OBJDIR)/%.o: $(RESDIR)/%.c
+ $(LCC) $(LCCFLAGS) -c -o $@ $<
+
+# Compile .s assembly files in "src/" to .o object files
+$(OBJDIR)/%.o: $(SRCDIR)/%.s
+ $(LCC) $(LCCFLAGS) -c -o $@ $<
+
+# If needed, compile .c files i n"src/" to .s assembly files
+# (not required if .c is compiled directly to .o)
+$(OBJDIR)/%.s: $(SRCDIR)/%.c
+ $(LCC) $(LCCFLAGS) -S -o $@ $<
+
+# Link the compiled object files into a .gb ROM file
+$(BINS): $(OBJS)
+ $(LCC) $(LCCFLAGS) -o $(BINS) $(OBJS)
+
+prepare:
+ mkdir -p $(OBJDIR)
+
+clean:
+# rm -f *.gb *.ihx *.cdb *.adb *.noi *.map
+ rm -f $(OBJDIR)/*.*
+
diff --git a/gbdk/gbdk-lib/examples/gb/template_subfolders/Readme.md b/gbdk/gbdk-lib/examples/gb/template_subfolders/Readme.md
new file mode 100644
index 00000000..92830df2
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/template_subfolders/Readme.md
@@ -0,0 +1,18 @@
+
+A template project with a Makefile that supports sub-directories.
+
+The Makefile will automatically detect and compile new source files
+when they are added to the "src" and "res" directories.
+
+Project directories
+ - src: Main program source files (.c, .h, .s) can go here
+ - res: Program graphics and audio source files (.c, .h, .s) can go here
+ - obj: Compiled ROM (.gb) and debug files go in this directory
+
+
+== Sprite and Background tiles from: ==
+
+https://sondanielson.itch.io/gameboy-simple-rpg-tileset
+"Licence is under CCA so you can use these assets both privately and commercially"
+"You are free to use them as is or modify them to your liking. All i ask is you credit me if you do use them please :)"
+
diff --git a/gbdk/gbdk-lib/examples/gb/template_subfolders/res/dungeon_32x32.gbm b/gbdk/gbdk-lib/examples/gb/template_subfolders/res/dungeon_32x32.gbm
new file mode 100644
index 00000000..7418854b
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/template_subfolders/res/dungeon_32x32.gbm
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/gb/template_subfolders/res/dungeon_32x32.gbr b/gbdk/gbdk-lib/examples/gb/template_subfolders/res/dungeon_32x32.gbr
new file mode 100644
index 00000000..ba5ca530
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/template_subfolders/res/dungeon_32x32.gbr
Binary files differ
diff --git a/gbdk/gbdk-lib/examples/gb/template_subfolders/res/dungeon_map.c b/gbdk/gbdk-lib/examples/gb/template_subfolders/res/dungeon_map.c
new file mode 100644
index 00000000..072afdff
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/template_subfolders/res/dungeon_map.c
@@ -0,0 +1,133 @@
+/*
+
+ DUNGEON_MAP.C
+
+ Map Source File.
+
+ Info:
+ Section :
+ Bank : 0
+ Map size : 32 x 32
+ Tile set : dungeon_32x32.gbr
+ Plane count : 1 plane (8 bits)
+ Plane order : Planes are continues
+ Tile offset : 0
+ Split data : No
+
+ This file was generated by GBMB v1.8
+
+*/
+
+#define dungeon_mapWidth 32
+#define dungeon_mapHeight 32
+#define dungeon_mapBank 0
+
+#define dungeon_map dungeon_mapPLN0
+const unsigned char dungeon_mapPLN0[] =
+{
+ 0x0A,0x0B,0x07,0x05,0x06,0x04,0x07,0x03,0x04,0x07,
+ 0x03,0x04,0x07,0x08,0x09,0x01,0x0A,0x0B,0x07,0x07,
+ 0x03,0x04,0x07,0x03,0x04,0x07,0x03,0x04,0x03,0x0C,
+ 0x08,0x09,0x0D,0x0E,0x0F,0x12,0x13,0x11,0x0F,0x10,
+ 0x11,0x0F,0x10,0x11,0x0F,0x14,0x15,0x01,0x0D,0x0E,
+ 0x0F,0x0F,0x10,0x11,0x0F,0x10,0x11,0x0F,0x10,0x11,
+ 0x10,0x16,0x14,0x15,0x17,0x18,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x19,0x1A,0x01,
+ 0x1B,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x1D,0x1E,0x1F,0x1C,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x19,
+ 0x1A,0x01,0x1F,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x19,0x1A,0x1B,0x20,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x21,0x22,0x01,0x1F,0x1C,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x21,0x22,
+ 0x1F,0x1C,0x00,0x00,0x00,0x23,0x24,0x25,0x24,0x26,
+ 0x00,0x00,0x00,0x27,0x28,0x01,0x17,0x18,0x00,0x00,
+ 0x00,0x23,0x24,0x25,0x24,0x26,0x00,0x00,0x00,0x00,
+ 0x27,0x28,0x17,0x18,0x00,0x00,0x00,0x19,0x2B,0x2C,
+ 0x2D,0x20,0x00,0x00,0x00,0x19,0x1A,0x01,0x1F,0x1C,
+ 0x00,0x00,0x00,0x19,0x2B,0x2C,0x2D,0x20,0x00,0x00,
+ 0x00,0x00,0x19,0x1A,0x1F,0x1C,0x00,0x00,0x00,0x21,
+ 0x22,0x01,0x1F,0x1C,0x00,0x00,0x00,0x21,0x15,0x01,
+ 0x0D,0x1C,0x00,0x00,0x00,0x21,0x22,0x01,0x1F,0x1C,
+ 0x00,0x00,0x00,0x00,0x21,0x22,0x1B,0x20,0x00,0x00,
+ 0x00,0x27,0x28,0x01,0x17,0x18,0x00,0x00,0x00,0x30,
+ 0x31,0x32,0x33,0x20,0x00,0x00,0x00,0x21,0x22,0x01,
+ 0x1F,0x1C,0x00,0x00,0x00,0x00,0x19,0x1A,0x1F,0x1C,
+ 0x00,0x00,0x00,0x19,0x1A,0x01,0x1F,0x1C,0x00,0x00,
+ 0x00,0x34,0x35,0x0F,0x10,0x36,0x00,0x00,0x00,0x27,
+ 0x28,0x01,0x17,0x18,0x00,0x00,0x00,0x00,0x21,0x22,
+ 0x1F,0x1C,0x00,0x00,0x00,0x21,0x22,0x01,0x1B,0x20,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x19,0x1A,0x01,0x1F,0x1C,0x00,0x00,0x00,0x00,
+ 0x19,0x1A,0x1F,0x1C,0x00,0x00,0x00,0x19,0x1A,0x01,
+ 0x1F,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x21,0x22,0x01,0x1B,0x20,0x00,0x00,
+ 0x00,0x00,0x21,0x22,0x1B,0x20,0x00,0x00,0x00,0x21,
+ 0x22,0x01,0x1F,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x19,0x1A,0x01,0x1F,0x1C,
+ 0x00,0x00,0x00,0x00,0x27,0x28,0x1F,0x1C,0x00,0x00,
+ 0x00,0x19,0x1A,0x01,0x37,0x38,0x24,0x26,0x00,0x00,
+ 0x00,0x23,0x24,0x24,0x25,0x24,0x39,0x3A,0x3B,0x01,
+ 0x1F,0x1C,0x00,0x00,0x00,0x00,0x19,0x1A,0x1B,0x20,
+ 0x00,0x00,0x00,0x21,0x22,0x01,0x3C,0x3D,0x2D,0x20,
+ 0x00,0x00,0x00,0x19,0x2B,0x3E,0x3F,0x3E,0x40,0x41,
+ 0x42,0x01,0x1B,0x20,0x00,0x00,0x00,0x00,0x21,0x22,
+ 0x1F,0x1C,0x00,0x00,0x00,0x27,0x15,0x01,0x01,0x01,
+ 0x1F,0x1C,0x00,0x00,0x00,0x21,0x22,0x01,0x01,0x01,
+ 0x01,0x01,0x01,0x01,0x0D,0x20,0x00,0x00,0x00,0x00,
+ 0x19,0x1A,0x1F,0x1C,0x00,0x00,0x00,0x30,0x31,0x0B,
+ 0x03,0x07,0x33,0x20,0x00,0x00,0x00,0x30,0x31,0x08,
+ 0x09,0x01,0x0A,0x0B,0x07,0x0B,0x33,0x20,0x00,0x00,
+ 0x00,0x00,0x21,0x22,0x1F,0x1C,0x00,0x00,0x00,0x34,
+ 0x35,0x0F,0x10,0x0F,0x10,0x36,0x00,0x00,0x00,0x34,
+ 0x35,0x14,0x15,0x01,0x0D,0x0E,0x0F,0x0F,0x10,0x36,
+ 0x00,0x00,0x00,0x00,0x19,0x22,0x29,0x2A,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x19,0x1A,0x01,0x1F,0x1C,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x43,0x44,0x2E,0x2F,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x19,0x1A,0x01,0x1F,0x1C,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x45,0x46,
+ 0x1B,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x31,0x32,
+ 0x33,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x21,0x22,0x37,0x38,0x24,0x24,0x24,0x24,0x24,0x25,
+ 0x24,0x39,0x24,0x25,0x24,0x26,0x00,0x00,0x00,0x34,
+ 0x35,0x0F,0x10,0x36,0x00,0x00,0x00,0x23,0x24,0x24,
+ 0x24,0x24,0x3A,0x3B,0x3C,0x3D,0x3E,0x3E,0x3E,0x3E,
+ 0x3E,0x3F,0x3E,0x40,0x3E,0x2C,0x2D,0x20,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x19,
+ 0x2B,0x41,0x3E,0x3E,0x41,0x42,0x01,0x01,0x01,0x01,
+ 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x1F,0x1C,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x21,0x22,0x01,0x01,0x01,0x01,0x01,0x0A,0x0B,
+ 0x07,0x03,0x07,0x03,0x04,0x07,0x03,0x04,0x0B,0x0B,
+ 0x33,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x30,0x31,0x0B,0x07,0x03,0x08,0x09,
+ 0x0D,0x0E,0x0F,0x10,0x0F,0x10,0x11,0x0F,0x10,0x11,
+ 0x10,0x0F,0x10,0x36,0x00,0x00,0x00,0x23,0x24,0x25,
+ 0x24,0x26,0x00,0x00,0x00,0x34,0x35,0x10,0x0F,0x10,
+ 0x14,0x15,0x1F,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x19,
+ 0x2B,0x2C,0x2D,0x20,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x27,0x28,0x1F,0x1C,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x27,0x28,0x01,0x17,0x18,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x19,0x1A,0x1B,0x20,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x19,0x1A,0x01,0x1F,0x1C,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x21,0x22,0x47,0x48,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x21,0x22,0x01,0x1B,0x20,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x21,0x22,
+ 0x37,0x38,0x49,0x4A,0x4B,0x24,0x39,0x24,0x24,0x24,
+ 0x25,0x24,0x39,0x24,0x24,0x39,0x25,0x3A,0x3B,0x01,
+ 0x37,0x38,0x24,0x25,0x24,0x39,0x24,0x25,0x24,0x39,
+ 0x3A,0x3B,0x3C,0x3D,0x4C,0x4D,0x4E,0x3E,0x40,0x3E,
+ 0x3E,0x3E,0x3F,0x3E,0x40,0x3E,0x3E,0x40,0x3F,0x41,
+ 0x42,0x01,0x3C,0x3D,0x3E,0x3F,0x3E,0x40,0x3E,0x3F,
+ 0x3E,0x40,0x41,0x42
+};
+
+/* End of DUNGEON_MAP.C */
diff --git a/gbdk/gbdk-lib/examples/gb/template_subfolders/res/dungeon_map.h b/gbdk/gbdk-lib/examples/gb/template_subfolders/res/dungeon_map.h
new file mode 100644
index 00000000..da4d0998
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/template_subfolders/res/dungeon_map.h
@@ -0,0 +1,28 @@
+/*
+
+ DUNGEON_MAP.H
+
+ Map Include File.
+
+ Info:
+ Section :
+ Bank : 0
+ Map size : 32 x 32
+ Tile set : dungeon_32x32.gbr
+ Plane count : 1 plane (8 bits)
+ Plane order : Planes are continues
+ Tile offset : 0
+ Split data : No
+
+ This file was generated by GBMB v1.8
+
+*/
+
+#define dungeon_mapWidth 32
+#define dungeon_mapHeight 32
+#define dungeon_mapBank 0
+
+#define dungeon_map dungeon_mapPLN0
+extern const unsigned char dungeon_mapPLN0[];
+
+/* End of DUNGEON_MAP.H */
diff --git a/gbdk/gbdk-lib/examples/gb/template_subfolders/res/dungeon_tiles.c b/gbdk/gbdk-lib/examples/gb/template_subfolders/res/dungeon_tiles.c
new file mode 100644
index 00000000..9ddc4b84
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/template_subfolders/res/dungeon_tiles.c
@@ -0,0 +1,188 @@
+/*
+
+ DUNGEON_TILES.C
+
+ Tile Source File.
+
+ Info:
+ Form : All tiles as one unit.
+ Format : Gameboy 4 color.
+ Compression : None.
+ Counter : None.
+ Tile size : 8 x 8
+ Tiles : 0 to 78
+
+ Palette colors : Included.
+ SGB Palette : None.
+ CGB Palette : None.
+
+ Convert to metatiles : No.
+
+ This file was generated by GBTD v2.2
+
+*/
+
+/* Start of tile array. */
+const unsigned char dungeon_tiles[] =
+{
+ 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,
+ 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xFF,0xFF,0xFF,0xFF,0xF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FF,0x81,0x81,0x81,0xFF,0xFF,
+ 0xD7,0xB8,0x90,0x90,0x90,0x90,0xFF,0xFF,
+ 0xDF,0x7F,0xDF,0x7F,0x4F,0x7F,0xCF,0xFF,
+ 0x67,0xDF,0xF3,0x6F,0x78,0x37,0xFF,0xFF,
+ 0xFB,0xFE,0xFB,0xFE,0xF2,0xFE,0xF3,0xFF,
+ 0xE6,0xFB,0xCF,0xF6,0x1E,0xEC,0xFF,0xFF
+};
+
+/* End of DUNGEON_TILES.C */
diff --git a/gbdk/gbdk-lib/examples/gb/template_subfolders/res/dungeon_tiles.h b/gbdk/gbdk-lib/examples/gb/template_subfolders/res/dungeon_tiles.h
new file mode 100644
index 00000000..53001cf3
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/template_subfolders/res/dungeon_tiles.h
@@ -0,0 +1,103 @@
+/*
+
+ DUNGEON_TILES.H
+
+ Include File.
+
+ Info:
+ Form : All tiles as one unit.
+ Format : Gameboy 4 color.
+ Compression : None.
+ Counter : None.
+ Tile size : 8 x 8
+ Tiles : 0 to 78
+
+ Palette colors : Included.
+ SGB Palette : None.
+ CGB Palette : None.
+
+ Convert to metatiles : No.
+
+ This file was generated by GBTD v2.2
+
+*/
+
+
+/* Bank of tiles. */
+#define dungeon_tilesBank 0
+
+/* Super Gameboy palette 0 */
+#define dungeon_tilesSGBPal0c0 0
+#define dungeon_tilesSGBPal0c1 0
+#define dungeon_tilesSGBPal0c2 22528
+#define dungeon_tilesSGBPal0c3 44
+
+/* Super Gameboy palette 1 */
+#define dungeon_tilesSGBPal1c0 6076
+#define dungeon_tilesSGBPal1c1 8935
+#define dungeon_tilesSGBPal1c2 6596
+#define dungeon_tilesSGBPal1c3 5344
+
+/* Super Gameboy palette 2 */
+#define dungeon_tilesSGBPal2c0 6076
+#define dungeon_tilesSGBPal2c1 8935
+#define dungeon_tilesSGBPal2c2 6596
+#define dungeon_tilesSGBPal2c3 5344
+
+/* Super Gameboy palette 3 */
+#define dungeon_tilesSGBPal3c0 6076
+#define dungeon_tilesSGBPal3c1 8935
+#define dungeon_tilesSGBPal3c2 6596
+#define dungeon_tilesSGBPal3c3 5344
+
+/* Gameboy Color palette 0 */
+#define dungeon_tilesCGBPal0c0 26620
+#define dungeon_tilesCGBPal0c1 14096
+#define dungeon_tilesCGBPal0c2 10662
+#define dungeon_tilesCGBPal0c3 2112
+
+/* Gameboy Color palette 1 */
+#define dungeon_tilesCGBPal1c0 6076
+#define dungeon_tilesCGBPal1c1 8935
+#define dungeon_tilesCGBPal1c2 6596
+#define dungeon_tilesCGBPal1c3 5344
+
+/* Gameboy Color palette 2 */
+#define dungeon_tilesCGBPal2c0 6076
+#define dungeon_tilesCGBPal2c1 8935
+#define dungeon_tilesCGBPal2c2 6596
+#define dungeon_tilesCGBPal2c3 5344
+
+/* Gameboy Color palette 3 */
+#define dungeon_tilesCGBPal3c0 6076
+#define dungeon_tilesCGBPal3c1 8935
+#define dungeon_tilesCGBPal3c2 6596
+#define dungeon_tilesCGBPal3c3 5344
+
+/* Gameboy Color palette 4 */
+#define dungeon_tilesCGBPal4c0 6076
+#define dungeon_tilesCGBPal4c1 8935
+#define dungeon_tilesCGBPal4c2 6596
+#define dungeon_tilesCGBPal4c3 5344
+
+/* Gameboy Color palette 5 */
+#define dungeon_tilesCGBPal5c0 6076
+#define dungeon_tilesCGBPal5c1 8935
+#define dungeon_tilesCGBPal5c2 6596
+#define dungeon_tilesCGBPal5c3 5344
+
+/* Gameboy Color palette 6 */
+#define dungeon_tilesCGBPal6c0 6076
+#define dungeon_tilesCGBPal6c1 8935
+#define dungeon_tilesCGBPal6c2 6596
+#define dungeon_tilesCGBPal6c3 5344
+
+/* Gameboy Color palette 7 */
+#define dungeon_tilesCGBPal7c0 6076
+#define dungeon_tilesCGBPal7c1 8935
+#define dungeon_tilesCGBPal7c2 6596
+#define dungeon_tilesCGBPal7c3 5344
+/* Start of tile array. */
+extern const const unsigned char dungeon_tiles[];
+
+/* End of DUNGEON_TILES.H */
diff --git a/gbdk/gbdk-lib/examples/gb/template_subfolders/src/main.c b/gbdk/gbdk-lib/examples/gb/template_subfolders/src/main.c
new file mode 100644
index 00000000..abc06cf2
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gb/template_subfolders/src/main.c
@@ -0,0 +1,31 @@
+#include <gb/gb.h>
+#include <stdint.h>
+#include "../res/dungeon_map.h"
+#include "../res/dungeon_tiles.h"
+
+
+void init_gfx() {
+ // Load Background tiles and then map
+ set_bkg_data(0, 79u, dungeon_tiles);
+ set_bkg_tiles(0, 0, 32u, 32u, dungeon_mapPLN0);
+
+ // Turn the background map on to make it visible
+ SHOW_BKG;
+}
+
+
+void main(void)
+{
+ init_gfx();
+
+ // Loop forever
+ while(1) {
+
+
+ // Game main loop processing goes here
+
+
+ // Done processing, yield CPU and wait for start of next frame
+ wait_vbl_done();
+ }
+}
diff --git a/gbdk/gbdk-lib/examples/gg/Makefile b/gbdk/gbdk-lib/examples/gg/Makefile
new file mode 100644
index 00000000..f891d672
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gg/Makefile
@@ -0,0 +1,17 @@
+# Register all subdirectories in the project's root directory.
+SUBDIRS := $(wildcard */.)
+
+# Top-level phony targets.
+all clean compile.bat: $(SUBDIRS) FORCE
+# Similar to:
+# .PHONY: all clean
+# all clean: $(SUBDIRS)
+# GNU's .PHONY target is more efficient in that it explicitly declares non-files.
+
+# Recurse `make` into each subdirectory
+# Pass along targets specified at command-line (if any).
+$(SUBDIRS): FORCE
+ $(MAKE) -C $@ $(MAKECMDGOALS)
+
+# Force targets.
+FORCE: \ No newline at end of file
diff --git a/gbdk/gbdk-lib/examples/gg/smoke/Makefile b/gbdk/gbdk-lib/examples/gg/smoke/Makefile
new file mode 100644
index 00000000..76d8d2f3
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gg/smoke/Makefile
@@ -0,0 +1,30 @@
+CC = ../../../bin/lcc -mz80:gg -Wm-yoA -Wl-m -Wl-j
+
+BINS = smoketest.gg
+
+all: $(BINS)
+
+ASRC = $(wildcard *.s)
+CSRC = $(wildcard *.c)
+
+OBJS = $(CSRC:%.c=%.o) $(ASRC:%.s=%.o)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+# Compile and link single file in one pass
+
+%.o: %.c
+ $(CC) -c -o $@ $<
+
+%.o: %.s
+ $(CC) -c -o $@ $<
+
+$(BINS): $(OBJS)
+ $(CC) -Wm-yS -o $@ $^
+ rm -f *.map *.noi *.ihx *.lst
+
+clean:
+ rm -f *.o *.lst *.map *.gg *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi
+
diff --git a/gbdk/gbdk-lib/examples/gg/smoke/assets.c b/gbdk/gbdk-lib/examples/gg/smoke/assets.c
new file mode 100644
index 00000000..420dfca9
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gg/smoke/assets.c
@@ -0,0 +1,46 @@
+#pragma bank 2
+
+#include <sms/sms.h>
+
+BANKREF(earth_data)
+const unsigned char earth_data[] = {
+
+ /* Tile 0x00 */
+ 0x07,0x07,0x18,0x1F,0x32,0x2D,0x71,0x4E,0x70,0x4F,0xF8,0x87,0xF8,0x87,0xF8,0x87,
+ 0xFC,0x83,0xFE,0x81,0x7F,0x40,0x7F,0x40,0x3F,0x20,0x1F,0x18,0x07,0x07,0x00,0x00,
+ 0xC0,0xC0,0xF0,0x30,0x78,0x88,0x3C,0xC4,0x5C,0xA4,0x9E,0x62,0x3E,0xC2,0x3E,0xC2,
+ 0x5E,0xA2,0x7E,0x82,0x0C,0xF4,0x0C,0xF4,0x98,0x68,0xB0,0x70,0xC0,0xC0,0x00,0x00,
+ 0x07,0x07,0x1F,0x18,0x2F,0x30,0x4F,0x70,0x6F,0x50,0x9F,0xE0,0x9F,0xE0,0xBF,0xC0,
+ 0xFF,0x80,0xB7,0xC8,0x63,0x5C,0x43,0x7C,0x3F,0x20,0x1F,0x18,0x07,0x07,0x00,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FE,0x02,0xFE,0x92,0x6E,
+ 0xD6,0x2A,0xFE,0x02,0xEC,0x14,0xFC,0x04,0xF8,0x08,0xF0,0x30,0xC0,0xC0,0x00,0x00,
+ 0x07,0x07,0x1D,0x1A,0x36,0x29,0x5C,0x63,0x6C,0x53,0xCE,0xB1,0x9F,0xE0,0x9E,0xE1,
+ 0xAE,0xD1,0xBF,0xC0,0x47,0x78,0x47,0x78,0x2F,0x30,0x1F,0x18,0x07,0x07,0x00,0x00,
+ 0xC0,0xC0,0x70,0xB0,0x08,0xF8,0x04,0xFC,0x04,0xFC,0xE2,0x1E,0x32,0xCE,0x0E,0xF2,
+ 0x0E,0xF2,0x1E,0xE2,0x1C,0xE4,0x2C,0xD4,0xF8,0x08,0xF0,0x30,0xC0,0xC0,0x00,0x00,
+
+ /* Tile 0x18 */
+ 0x07,0x07,0x1E,0x19,0x33,0x2C,0x49,0x76,0x42,0x7D,0xC4,0xBB,0xC1,0xBE,0xC1,0xBE,
+ 0xE2,0x9D,0xF3,0x8C,0x78,0x47,0x78,0x47,0x3C,0x23,0x1C,0x1B,0x07,0x07,0x00,0x00,
+ 0xC0,0xC0,0x70,0xB0,0x68,0x98,0xC4,0x3C,0xC4,0x3C,0xEE,0x12,0xF2,0x0E,0xE2,0x1E,
+ 0xE2,0x1E,0xF2,0x0E,0x7C,0x84,0x7C,0x84,0xF8,0x08,0xF0,0x30,0xC0,0xC0,0x00,0x00
+};
+
+BANKREF(earth_data_size)
+const unsigned int earth_data_size = sizeof(earth_data);
diff --git a/gbdk/gbdk-lib/examples/gg/smoke/banked.c b/gbdk/gbdk-lib/examples/gg/smoke/banked.c
new file mode 100644
index 00000000..a18c3464
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gg/smoke/banked.c
@@ -0,0 +1,7 @@
+#pragma bank 3
+
+#include <stdint.h>
+
+uint16_t banked_func(uint8_t be, uint8_t ef) __banked {
+ return ((be << 8) | ef);
+} \ No newline at end of file
diff --git a/gbdk/gbdk-lib/examples/gg/smoke/smoketest.c b/gbdk/gbdk-lib/examples/gg/smoke/smoketest.c
new file mode 100644
index 00000000..346435ef
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/gg/smoke/smoketest.c
@@ -0,0 +1,90 @@
+#include <sms/sms.h>
+
+BANKREF_EXTERN(earth_data)
+extern const unsigned char earth_data[];
+
+BANKREF_EXTERN(earth_data_size)
+extern const unsigned int earth_data_size;
+
+const uint8_t tilemap[] = {2, 4, 6, 8, 3, 5, 7, 9};
+const uint16_t tilemapw[] = {2, 4, 6, 8, 3, 5, 7, 9};
+
+uint16_t banked_func(uint8_t be, uint8_t ef) __banked;
+
+int16_t x = 8 << 4, y = 0;
+int8_t xspd = 0, yspd = 0;
+
+uint8_t anim = 0, tick = 0;
+
+joypads_t joy;
+void main() {
+ HIDE_LEFT_COLUMN;
+ SPRITES_8x16;
+ DISPLAY_ON;
+
+// vmemcpy(0x4000, earth_data, sizeof(earth_data));
+
+ SWITCH_ROM(BANK(earth_data));
+ if (banked_func(0xBE, 0xEF) == 0xBEEF) {
+ set_bkg_data(2, earth_data_size >> 4, earth_data);
+ set_sprite_data(0, earth_data_size >> 4, earth_data);
+ set_sprite_tile(0, 0);
+ set_sprite_tile(1, 2);
+ }
+
+ set_bkg_tiles(4, 10, 4, 2, tilemap);
+
+ set_tile_map(4, 16, 4, 2, tilemapw);
+
+ joypad_init(2, &joy);
+
+ while(TRUE) {
+ joypad_ex(&joy);
+
+ if (joy.joy0 & J_LEFT) {
+ if (xspd > -32) xspd -= 2;
+ } else if (joy.joy0 & J_RIGHT) {
+ if (xspd < 32) xspd += 2;
+ } else {
+ if (xspd < 0) xspd++; else if (xspd > 0) xspd--;
+ }
+
+ if (joy.joy0 & J_UP) {
+ if (yspd > -32) yspd -= 2;
+ } else if (joy.joy0 & J_DOWN) {
+ if (yspd < 32) yspd += 2;
+ } else {
+ if (yspd < 0) yspd++; else if (yspd > 0) yspd--;
+ }
+
+ x += xspd;
+ if (x < (8 << 4)) x = 8 << 4; else if (x > (30 * 8) << 4) x = (30 * 8) << 4;
+
+
+ y += yspd;
+ if (y < 0) y = 0; else if (y > (22 * 8) << 4) y = (22 * 8) << 4;
+
+ tick++; tick &= 7;
+ if (!tick) {
+ anim++; if (anim == 7) anim = 0;
+ set_sprite_tile(0, anim << 2);
+ set_sprite_tile(1, (anim << 2) + 2);
+ }
+
+ move_sprite(0, x >> 4, y >> 4);
+ move_sprite(1, (x >> 4) + 8, y >> 4);
+
+ if (joy.joy1 & J_LEFT) {
+ scroll_bkg(-1, 0);
+ } else if (joy.joy1 & J_RIGHT) {
+ scroll_bkg(1, 0);
+ }
+ if (joy.joy1 & J_UP) {
+ scroll_bkg(0, -1);
+ } else if (joy.joy1 & J_DOWN) {
+ scroll_bkg(0, 1);
+ }
+
+ wait_vbl_done();
+ }
+}
diff --git a/gbdk/gbdk-lib/examples/msxdos/Makefile b/gbdk/gbdk-lib/examples/msxdos/Makefile
new file mode 100644
index 00000000..f891d672
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/msxdos/Makefile
@@ -0,0 +1,17 @@
+# Register all subdirectories in the project's root directory.
+SUBDIRS := $(wildcard */.)
+
+# Top-level phony targets.
+all clean compile.bat: $(SUBDIRS) FORCE
+# Similar to:
+# .PHONY: all clean
+# all clean: $(SUBDIRS)
+# GNU's .PHONY target is more efficient in that it explicitly declares non-files.
+
+# Recurse `make` into each subdirectory
+# Pass along targets specified at command-line (if any).
+$(SUBDIRS): FORCE
+ $(MAKE) -C $@ $(MAKECMDGOALS)
+
+# Force targets.
+FORCE: \ No newline at end of file
diff --git a/gbdk/gbdk-lib/examples/msxdos/hello/Makefile b/gbdk/gbdk-lib/examples/msxdos/hello/Makefile
new file mode 100644
index 00000000..f1651a90
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/msxdos/hello/Makefile
@@ -0,0 +1,30 @@
+CC = ../../../bin/lcc -v -mz80:msxdos -Wm-yoA -Wl-j
+
+BINS = test.com
+
+all: $(BINS)
+
+ASRC = $(wildcard *.s)
+CSRC = $(wildcard *.c)
+
+OBJS = $(CSRC:%.c=%.o) $(ASRC:%.s=%.o)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+# Compile and link single file in one pass
+
+%.o: %.c
+ $(CC) -c -o $@ $<
+
+%.o: %.s
+ $(CC) -c -o $@ $<
+
+$(BINS): $(OBJS)
+ $(CC) -Wm-yS -o $@ $^
+ rm -f *.map *.noi *.ihx *.lst
+
+clean:
+ rm -f *.o *.lst *.map *.com *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi
+
diff --git a/gbdk/gbdk-lib/examples/msxdos/hello/test.c b/gbdk/gbdk-lib/examples/msxdos/hello/test.c
new file mode 100644
index 00000000..57ab4add
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/msxdos/hello/test.c
@@ -0,0 +1,13 @@
+#include <gbdk/platform.h>
+#include <stdio.h>
+#include <stdint.h>
+
+int a = 100, b = 200;
+void main(int argc, char * argv[]) {
+ printf("Hello, world!\r\nargc: %d\r\n", argc);
+
+ for (int i = 0; i != argc; i++)
+ printf("argv%d = '%s'\r\n", i, argv[i]);
+
+ printf("a = %d b = %d\r\n&a == 0x%x", a, b, &a);
+}
diff --git a/gbdk/gbdk-lib/examples/msxdos/smoke/Makefile b/gbdk/gbdk-lib/examples/msxdos/smoke/Makefile
new file mode 100644
index 00000000..384b69ff
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/msxdos/smoke/Makefile
@@ -0,0 +1,30 @@
+CC = ../../../bin/lcc -mz80:msxdos -Wm-yoA -Wl-j
+
+BINS = smoketest.com
+
+all: $(BINS)
+
+ASRC = $(wildcard *.s)
+CSRC = $(wildcard *.c)
+
+OBJS = $(CSRC:%.c=%.o) $(ASRC:%.s=%.o)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+# Compile and link single file in one pass
+
+%.o: %.c
+ $(CC) -c -o $@ $<
+
+%.o: %.s
+ $(CC) -c -o $@ $<
+
+$(BINS): $(OBJS)
+ $(CC) -Wm-yS -o $@ $^
+ rm -f *.map *.noi *.ihx *.lst
+
+clean:
+ rm -f *.o *.lst *.map *.com *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi
+
diff --git a/gbdk/gbdk-lib/examples/msxdos/smoke/assets.c b/gbdk/gbdk-lib/examples/msxdos/smoke/assets.c
new file mode 100644
index 00000000..420dfca9
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/msxdos/smoke/assets.c
@@ -0,0 +1,46 @@
+#pragma bank 2
+
+#include <sms/sms.h>
+
+BANKREF(earth_data)
+const unsigned char earth_data[] = {
+
+ /* Tile 0x00 */
+ 0x07,0x07,0x18,0x1F,0x32,0x2D,0x71,0x4E,0x70,0x4F,0xF8,0x87,0xF8,0x87,0xF8,0x87,
+ 0xFC,0x83,0xFE,0x81,0x7F,0x40,0x7F,0x40,0x3F,0x20,0x1F,0x18,0x07,0x07,0x00,0x00,
+ 0xC0,0xC0,0xF0,0x30,0x78,0x88,0x3C,0xC4,0x5C,0xA4,0x9E,0x62,0x3E,0xC2,0x3E,0xC2,
+ 0x5E,0xA2,0x7E,0x82,0x0C,0xF4,0x0C,0xF4,0x98,0x68,0xB0,0x70,0xC0,0xC0,0x00,0x00,
+ 0x07,0x07,0x1F,0x18,0x2F,0x30,0x4F,0x70,0x6F,0x50,0x9F,0xE0,0x9F,0xE0,0xBF,0xC0,
+ 0xFF,0x80,0xB7,0xC8,0x63,0x5C,0x43,0x7C,0x3F,0x20,0x1F,0x18,0x07,0x07,0x00,0x00,
+ 0xC0,0xC0,0xB0,0x70,0x18,0xE8,0x0C,0xF4,0x0C,0xF4,0x82,0x7E,0x82,0x7E,0x86,0x7A,
+ 0xC6,0x3A,0xE6,0x1A,0xF4,0x0C,0xFC,0x04,0xF8,0x08,0xF0,0x30,0xC0,0xC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xB1,0x9F,0xE0,0x9E,0xE1,
+ 0xAE,0xD1,0xBF,0xC0,0x47,0x78,0x47,0x78,0x2F,0x30,0x1F,0x18,0x07,0x07,0x00,0x00,
+ 0xC0,0xC0,0x70,0xB0,0x08,0xF8,0x04,0xFC,0x04,0xFC,0xE2,0x1E,0x32,0xCE,0x0E,0xF2,
+ 0x0E,0xF2,0x1E,0xE2,0x1C,0xE4,0x2C,0xD4,0xF8,0x08,0xF0,0x30,0xC0,0xC0,0x00,0x00,
+
+ /* Tile 0x18 */
+ 0x07,0x07,0x1E,0x19,0x33,0x2C,0x49,0x76,0x42,0x7D,0xC4,0xBB,0xC1,0xBE,0xC1,0xBE,
+ 0xE2,0x9D,0xF3,0x8C,0x78,0x47,0x78,0x47,0x3C,0x23,0x1C,0x1B,0x07,0x07,0x00,0x00,
+ 0xC0,0xC0,0x70,0xB0,0x68,0x98,0xC4,0x3C,0xC4,0x3C,0xEE,0x12,0xF2,0x0E,0xE2,0x1E,
+ 0xE2,0x1E,0xF2,0x0E,0x7C,0x84,0x7C,0x84,0xF8,0x08,0xF0,0x30,0xC0,0xC0,0x00,0x00
+};
+
+BANKREF(earth_data_size)
+const unsigned int earth_data_size = sizeof(earth_data);
diff --git a/gbdk/gbdk-lib/examples/msxdos/smoke/banked.c b/gbdk/gbdk-lib/examples/msxdos/smoke/banked.c
new file mode 100644
index 00000000..a18c3464
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/msxdos/smoke/banked.c
@@ -0,0 +1,7 @@
+#pragma bank 3
+
+#include <stdint.h>
+
+uint16_t banked_func(uint8_t be, uint8_t ef) __banked {
+ return ((be << 8) | ef);
+} \ No newline at end of file
diff --git a/gbdk/gbdk-lib/examples/msxdos/smoke/ram_bank0.s b/gbdk/gbdk-lib/examples/msxdos/smoke/ram_bank0.s
new file mode 100644
index 00000000..a8a07a0f
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/msxdos/smoke/ram_bank0.s
@@ -0,0 +1,6 @@
+ .area _DATA_0
+
+_array0::
+ .ds 0x10
+_array1::
+ .ds 0x10 \ No newline at end of file
diff --git a/gbdk/gbdk-lib/examples/msxdos/smoke/ram_bank1.s b/gbdk/gbdk-lib/examples/msxdos/smoke/ram_bank1.s
new file mode 100644
index 00000000..06c89c44
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/msxdos/smoke/ram_bank1.s
@@ -0,0 +1,6 @@
+ .area _DATA_1
+
+_array2::
+ .ds 0x04
+_array3::
+ .ds 0x06 \ No newline at end of file
diff --git a/gbdk/gbdk-lib/examples/msxdos/smoke/smoketest.c b/gbdk/gbdk-lib/examples/msxdos/smoke/smoketest.c
new file mode 100644
index 00000000..f84d0410
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/msxdos/smoke/smoketest.c
@@ -0,0 +1,90 @@
+#include <gbdk/platform.h>
+
+BANKREF_EXTERN(earth_data)
+extern const unsigned char earth_data[];
+
+BANKREF_EXTERN(earth_data_size)
+extern const unsigned int earth_data_size;
+
+const uint8_t tilemap[] = {2, 4, 6, 8, 3, 5, 7, 9};
+const uint16_t tilemapw[] = {2, 4, 6, 8, 3, 5, 7, 9};
+
+uint16_t banked_func(uint8_t be, uint8_t ef) __banked;
+
+int16_t x = 8 << 4, y = 0;
+int8_t xspd = 0, yspd = 0;
+
+uint8_t anim = 0, tick = 0;
+
+joypads_t joy;
+void main() {
+ HIDE_LEFT_COLUMN;
+ SPRITES_8x16;
+ DISPLAY_ON;
+
+// vmemcpy(0x4000, earth_data, sizeof(earth_data));
+
+ SWITCH_ROM(BANK(earth_data));
+ if (banked_func(0xBE, 0xEF) == 0xBEEF) {
+ set_bkg_data(2, earth_data_size >> 4, earth_data);
+ set_sprite_data(0, earth_data_size >> 4, earth_data);
+ set_sprite_tile(0, 0);
+ set_sprite_tile(1, 2);
+ }
+
+ set_bkg_tiles(4, 10, 4, 2, tilemap);
+
+ set_tile_map(4, 16, 4, 2, tilemapw);
+
+ joypad_init(2, &joy);
+
+ while(TRUE) {
+ joypad_ex(&joy);
+
+ if (joy.joy0 & J_LEFT) {
+ if (xspd > -32) xspd -= 2;
+ } else if (joy.joy0 & J_RIGHT) {
+ if (xspd < 32) xspd += 2;
+ } else {
+ if (xspd < 0) xspd++; else if (xspd > 0) xspd--;
+ }
+
+ if (joy.joy0 & J_UP) {
+ if (yspd > -32) yspd -= 2;
+ } else if (joy.joy0 & J_DOWN) {
+ if (yspd < 32) yspd += 2;
+ } else {
+ if (yspd < 0) yspd++; else if (yspd > 0) yspd--;
+ }
+
+ x += xspd;
+ if (x < (8 << 4)) x = 8 << 4; else if (x > (30 * 8) << 4) x = (30 * 8) << 4;
+
+
+ y += yspd;
+ if (y < 0) y = 0; else if (y > (22 * 8) << 4) y = (22 * 8) << 4;
+
+ tick++; tick &= 7;
+ if (!tick) {
+ anim++; if (anim == 7) anim = 0;
+ set_sprite_tile(0, anim << 2);
+ set_sprite_tile(1, (anim << 2) + 2);
+ }
+
+ move_sprite(0, x >> 4, y >> 4);
+ move_sprite(1, (x >> 4) + 8, y >> 4);
+
+ if (joy.joy1 & J_LEFT) {
+ scroll_bkg(-1, 0);
+ } else if (joy.joy1 & J_RIGHT) {
+ scroll_bkg(1, 0);
+ }
+ if (joy.joy1 & J_UP) {
+ scroll_bkg(0, -1);
+ } else if (joy.joy1 & J_DOWN) {
+ scroll_bkg(0, 1);
+ }
+
+ wait_vbl_done();
+ }
+}
diff --git a/gbdk/gbdk-lib/examples/msxdos/test/Makefile b/gbdk/gbdk-lib/examples/msxdos/test/Makefile
new file mode 100644
index 00000000..f33112a5
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/msxdos/test/Makefile
@@ -0,0 +1,30 @@
+CC = ../../../bin/lcc -mz80:msxdos -Wm-yoA -Wl-j
+
+BINS = test.com
+
+all: $(BINS)
+
+ASRC = $(wildcard *.s)
+CSRC = $(wildcard *.c)
+
+OBJS = $(CSRC:%.c=%.o) $(ASRC:%.s=%.o)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+# Compile and link single file in one pass
+
+%.o: %.c
+ $(CC) -c -o $@ $<
+
+%.o: %.s
+ $(CC) -c -o $@ $<
+
+$(BINS): $(OBJS)
+ $(CC) -Wm-yS -o $@ $^
+ rm -f *.map *.noi *.ihx *.lst
+
+clean:
+ rm -f *.o *.lst *.map *.com *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi
+
diff --git a/gbdk/gbdk-lib/examples/msxdos/test/test.c b/gbdk/gbdk-lib/examples/msxdos/test/test.c
new file mode 100644
index 00000000..e62645d0
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/msxdos/test/test.c
@@ -0,0 +1,10 @@
+#include <gbdk/platform.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+void main() {
+ uint8_t data[32];
+ uint16_t score = 75;
+ printf("%d %s", strlen(uitoa(score, data, 10)), data);
+}
diff --git a/gbdk/gbdk-lib/examples/sms/Makefile b/gbdk/gbdk-lib/examples/sms/Makefile
new file mode 100644
index 00000000..f891d672
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/sms/Makefile
@@ -0,0 +1,17 @@
+# Register all subdirectories in the project's root directory.
+SUBDIRS := $(wildcard */.)
+
+# Top-level phony targets.
+all clean compile.bat: $(SUBDIRS) FORCE
+# Similar to:
+# .PHONY: all clean
+# all clean: $(SUBDIRS)
+# GNU's .PHONY target is more efficient in that it explicitly declares non-files.
+
+# Recurse `make` into each subdirectory
+# Pass along targets specified at command-line (if any).
+$(SUBDIRS): FORCE
+ $(MAKE) -C $@ $(MAKECMDGOALS)
+
+# Force targets.
+FORCE: \ No newline at end of file
diff --git a/gbdk/gbdk-lib/examples/sms/smoke/Makefile b/gbdk/gbdk-lib/examples/sms/smoke/Makefile
new file mode 100644
index 00000000..54ba09e5
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/sms/smoke/Makefile
@@ -0,0 +1,30 @@
+CC = ../../../bin/lcc -mz80:sms -Wm-yoA -Wl-j
+
+BINS = smoketest.sms
+
+all: $(BINS)
+
+ASRC = $(wildcard *.s)
+CSRC = $(wildcard *.c)
+
+OBJS = $(CSRC:%.c=%.o) $(ASRC:%.s=%.o)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+# Compile and link single file in one pass
+
+%.o: %.c
+ $(CC) -c -o $@ $<
+
+%.o: %.s
+ $(CC) -c -o $@ $<
+
+$(BINS): $(OBJS)
+ $(CC) -Wm-yS -o $@ $^
+ rm -f *.map *.noi *.ihx *.lst
+
+clean:
+ rm -f *.o *.lst *.map *.sms *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi
+
diff --git a/gbdk/gbdk-lib/examples/sms/smoke/assets.c b/gbdk/gbdk-lib/examples/sms/smoke/assets.c
new file mode 100644
index 00000000..420dfca9
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/sms/smoke/assets.c
@@ -0,0 +1,46 @@
+#pragma bank 2
+
+#include <sms/sms.h>
+
+BANKREF(earth_data)
+const unsigned char earth_data[] = {
+
+ /* Tile 0x00 */
+ 0x07,0x07,0x18,0x1F,0x32,0x2D,0x71,0x4E,0x70,0x4F,0xF8,0x87,0xF8,0x87,0xF8,0x87,
+ 0xFC,0x83,0xFE,0x81,0x7F,0x40,0x7F,0x40,0x3F,0x20,0x1F,0x18,0x07,0x07,0x00,0x00,
+ 0xC0,0xC0,0xF0,0x30,0x78,0x88,0x3C,0xC4,0x5C,0xA4,0x9E,0x62,0x3E,0xC2,0x3E,0xC2,
+ 0x5E,0xA2,0x7E,0x82,0x0C,0xF4,0x0C,0xF4,0x98,0x68,0xB0,0x70,0xC0,0xC0,0x00,0x00,
+ 0x07,0x07,0x1F,0x18,0x2F,0x30,0x4F,0x70,0x6F,0x50,0x9F,0xE0,0x9F,0xE0,0xBF,0xC0,
+ 0xFF,0x80,0xB7,0xC8,0x63,0x5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xF0,0x30,0x08,0xF8,0x04,0xFC,0x04,0xFC,0x02,0xFE,0x02,0xFE,0x92,0x6E,
+ 0xD6,0x2A,0xFE,0x02,0xEC,0x14,0xFC,0x04,0xF8,0x08,0xF0,0x30,0xC0,0xC0,0x00,0x00,
+ 0x07,0x07,0x1D,0x1A,0x36,0x29,0x5C,0x63,0x6C,0x53,0xCE,0xB1,0x9F,0xE0,0x9E,0xE1,
+ 0xAE,0xD1,0xBF,0xC0,0x47,0x78,0x47,0x78,0x2F,0x30,0x1F,0x18,0x07,0x07,0x00,0x00,
+ 0xC0,0xC0,0x70,0xB0,0x08,0xF8,0x04,0xFC,0x04,0xFC,0xE2,0x1E,0x32,0xCE,0x0E,0xF2,
+ 0x0E,0xF2,0x1E,0xE2,0x1C,0xE4,0x2C,0xD4,0xF8,0x08,0xF0,0x30,0xC0,0xC0,0x00,0x00,
+
+ /* Tile 0x18 */
+ 0x07,0x07,0x1E,0x19,0x33,0x2C,0x49,0x76,0x42,0x7D,0xC4,0xBB,0xC1,0xBE,0xC1,0xBE,
+ 0xE2,0x9D,0xF3,0x8C,0x78,0x47,0x78,0x47,0x3C,0x23,0x1C,0x1B,0x07,0x07,0x00,0x00,
+ 0xC0,0xC0,0x70,0xB0,0x68,0x98,0xC4,0x3C,0xC4,0x3C,0xEE,0x12,0xF2,0x0E,0xE2,0x1E,
+ 0xE2,0x1E,0xF2,0x0E,0x7C,0x84,0x7C,0x84,0xF8,0x08,0xF0,0x30,0xC0,0xC0,0x00,0x00
+};
+
+BANKREF(earth_data_size)
+const unsigned int earth_data_size = sizeof(earth_data);
diff --git a/gbdk/gbdk-lib/examples/sms/smoke/banked.c b/gbdk/gbdk-lib/examples/sms/smoke/banked.c
new file mode 100644
index 00000000..a18c3464
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/sms/smoke/banked.c
@@ -0,0 +1,7 @@
+#pragma bank 3
+
+#include <stdint.h>
+
+uint16_t banked_func(uint8_t be, uint8_t ef) __banked {
+ return ((be << 8) | ef);
+} \ No newline at end of file
diff --git a/gbdk/gbdk-lib/examples/sms/smoke/ram_bank0.s b/gbdk/gbdk-lib/examples/sms/smoke/ram_bank0.s
new file mode 100644
index 00000000..a8a07a0f
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/sms/smoke/ram_bank0.s
@@ -0,0 +1,6 @@
+ .area _DATA_0
+
+_array0::
+ .ds 0x10
+_array1::
+ .ds 0x10 \ No newline at end of file
diff --git a/gbdk/gbdk-lib/examples/sms/smoke/ram_bank1.s b/gbdk/gbdk-lib/examples/sms/smoke/ram_bank1.s
new file mode 100644
index 00000000..06c89c44
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/sms/smoke/ram_bank1.s
@@ -0,0 +1,6 @@
+ .area _DATA_1
+
+_array2::
+ .ds 0x04
+_array3::
+ .ds 0x06 \ No newline at end of file
diff --git a/gbdk/gbdk-lib/examples/sms/smoke/smoketest.c b/gbdk/gbdk-lib/examples/sms/smoke/smoketest.c
new file mode 100644
index 00000000..346435ef
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/sms/smoke/smoketest.c
@@ -0,0 +1,90 @@
+#include <sms/sms.h>
+
+BANKREF_EXTERN(earth_data)
+extern const unsigned char earth_data[];
+
+BANKREF_EXTERN(earth_data_size)
+extern const unsigned int earth_data_size;
+
+const uint8_t tilemap[] = {2, 4, 6, 8, 3, 5, 7, 9};
+const uint16_t tilemapw[] = {2, 4, 6, 8, 3, 5, 7, 9};
+
+uint16_t banked_func(uint8_t be, uint8_t ef) __banked;
+
+int16_t x = 8 << 4, y = 0;
+int8_t xspd = 0, yspd = 0;
+
+uint8_t anim = 0, tick = 0;
+
+joypads_t joy;
+void main() {
+ HIDE_LEFT_COLUMN;
+ SPRITES_8x16;
+ DISPLAY_ON;
+
+// vmemcpy(0x4000, earth_data, sizeof(earth_data));
+
+ SWITCH_ROM(BANK(earth_data));
+ if (banked_func(0xBE, 0xEF) == 0xBEEF) {
+ set_bkg_data(2, earth_data_size >> 4, earth_data);
+ set_sprite_data(0, earth_data_size >> 4, earth_data);
+ set_sprite_tile(0, 0);
+ set_sprite_tile(1, 2);
+ }
+
+ set_bkg_tiles(4, 10, 4, 2, tilemap);
+
+ set_tile_map(4, 16, 4, 2, tilemapw);
+
+ joypad_init(2, &joy);
+
+ while(TRUE) {
+ joypad_ex(&joy);
+
+ if (joy.joy0 & J_LEFT) {
+ if (xspd > -32) xspd -= 2;
+ } else if (joy.joy0 & J_RIGHT) {
+ if (xspd < 32) xspd += 2;
+ } else {
+ if (xspd < 0) xspd++; else if (xspd > 0) xspd--;
+ }
+
+ if (joy.joy0 & J_UP) {
+ if (yspd > -32) yspd -= 2;
+ } else if (joy.joy0 & J_DOWN) {
+ if (yspd < 32) yspd += 2;
+ } else {
+ if (yspd < 0) yspd++; else if (yspd > 0) yspd--;
+ }
+
+ x += xspd;
+ if (x < (8 << 4)) x = 8 << 4; else if (x > (30 * 8) << 4) x = (30 * 8) << 4;
+
+
+ y += yspd;
+ if (y < 0) y = 0; else if (y > (22 * 8) << 4) y = (22 * 8) << 4;
+
+ tick++; tick &= 7;
+ if (!tick) {
+ anim++; if (anim == 7) anim = 0;
+ set_sprite_tile(0, anim << 2);
+ set_sprite_tile(1, (anim << 2) + 2);
+ }
+
+ move_sprite(0, x >> 4, y >> 4);
+ move_sprite(1, (x >> 4) + 8, y >> 4);
+
+ if (joy.joy1 & J_LEFT) {
+ scroll_bkg(-1, 0);
+ } else if (joy.joy1 & J_RIGHT) {
+ scroll_bkg(1, 0);
+ }
+ if (joy.joy1 & J_UP) {
+ scroll_bkg(0, -1);
+ } else if (joy.joy1 & J_DOWN) {
+ scroll_bkg(0, 1);
+ }
+
+ wait_vbl_done();
+ }
+}
diff --git a/gbdk/gbdk-lib/examples/sms/test/Makefile b/gbdk/gbdk-lib/examples/sms/test/Makefile
new file mode 100644
index 00000000..9bc615ae
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/sms/test/Makefile
@@ -0,0 +1,30 @@
+CC = ../../../bin/lcc -mz80:sms -Wm-yoA -Wl-j
+
+BINS = test.sms
+
+all: $(BINS)
+
+ASRC = $(wildcard *.s)
+CSRC = $(wildcard *.c)
+
+OBJS = $(CSRC:%.c=%.o) $(ASRC:%.s=%.o)
+
+compile.bat: Makefile
+ @echo "REM Automatically generated from Makefile" > compile.bat
+ @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
+
+# Compile and link single file in one pass
+
+%.o: %.c
+ $(CC) -c -o $@ $<
+
+%.o: %.s
+ $(CC) -c -o $@ $<
+
+$(BINS): $(OBJS)
+ $(CC) -Wm-yS -o $@ $^
+ rm -f *.map *.noi *.ihx *.lst
+
+clean:
+ rm -f *.o *.lst *.map *.sms *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi
+
diff --git a/gbdk/gbdk-lib/examples/sms/test/test.c b/gbdk/gbdk-lib/examples/sms/test/test.c
new file mode 100644
index 00000000..a8ff0b31
--- /dev/null
+++ b/gbdk/gbdk-lib/examples/sms/test/test.c
@@ -0,0 +1,11 @@
+#include <sms/sms.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+void main() {
+ uint8_t data[32];
+ uint16_t score = 75;
+ printf("%d %s", strlen(uitoa(score, data, 10)), data);
+}
diff --git a/gbdk/gbdk-lib/include/asm/sm83/provides.h b/gbdk/gbdk-lib/include/asm/sm83/provides.h
new file mode 100644
index 00000000..8e297399
--- /dev/null
+++ b/gbdk/gbdk-lib/include/asm/sm83/provides.h
@@ -0,0 +1,4 @@
+#define USE_C_MEMCPY 0
+#define USE_C_STRCPY 0
+#define USE_C_STRCMP 0
+
diff --git a/gbdk/gbdk-lib/include/asm/sm83/stdarg.h b/gbdk/gbdk-lib/include/asm/sm83/stdarg.h
new file mode 100644
index 00000000..0c6e384e
--- /dev/null
+++ b/gbdk/gbdk-lib/include/asm/sm83/stdarg.h
@@ -0,0 +1,18 @@
+#ifndef ASM_SM83_STDARG_INCLUDE
+#define ASM_SM83_STDARG_INCLUDE
+
+/* sdcc pushes right to left with the real sizes, not cast up
+ to an int.
+ so printf(int, char, long)
+ results in push long, push char, push int
+ On the z80 the stack grows down, so the things seem to be in
+ the correct order.
+ */
+
+typedef unsigned char * va_list;
+#define va_start(list, last) list = (unsigned char *)&last + sizeof(last)
+#define va_arg(list, type) *((type *)((list += sizeof(type)) - sizeof(type)))
+
+#define va_end(list)
+
+#endif
diff --git a/gbdk/gbdk-lib/include/asm/sm83/string.h b/gbdk/gbdk-lib/include/asm/sm83/string.h
new file mode 100644
index 00000000..ceb9298a
--- /dev/null
+++ b/gbdk/gbdk-lib/include/asm/sm83/string.h
@@ -0,0 +1,150 @@
+/** @file string.h
+ Generic string functions.
+ */
+#ifndef STRING_INCLUDE
+#define STRING_INCLUDE
+
+#include <types.h>
+
+/** Copies the string pointed to by __src__ (including the terminating
+ `\0' character) to the array pointed to by __dest__.
+
+ The strings may not overlap, and the destination string dest must
+ be large enough to receive the copy.
+
+ @param dest Array to copy into
+ @param src Array to copy from
+
+ @return A pointer to dest
+*/
+char *strcpy(char *dest, const char *src) OLDCALL PRESERVES_REGS(b, c);
+
+/** Compares strings
+
+ @param s1 First string to compare
+ @param s2 Second string to compare
+
+ Returns:
+ \li > 0 if __s1__ > __s2__
+ \li 0 if __s1__ == __s2__
+ \li < 0 if __s1__ < __s2__
+*/
+int strcmp(const char *s1, const char *s2) OLDCALL PRESERVES_REGS(b, c);
+
+/** Copies n bytes from memory area src to memory area dest.
+
+ The memory areas may not overlap.
+
+ @param dest Buffer to copy into
+ @param src Buffer to copy from
+ @param len Number of Bytes to copy
+*/
+void *memcpy(void *dest, const void *src, size_t len);
+
+/** Copies n bytes from memory area src to memory area dest, areas may overlap
+ */
+void *memmove (void *dest, const void *src, size_t n);
+
+/** Fills the memory region __s__ with __n__ bytes using value __c__
+
+ @param s Buffer to fill
+ @param c char value to fill with (truncated from int)
+ @param n Number of bytes to fill
+*/
+void *memset (void *s, int c, size_t n) OLDCALL PRESERVES_REGS(b, c);
+
+/** Reverses the characters in a string
+
+ @param s Pointer to string to reverse.
+
+ For example 'abcdefg' will become 'gfedcba'.
+
+ Banked as the string must be modifiable.
+
+ Returns: Pointer to __s__
+*/
+char *reverse(char *s) OLDCALL PRESERVES_REGS(b, c);
+
+/** Concatenate Strings. Appends string __s2__ to the end of string __s1__
+
+ @param s1 String to append onto
+ @param s2 String to copy from
+
+ For example 'abc' and 'def' will become 'abcdef'.
+
+ String __s1__ must be large enough to store both __s1__ and __s2__.
+
+ Returns: Pointer to __s1__
+*/
+char *strcat(char *s1, const char *s2);
+
+/** Calculates the length of a string
+
+ @param s String to calculate length of
+
+ Returns: Length of string not including the terminating `\0' character.
+*/
+int strlen(const char *s) OLDCALL PRESERVES_REGS(b, c);
+
+/**Concatenate at most __n__ characters from string __s2__ onto the end of __s1__.
+
+ @param s1 String to append onto
+ @param s2 String to copy from
+ @param n Max number of characters to copy from __s2__
+
+ String __s1__ must be large enough to store both __s1__ and __n__ characters of __s2__
+
+ Returns: Pointer to __s1__
+*/
+char *strncat(char *s1, const char *s2, int n);
+
+/** Compare strings (at most __n__ characters):
+
+ @param s1 First string to compare
+ @param s2 Second string to compare
+ @param n Max number of characters to compare
+
+ Returns zero if the strings are identical, or non-zero
+ if they are not (see below).
+
+ Returns:
+ \li > 0 if __s1__ > __s2__ (at first non-matching byte)
+ \li 0 if __s1__ == __s2__
+ \li < 0 if __s1__ < __s2__ (at first non-matching byte)
+*/
+int strncmp(const char *s1, const char *s2, int n);
+
+/** Copy __n__ characters from string __s2__ to __s1__
+
+
+ @param s1 String to copy into
+ @param s2 String to copy from
+ @param n Max number of characters to copy from __s2__
+
+ If __s2__ is shorter than __n__, the remaining
+ bytes in __s1__ are filled with \0.
+
+ Warning: If there is no \0 in the first __n__ bytes of __s2__ then __s1__
+ will not be null terminated.
+
+ Returns: Pointer to __s1__
+*/
+char *strncpy(char *s1, const char *s2, int n);
+
+/** Compare up to __count__ bytes in buffers __buf1__ and __buf2__
+
+ @param buf1 Pointer to First buffer to compare
+ @param buf2 Pointer to Second buffer to compare
+ @param count Max number of bytes to compare
+
+ Returns zero if the buffers are identical, or non-zero
+ if they are not (see below).
+
+ Returns:
+ \li > 0 if __buf1__ > __buf2__ (at first non-matching byte)
+ \li 0 if __buf1__ == __buf2__
+ \li < 0 if __buf1__ < __buf2__ (at first non-matching byte)
+*/
+int memcmp(const void *buf1, const void *buf2, size_t count) OLDCALL;
+
+#endif
diff --git a/gbdk/gbdk-lib/include/asm/sm83/types.h b/gbdk/gbdk-lib/include/asm/sm83/types.h
new file mode 100644
index 00000000..f6e7e101
--- /dev/null
+++ b/gbdk/gbdk-lib/include/asm/sm83/types.h
@@ -0,0 +1,70 @@
+/** @file asm/sm83/types.h
+ @anchor file_asm_sm83_types_h
+ Types definitions for the gb.
+*/
+#ifndef ASM_SM83_TYPES_INCLUDE
+#define ASM_SM83_TYPES_INCLUDE
+
+#ifndef __PORT_sm83
+ #error sm83 only.
+#endif
+
+#ifdef __SDCC
+
+#define NONBANKED __nonbanked /**< Placed in the non-banked lower 16K region (bank 0), regardless of the bank selected by it's source file. */
+#define BANKED __banked /**< The function will use banked sdcc calls, and is placed in the bank selected by it's source file (or compiler switches). */
+
+/** Use to create a block of of code which should execute with interrupts temporarily turned off.
+
+ __Do not__ use @ref CRITICAL and @ref INTERRUPT attributes for a
+ function added via add_VBL() (or LCD, etc). The attributes
+ are only required when constructing a bare jump from the
+ interrupt vector itself.
+
+ @see enable_interrupts, disable_interrupts
+*/
+#define CRITICAL __critical
+
+/** Indicate to the compiler the function will be used as an interrupt handler.
+
+ __Do not__ use @ref CRITICAL and @ref INTERRUPT attributes for a
+ function added via add_VBL() (or LCD, etc). The attributes
+ are only required when constructing a bare jump from the
+ interrupt vector itself.
+
+ @see ISR_VECTOR(), ISR_NESTED_VECTOR()
+*/
+#define INTERRUPT __interrupt
+
+#endif
+
+/** Signed eight bit.
+ */
+typedef signed char INT8;
+/** Unsigned eight bit.
+ */
+typedef unsigned char UINT8;
+/** Signed sixteen bit.
+ */
+typedef signed int INT16;
+/** Unsigned sixteen bit.
+ */
+typedef unsigned int UINT16;
+/** Signed 32 bit.
+ */
+typedef signed long INT32;
+/** Unsigned 32 bit.
+ */
+typedef unsigned long UINT32;
+
+#ifndef __SIZE_T_DEFINED
+#define __SIZE_T_DEFINED
+typedef unsigned int size_t;
+#endif
+
+/** Returned from clock
+ @see clock
+*/
+typedef unsigned int clock_t;
+
+#endif
diff --git a/gbdk/gbdk-lib/include/asm/types.h b/gbdk/gbdk-lib/include/asm/types.h
new file mode 100644
index 00000000..5ed75f45
--- /dev/null
+++ b/gbdk/gbdk-lib/include/asm/types.h
@@ -0,0 +1,90 @@
+/** @file asm/types.h
+ Shared types definitions.
+*/
+#ifndef ASM_TYPES_INCLUDE
+#define ASM_TYPES_INCLUDE
+
+#if defined(__PORT_sm83)
+#include <asm/sm83/types.h>
+#elif defined(__PORT_z80)
+#include <asm/z80/types.h>
+#else
+#error Unrecognised port
+#endif
+
+#ifndef OLDCALL
+#if __SDCC_REVISION >= 12608
+#define OLDCALL __sdcccall(0)
+#else
+#define OLDCALL
+#endif
+#endif
+
+#ifdef __SDCC
+#define PRESERVES_REGS(...) __preserves_regs(__VA_ARGS__)
+#define NAKED __naked
+#define SFR __sfr
+#define AT(A) __at(A)
+#else
+#define PRESERVES_REGS(...)
+#define NAKED
+#define SFR
+#define AT(A)
+#endif
+
+#ifndef NONBANKED
+#define NONBANKED
+#endif
+#ifndef BANKED
+#define BANKED
+#endif
+#ifndef CRITICAL
+#define CRITICAL
+#endif
+#ifndef INTERRUPT
+#define INTERRUPT
+#endif
+
+/** TRUE or FALSE.
+ @anchor file_asm_types_h
+ */
+typedef INT8 BOOLEAN;
+
+/** Signed 8 bit.
+ */
+typedef INT8 BYTE;
+/** Unsigned 8 bit.
+ */
+typedef UINT8 UBYTE;
+/** Signed 16 bit */
+typedef INT16 WORD;
+/** Unsigned 16 bit */
+typedef UINT16 UWORD;
+/** Signed 32 bit */
+typedef INT32 LWORD;
+/** Unsigned 32 bit */
+typedef UINT32 ULWORD;
+/** Signed 32 bit */
+typedef INT32 DWORD;
+/** Unsigned 32 bit */
+typedef UINT32 UDWORD;
+
+/** Useful definition for working with 8 bit + 8 bit fixed point values
+
+ Use `.w` to access the variable as unsigned 16 bit type.
+
+ Use `.b.h` and `.b.l` (or just `.h` and `.l`) to directly access it's high and low unsigned 8 bit values.
+ */
+typedef union _fixed {
+ struct {
+ UBYTE l;
+ UBYTE h;
+ };
+ struct {
+ UBYTE l;
+ UBYTE h;
+ } b;
+ UWORD w;
+} fixed;
+
+#endif
diff --git a/gbdk/gbdk-lib/include/asm/z80/provides.h b/gbdk/gbdk-lib/include/asm/z80/provides.h
new file mode 100644
index 00000000..d7aa1956
--- /dev/null
+++ b/gbdk/gbdk-lib/include/asm/z80/provides.h
@@ -0,0 +1,4 @@
+#define USE_C_MEMCPY 0
+#define USE_C_STRCPY 0
+#define USE_C_STRCMP 1
+
diff --git a/gbdk/gbdk-lib/include/asm/z80/stdarg.h b/gbdk/gbdk-lib/include/asm/z80/stdarg.h
new file mode 100644
index 00000000..a82642fe
--- /dev/null
+++ b/gbdk/gbdk-lib/include/asm/z80/stdarg.h
@@ -0,0 +1,18 @@
+#ifndef ASM_Z80_STDARG_INCLUDE
+#define ASM_Z80_STDARG_INCLUDE
+
+/* sdcc pushes right to left with the real sizes, not cast up
+ to an int.
+ so printf(int, char, long)
+ results in push long, push char, push int
+ On the z80 the stack grows down, so the things seem to be in
+ the correct order.
+ */
+
+typedef unsigned char * va_list;
+#define va_start(list, last) list = (unsigned char *)&last + sizeof(last)
+#define va_arg(list, type) *((type *)((list += sizeof(type)) - sizeof(type)))
+
+#define va_end(list)
+
+#endif
diff --git a/gbdk/gbdk-lib/include/asm/z80/string.h b/gbdk/gbdk-lib/include/asm/z80/string.h
new file mode 100644
index 00000000..0d4b2e01
--- /dev/null
+++ b/gbdk/gbdk-lib/include/asm/z80/string.h
@@ -0,0 +1,144 @@
+/** @file string.h
+ Generic string functions.
+ */
+#ifndef STRING_INCLUDE
+#define STRING_INCLUDE
+
+#include <types.h>
+
+/** Copies the string pointed to by __src__ (including the terminating
+ `\0' character) to the array pointed to by __dest__.
+
+ The strings may not overlap, and the destination string dest must
+ be large enough to receive the copy.
+
+ @param dest Array to copy into
+ @param src Array to copy from
+
+ @return A pointer to dest
+*/
+char *strcpy(char *dest, const char *src) OLDCALL;
+
+/** Compares strings
+
+ @param s1 First string to compare
+ @param s2 Second string to compare
+
+ Returns:
+ \li > 0 if __s1__ > __s2__
+ \li 0 if __s1__ == __s2__
+ \li < 0 if __s1__ < __s2__
+*/
+int strcmp(const char *s1, const char *s2);
+
+/** Copies n bytes from memory area src to memory area dest.
+
+ The memory areas may not overlap.
+
+ @param dest Buffer to copy into
+ @param src Buffer to copy from
+ @param len Number of Bytes to copy
+*/
+void *memcpy(void *dest, const void *src, size_t len);
+
+/** Copies n bytes from memory area src to memory area dest, areas may overlap
+ */
+void *memmove (void *dest, const void *src, size_t n) OLDCALL;
+
+/** Fills the memory region __s__ with __n__ bytes using value __c__
+
+ @param s Buffer to fill
+ @param c char value to fill with (truncated from int)
+ @param n Number of bytes to fill
+*/
+void *memset (void *s, int c, size_t n) Z88DK_CALLEE;
+
+/** Reverses the characters in a string
+
+ @param s Pointer to string to reverse.
+
+ For example 'abcdefg' will become 'gfedcba'.
+
+ Banked as the string must be modifiable.
+
+ Returns: Pointer to __s__
+*/
+char *reverse(char *s) NONBANKED;
+
+/** Concatenate Strings. Appends string __s2__ to the end of string __s1__
+
+ @param s1 String to append onto
+ @param s2 String to copy from
+
+ For example 'abc' and 'def' will become 'abcdef'.
+
+ String __s1__ must be large enough to store both __s1__ and __s2__.
+
+ Returns: Pointer to __s1__
+*/
+char *strcat(char *s1, const char *s2) NONBANKED;
+
+/** Calculates the length of a string
+
+ @param s String to calculate length of
+
+ Returns: Length of string not including the terminating `\0' character.
+*/
+int strlen(const char *s) OLDCALL;
+
+/**Concatenate at most __n__ characters from string __s2__ onto the end of __s1__.
+
+ @param s1 String to append onto
+ @param s2 String to copy from
+ @param n Max number of characters to copy from __s2__
+
+ String __s1__ must be large enough to store both __s1__ and __n__ characters of __s2__
+
+ Returns: Pointer to __s1__
+*/
+char *strncat(char *s1, const char *s2, int n) NONBANKED;
+
+/** Compare strings (at most n characters):
+
+ @param s1 First string to compare
+ @param s2 Second string to compare
+ @param n Max number of characters to compare
+
+ Returns:
+ \li > 0 if __s1__ > __s2__
+ \li 0 if __s1__ == __s2__
+ \li < 0 if __s1__ < __s2__
+*/
+int strncmp(const char *s1, const char *s2, int n) NONBANKED;
+
+/** Copy __n__ characters from string __s2__ to __s1__
+
+
+ @param s1 String to copy into
+ @param s2 String to copy from
+ @param n Max number of characters to copy from __s2__
+
+ If __s2__ is shorter than __n__, the remaining
+ bytes in __s1__ are filled with \0.
+
+ Warning: If there is no \0 in the first __n__ bytes of __s2__ then __s1__
+ will not be null terminated.
+
+ Returns: Pointer to __s1__
+*/
+char *strncpy(char *s1, const char *s2, int n) NONBANKED;
+
+/** Compares buffers
+
+ @param buf1 First buffer to compare
+ @param buf2 Second buffer to compare
+ @param count Buffer length
+
+ Returns:
+ \li > 0 if __buf1__ > __buf2__
+ \li 0 if __buf1__ == __buf2__
+ \li < 0 if __buf1__ < __buf2__
+*/
+int memcmp(const void *buf1, const void *buf2, size_t count) Z88DK_CALLEE;
+
+#endif
diff --git a/gbdk/gbdk-lib/include/asm/z80/types.h b/gbdk/gbdk-lib/include/asm/z80/types.h
new file mode 100644
index 00000000..bb9dc160
--- /dev/null
+++ b/gbdk/gbdk-lib/include/asm/z80/types.h
@@ -0,0 +1,76 @@
+/** @file asm/z80/types.h
+ @anchor file_asm_z80_types_h
+ Types definitions for the gb.
+*/
+#ifndef ASM_Z80_TYPES_INCLUDE
+#define ASM_Z80_TYPES_INCLUDE
+
+#ifndef __PORT_z80
+ #error z80 only.
+#endif
+
+#ifdef __SDCC
+
+#define Z88DK_CALLEE __sdcccall(0) __z88dk_callee
+#define Z88DK_FASTCALL __z88dk_fastcall
+
+#define NONBANKED __nonbanked /**< Placed in the non-banked lower 16K region (bank 0), regardless of the bank selected by it's source file. */
+#define BANKED __banked /**< The function will use banked sdcc calls, and is placed in the bank selected by it's source file (or compiler switches). */
+
+/** Use to create a block of of code which should execute with interrupts temporarily turned off.
+
+ __Do not__ use @ref CRITICAL and @ref INTERRUPT attributes for a
+ function added via add_VBL() (or LCD, etc). The attributes
+ are only required when constructing a bare jump from the
+ interrupt vector itself.
+
+ @see enable_interrupts, disable_interrupts
+*/
+#define CRITICAL __critical
+
+/** Indicate to the compiler the function will be used as an interrupt handler.
+
+ __Do not__ use @ref CRITICAL and @ref INTERRUPT attributes for a
+ function added via add_VBL() (or LCD, etc). The attributes
+ are only required when constructing a bare jump from the
+ interrupt vector itself.
+*/
+#define INTERRUPT __interrupt
+
+#else
+
+#define Z88DK_CALLEE
+#define Z88DK_FASTCALL
+
+#endif
+
+/** Signed eight bit.
+ */
+typedef signed char INT8;
+/** Unsigned eight bit.
+ */
+typedef unsigned char UINT8;
+/** Signed sixteen bit.
+ */
+typedef signed int INT16;
+/** Unsigned sixteen bit.
+ */
+typedef unsigned int UINT16;
+/** Signed 32 bit.
+ */
+typedef signed long INT32;
+/** Unsigned 32 bit.
+ */
+typedef unsigned long UINT32;
+
+#ifndef __SIZE_T_DEFINED
+#define __SIZE_T_DEFINED
+typedef unsigned int size_t;
+#endif
+
+/** Returned from clock
+ @see clock
+*/
+typedef unsigned int clock_t;
+
+#endif
diff --git a/gbdk/gbdk-lib/include/assert.h b/gbdk/gbdk-lib/include/assert.h
new file mode 100644
index 00000000..6a62a5e6
--- /dev/null
+++ b/gbdk/gbdk-lib/include/assert.h
@@ -0,0 +1,47 @@
+/*-------------------------------------------------------------------------
+ assert.h - header file for assert ANSI routine
+
+ Copyright (C) 2018, Philipp Klaus Krause . pkk@spth.de
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to the
+ Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+ As a special exception, if you link this library with other files,
+ some of which are compiled with SDCC, to produce an executable,
+ this library does not by itself cause the resulting executable to
+ be covered by the GNU General Public License. This exception does
+ not however invalidate any other reasons why the executable file
+ might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
+
+#undef assert
+
+#ifdef NDEBUG
+
+/* Debugging disabled -- do not evaluate assertions. */
+#define assert(x) ((void)0)
+
+#else
+
+/* Debugging enabled -- verify assertions at run time. */
+void __assert(const char *expression, const char *functionname, const char *filename, unsigned int linenumber);
+#define assert(x) ((x) ? (void)0 : __assert(#x, __func__, __FILE__, __LINE__))
+
+#if __STDC_VERSION__ >= 201112L
+#define static_assert _Static_assert
+#endif
+
+#endif
+
diff --git a/gbdk/gbdk-lib/include/ctype.h b/gbdk/gbdk-lib/include/ctype.h
new file mode 100644
index 00000000..91f9c8ec
--- /dev/null
+++ b/gbdk/gbdk-lib/include/ctype.h
@@ -0,0 +1,45 @@
+/** @file ctype.h
+ Character type functions.
+*/
+#ifndef _CTYPE_H
+#define _CTYPE_H
+
+#include <types.h>
+#include <stdbool.h>
+
+/** Returns TRUE if the character __c__ is a letter (a-z, A-Z), otherwise FALSE
+ @param c Character to test
+*/
+bool isalpha(char c);
+
+/** Returns TRUE if the character __c__ is an uppercase letter (A-Z), otherwise FALSE
+ @param c Character to test
+*/
+bool isupper(char c);
+
+/** Returns TRUE if the character __c__ is a lowercase letter (a-z), otherwise FALSE
+ @param c Character to test
+*/
+bool islower(char c);
+
+/** Returns TRUE if the character __c__ is a digit (0-9), otherwise FALSE
+ @param c Character to test
+*/
+bool isdigit(char c);
+
+/** Returns TRUE if the character __c__ is a space (' '), tab (\\t), or newline (\\n) character, otherwise FALSE
+ @param c Character to test
+*/
+bool isspace(char c);
+
+/** Returns uppercase version of character __c__ if it is a letter (a-z), otherwise it returns the input value unchanged.
+ @param c Character to test
+*/
+char toupper(char c);
+
+/** Returns lowercase version of character __c__ if it is a letter (A-Z), otherwise it returns the input value unchanged.
+ @param c Character to test
+*/
+char tolower(char c);
+
+#endif /* _CTYPE_H */
diff --git a/gbdk/gbdk-lib/include/gb/bcd.h b/gbdk/gbdk-lib/include/gb/bcd.h
new file mode 100644
index 00000000..4f3f0049
--- /dev/null
+++ b/gbdk/gbdk-lib/include/gb/bcd.h
@@ -0,0 +1,61 @@
+#ifndef __BCD_H_INCLUDE
+#define __BCD_H_INCLUDE
+
+#include <types.h>
+#include <stdint.h>
+
+/** @file bcd.h
+ Support for working with BCD (Binary Coded Decimal)
+
+ See the example BCD project for additional details.
+*/
+
+// macro for creating BCD constants
+#define BCD_HEX(v) ((BCD)(v))
+
+/** Converts an integer value into BCD format
+
+ A maximum of 8 digits may be used
+*/
+#define MAKE_BCD(v) BCD_HEX(0x ## v)
+
+typedef uint32_t BCD;
+
+/** Converts integer __i__ into BCD format (Binary Coded Decimal)
+ @param i Numeric value to convert
+ @param value Pointer to a BCD variable to store the converted result
+*/
+void uint2bcd(uint16_t i, BCD * value) OLDCALL;
+
+/** Adds two numbers in BCD format: __sour__ += __value__
+ @param sour Pointer to a BCD value to add to (and where the result is stored)
+ @param value Pointer to the BCD value to add to __sour__
+*/
+void bcd_add(BCD * sour, const BCD * value) OLDCALL;
+
+/** Subtracts two numbers in BCD format: __sour__ -= __value__
+ @param sour Pointer to a BCD value to subtract from (and where the result is stored)
+ @param value Pointer to the BCD value to subtract from __sour__
+*/
+void bcd_sub(BCD * sour, const BCD * value) OLDCALL;
+
+/** Convert a BCD number into an asciiz (null terminated) string and return the length
+ @param bcd Pointer to BCD value to convert
+ @param tile_offset Optional per-character offset value to add (use 0 for none)
+ @param buffer Buffer to store the result in
+
+ Returns: Length in characters (always 8)
+
+ __buffer__ should be large enough to store the converted string
+ (9 bytes: 8 characters + 1 for terminator)
+
+ There are a couple different ways to use __tile_offset__.
+ For example:
+ \li It can be the Index of the Font Tile '0' in VRAM to
+ allow the buffer to be used directly with @ref set_bkg_tiles.
+ \li It can also be set to the ascii value for character '0'
+ so that the buffer is a normal string that can be passed to @ref printf.
+*/
+uint8_t bcd2text(const BCD * bcd, uint8_t tile_offset, uint8_t * buffer) OLDCALL;
+
+#endif
diff --git a/gbdk/gbdk-lib/include/gb/bgb_emu.h b/gbdk/gbdk-lib/include/gb/bgb_emu.h
new file mode 100644
index 00000000..77f204ba
--- /dev/null
+++ b/gbdk/gbdk-lib/include/gb/bgb_emu.h
@@ -0,0 +1,13 @@
+/** @file gb/bgb_emu.h
+
+ Shim for legacy use of @ref bgb_emu.h which has been
+ migrated to @ref emu_debug.h
+
+ See the `emu_debug` example project included with gbdk.
+*/
+#ifndef __BGB_EMU_INCLUDE
+#define __BGB_EMU_INCLUDE
+
+#include <gbdk/emu_debug.h>
+
+#endif
diff --git a/gbdk/gbdk-lib/include/gb/cgb.h b/gbdk/gbdk-lib/include/gb/cgb.h
new file mode 100644
index 00000000..7cbded42
--- /dev/null
+++ b/gbdk/gbdk-lib/include/gb/cgb.h
@@ -0,0 +1,182 @@
+/** @file gb/cgb.h
+ Support for the Color GameBoy (CGB).
+
+ __Enabling CGB features__
+
+ To unlock and use CGB features and registers you need to
+ change byte 0143h in the cartridge header. Otherwise, the CGB
+ will operate in monochrome "Non CGB" compatibility mode.
+ \li Use a value of __80h__ for games that support CGB and monochrome gameboys
+ \n (with Lcc: __-Wm-yc__, or makebin directly: __-yc__)
+ \li Use a value of __C0h__ for CGB only games.
+ \n (with Lcc: __-Wm-yC__, or makebin directly: __-yC__)
+
+ See the Pan Docs for more information CGB features.
+*/
+
+#ifndef _CGB_H
+#define _CGB_H
+
+#include <types.h>
+#include <stdint.h>
+
+/** Macro to create a CGB palette color entry out of 5-bit color components.
+
+ @param r 5-bit Red Component, range 0 - 31 (31 brightest)
+ @param g 5-bit Green Component, range 0 - 31 (31 brightest)
+ @param b 5-bit Blue Component, range 0 - 31 (31 brightest)
+
+ The resulting format is bitpacked BGR-555 in a uint16_t.
+
+ @see set_bkg_palette(), set_sprite_palette(), RGB8(), RGBHTML()
+ */
+#define RGB(r, g, b) ((((uint16_t)(b) & 0x1f) << 10) | (((uint16_t)(g) & 0x1f) << 5) | (((uint16_t)(r) & 0x1f) << 0))
+
+/** Macro to create a CGB palette color entry out of 8-bit color components.
+
+ @param r 8-bit Red Component, range 0 - 255 (255 brightest)
+ @param g 8-bit Green Component, range 0 - 255 (255 brightest)
+ @param b 8-bit Blue Component, range 0 - 255 (255 brightest)
+
+ The resulting format is bitpacked BGR-555 in a uint16_t.
+
+ The lowest 3 bits of each color component are dropped during conversion.
+
+ @see set_bkg_palette(), set_sprite_palette(), RGB(), RGBHTML()
+ */
+#define RGB8(r, g, b) ((uint16_t)((r) >> 3) | ((uint16_t)((g) >> 3) << 5) | ((uint16_t)((b) >> 3) << 10))
+
+/** Macro to convert a 24 Bit RGB color to a CGB palette color entry.
+
+ @param RGB24bit Bit packed RGB-888 color (0-255 for each color component).
+
+ The resulting format is bitpacked BGR-555 in a uint16_t.
+
+ The lowest 3 bits of each color component are dropped during conversion.
+
+ @see set_bkg_palette(), set_sprite_palette(), RGB(), RGB8()
+ */
+#define RGBHTML(RGB24bit) (RGB8((((RGB24bit) >> 16) & 0xFF), (((RGB24bit) >> 8) & 0xFF), ((RGB24bit) & 0xFF)))
+
+/** Common colors based on the EGA default palette.
+ */
+#define RGB_RED RGB(31, 0, 0)
+#define RGB_DARKRED RGB(15, 0, 0)
+#define RGB_GREEN RGB( 0, 31, 0)
+#define RGB_DARKGREEN RGB( 0, 15, 0)
+#define RGB_BLUE RGB( 0, 0, 31)
+#define RGB_DARKBLUE RGB( 0, 0, 15)
+#define RGB_YELLOW RGB(31, 31, 0)
+#define RGB_DARKYELLOW RGB(21, 21, 0)
+#define RGB_CYAN RGB( 0, 31, 31)
+#define RGB_AQUA RGB(28, 5, 22)
+#define RGB_PINK RGB(31, 0, 31)
+#define RGB_PURPLE RGB(21, 0, 21)
+#define RGB_BLACK RGB( 0, 0, 0)
+#define RGB_DARKGRAY RGB(10, 10, 10)
+#define RGB_LIGHTGRAY RGB(21, 21, 21)
+#define RGB_WHITE RGB(31, 31, 31)
+
+#define RGB_LIGHTFLESH RGB(30, 20, 15)
+#define RGB_BROWN RGB(10, 10, 0)
+#define RGB_ORANGE RGB(30, 20, 0)
+#define RGB_TEAL RGB(15, 15, 0)
+
+typedef uint16_t palette_color_t; /**< 16 bit color entry */
+
+/** Set CGB background palette(s).
+
+ @param first_palette Index of the first palette to write (0-7)
+ @param nb_palettes Number of palettes to write (1-8, max depends on first_palette)
+ @param rgb_data Pointer to source palette data
+
+ Writes __nb_palettes__ to background palette data starting
+ at __first_palette__, Palette data is sourced from __rgb_data__.
+
+ \li Each Palette is 8 bytes in size: 4 colors x 2 bytes per palette color entry.
+ \li Each color (4 per palette) is packed as BGR-555 format (1:5:5:5, MSBit [15] is unused).
+ \li Each component (R, G, B) may have values from 0 - 31 (5 bits), 31 is brightest.
+
+ @see RGB(), set_bkg_palette_entry()
+ */
+void set_bkg_palette(uint8_t first_palette, uint8_t nb_palettes, palette_color_t *rgb_data) OLDCALL;
+
+/** Set CGB sprite palette(s).
+
+ @param first_palette Index of the first palette to write (0-7)
+ @param nb_palettes Number of palettes to write (1-8, max depends on first_palette)
+ @param rgb_data Pointer to source palette data
+
+ Writes __nb_palettes__ to sprite palette data starting
+ at __first_palette__, Palette data is sourced from __rgb_data__.
+
+ \li Each Palette is 8 bytes in size: 4 colors x 2 bytes per palette color entry.
+ \li Each color (4 per palette) is packed as BGR-555 format (1:5:5:5, MSBit [15] is unused).
+ \li Each component (R, G, B) may have values from 0 - 31 (5 bits), 31 is brightest.
+
+ @see RGB(), set_sprite_palette_entry()
+ */
+void set_sprite_palette(uint8_t first_palette, uint8_t nb_palettes, palette_color_t *rgb_data) OLDCALL;
+
+/** Sets a single color in the specified CGB background palette.
+
+ @param palette Index of the palette to modify (0-7)
+ @param entry Index of color in palette to modify (0-3)
+ @param rgb_data New color data in BGR 15bpp format.
+
+ @see set_bkg_palette(), RGB()
+ */
+
+void set_bkg_palette_entry(uint8_t palette, uint8_t entry, uint16_t rgb_data) OLDCALL;
+
+/** Sets a single color in the specified CGB sprite palette.
+
+ @param palette Index of the palette to modify (0-7)
+ @param entry Index of color in palette to modify (0-3)
+ @param rgb_data New color data in BGR 15bpp format.
+
+ @see set_sprite_palette(), RGB()
+ */
+void set_sprite_palette_entry(uint8_t palette, uint8_t entry, uint16_t rgb_data) OLDCALL;
+
+/** Set CPU speed to slow (Normal Speed) operation.
+
+ Interrupts are temporarily disabled and then re-enabled during this call.
+
+ In this mode the CGB operates at the same speed as the DMG/Pocket/SGB models.
+
+ \li You can check to see if @ref _cpu == @ref CGB_TYPE before using this function.
+
+ @see cpu_fast()
+ */
+void cpu_slow();
+
+/** Set CPU speed to fast (CGB Double Speed) operation.
+
+ On startup the CGB operates in Normal Speed Mode and can be switched
+ into Double speed mode (faster processing but also higher power consumption).
+ See the Pan Docs for more information about which hardware features
+ operate faster and which remain at Normal Speed.
+
+ \li Interrupts are temporarily disabled and then re-enabled during this call.
+ \li You can check to see if @ref _cpu == @ref CGB_TYPE before using this function.
+
+ @see cpu_slow(), _cpu
+*/
+void cpu_fast();
+
+/** Set palette, compatible with the DMG/GBP.
+
+ The default/first CGB palettes for sprites and backgrounds are
+ set to a similar default appearance as on the DMG/Pocket/SGB models.
+ (White, Light Gray, Dark Gray, Black)
+
+ \li You can check to see if @ref _cpu == @ref CGB_TYPE before using this function.
+ */
+void set_default_palette();
+
+/** This function is obsolete
+ */
+void cgb_compatibility();
+
+#endif /* _CGB_H */
diff --git a/gbdk/gbdk-lib/include/gb/crash_handler.h b/gbdk/gbdk-lib/include/gb/crash_handler.h
new file mode 100644
index 00000000..5c82b37c
--- /dev/null
+++ b/gbdk/gbdk-lib/include/gb/crash_handler.h
@@ -0,0 +1,25 @@
+/** @file gb/crash_handler.h
+
+ When crash_handler.h is included, a crash dump screen
+ will be displayed if the CPU executes uninitalized
+ memory (with a value of 0xFF, the opcode for RST 38).
+ A handler is installed for RST 38 that calls
+ @ref __HandleCrash().
+
+ \code{.c}
+ #include <gb/crash_handler.h>
+ \endcode
+
+ Also see the `crash` example project included with gbdk.
+*/
+#ifndef __CRASH_HANDLER_INCLUDE
+#define __CRASH_HANDLER_INCLUDE
+
+/** Display the crash dump screen.
+
+ See the intro for this file for more details.
+*/
+void __HandleCrash();
+static void * __CRASH_HANDLER_INIT = &__HandleCrash;
+
+#endif \ No newline at end of file
diff --git a/gbdk/gbdk-lib/include/gb/drawing.h b/gbdk/gbdk-lib/include/gb/drawing.h
new file mode 100644
index 00000000..bc53d042
--- /dev/null
+++ b/gbdk/gbdk-lib/include/gb/drawing.h
@@ -0,0 +1,145 @@
+/** @file gb/drawing.h
+ All Points Addressable (APA) mode drawing library.
+
+ Drawing routines originally by Pascal Felber
+ Legendary overhall by Jon Fuge <jonny@q-continuum.demon.co.uk>
+ Commenting by Michael Hope
+
+ Note: The standard text printf() and putchar() cannot be used
+ in APA mode - use gprintf() and wrtchr() instead.
+
+ Note: Using drawing.h will cause it's custom VBL and LCD ISRs
+ (`drawing_vbl` and `drawing_lcd`) to be installed. Changing
+ the mode (`mode(M_TEXT_OUT);`) will cause them to be de-installed.
+
+ The valid coordinate ranges are from (x,y) 0,0 to 159,143.
+ There is no built-in clipping, so drawing outside valid
+ coordinates will likely produce undesired results (wrapping/etc).
+
+ ----
+
+ __Important note for the drawing API :__
+
+ The Game Boy graphics hardware is not well suited to frame-buffer
+ style graphics such as the kind provided in `drawing.h`.
+ Due to that, __most drawing functions (rectangles, circles, etc) will
+ be slow__ . When possible it's much faster and more efficient
+ to work with the tiles and tile maps that the Game Boy hardware is
+ built around.
+*/
+#ifndef __DRAWING_H
+#define __DRAWING_H
+
+#include <types.h>
+#include <stdint.h>
+
+/** Size of the screen in pixels */
+#define GRAPHICS_WIDTH 160
+#define GRAPHICS_HEIGHT 144
+
+#define SOLID 0x00 /* Overwrites the existing pixels */
+#define OR 0x01 /* Performs a logical OR */
+#define XOR 0x02 /* Performs a logical XOR */
+#define AND 0x03 /* Performs a logical AND */
+
+/** Possible drawing colours */
+#define WHITE 0
+#define LTGREY 1
+#define DKGREY 2
+#define BLACK 3
+
+/** Possible fill styles for box() and circle() */
+#define M_NOFILL 0
+#define M_FILL 1
+
+/** Possible values for signed_value in gprintln() and gprintn() */
+#define SIGNED 1
+#define UNSIGNED 0
+
+#include <types.h>
+
+/** Print the string 'str' with no interpretation
+ @see gotogxy()
+*/
+void gprint(char *str) NONBANKED;
+
+/** Print 16 bit __number__ in __radix__ (base) in the default font at the current text position.
+
+ @param number number to print
+ @param radix radix (base) to print with
+ @param signed_value should be set to SIGNED or UNSIGNED depending on whether the number is signed or not
+
+ The current position is advanced by the numer of characters printed.
+ @see gotogxy()
+*/
+void gprintln(int16_t number, int8_t radix, int8_t signed_value) NONBANKED;
+
+/** Print 8 bit __number__ in __radix__ (base) in the default font at the current text position.
+
+ @see gprintln(), gotogxy()
+*/
+void gprintn(int8_t number, int8_t radix, int8_t signed_value) NONBANKED;
+
+/** Print the string and arguments given by __fmt__ with arguments __...__
+
+ @param fmt The format string as per printf
+ @param ... params
+
+ Currently supported:
+ \li \%c (character)
+ \li \%u (int)
+ \li \%d (int8_t)
+ \li \%o (int8_t as octal)
+ \li \%x (int8_t as hex)
+ \li \%s (string)
+
+ @return Returns the number of items printed, or -1 if there was an error.
+ @see gotogxy()
+*/
+int8_t gprintf(char *fmt,...) NONBANKED;
+
+/** Old style plot - try @ref plot_point() */
+void plot(uint8_t x, uint8_t y, uint8_t colour, uint8_t mode) OLDCALL;
+
+/** Plot a point in the current drawing mode and colour at __x,y__ */
+void plot_point(uint8_t x, uint8_t y) OLDCALL;
+
+/** Exchanges the tile on screen at x,y with the tile pointed by src, original tile
+ is saved in dst. Both src and dst may be NULL - saving or copying to screen is
+ not performed in this case. */
+void switch_data(uint8_t x, uint8_t y, uint8_t *src, uint8_t *dst) OLDCALL;
+
+/** Draw a full screen image at __data__ */
+void draw_image(uint8_t *data) OLDCALL;
+
+/** Draw a line in the current drawing mode and colour from __x1,y1__ to __x2,y2__ */
+void line(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2) OLDCALL;
+
+/** Draw a box (rectangle) with corners __x1,y1__ and __x2,y2__ using fill mode
+ __style__ (one of NOFILL or FILL) */
+void box(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2, uint8_t style) OLDCALL;
+
+/** Draw a circle with centre at __x,y__ and __radius__ using fill mode
+ __style__ (one of NOFILL or FILL)*/
+void circle(uint8_t x, uint8_t y, uint8_t radius, uint8_t style) OLDCALL;
+
+/** Returns the current colour of the pixel at __x,y__ */
+uint8_t getpix(uint8_t x, uint8_t y) OLDCALL;
+
+/** Prints the character __chr__ in the default font at the current text position.
+
+ The current position is advanced by 1 after the character is printed.
+ @see gotogxy() */
+void wrtchr(char chr) OLDCALL;
+
+/** Sets the current text position to __x,y__.
+
+ Note: __x__ and __y__ have units of tiles (8 pixels per unit)
+ @see wrtchr() */
+void gotogxy(uint8_t x, uint8_t y) OLDCALL;
+
+/** Set the current __foreground__ colour (for pixels), __background__ colour, and
+ draw __mode__ */
+void color(uint8_t forecolor, uint8_t backcolor, uint8_t mode) OLDCALL;
+
+#endif /* __DRAWING_H */
diff --git a/gbdk/gbdk-lib/include/gb/emu_debug.h b/gbdk/gbdk-lib/include/gb/emu_debug.h
new file mode 100644
index 00000000..69d76323
--- /dev/null
+++ b/gbdk/gbdk-lib/include/gb/emu_debug.h
@@ -0,0 +1,13 @@
+/** @file gb/emu_debug.h
+
+ Shim for legacy use of @ref gb/emu_debug.h which has been
+ migrated to @ref gbdk/emu_debug.h
+
+ See the `emu_debug` example project included with gbdk.
+*/
+#ifndef __EMU_DEBUG_INCLUDE
+#define __EMU_DEBUG_INCLUDE
+
+#include <gbdk/emu_debug.h>
+
+#endif
diff --git a/gbdk/gbdk-lib/include/gb/gb.h b/gbdk/gbdk-lib/include/gb/gb.h
new file mode 100644
index 00000000..32886588
--- /dev/null
+++ b/gbdk/gbdk-lib/include/gb/gb.h
@@ -0,0 +1,1732 @@
+/** @file gb/gb.h
+ Gameboy specific functions.
+*/
+#ifndef _GB_H
+#define _GB_H
+
+#include <types.h>
+#include <stdint.h>
+#include <gbdk/version.h>
+#include <gb/hardware.h>
+
+#define NINTENDO
+#ifdef SEGA
+#undef SEGA
+#endif
+#if defined(__TARGET_ap)
+#define ANALOGUEPOCKET
+#elif defined(__TARGET_gb)
+#define GAMEBOY
+#elif defined(__TARGET_duck)
+#define MEGADUCK
+#endif
+
+
+/** Joypad bits.
+ A logical OR of these is used in the wait_pad and joypad
+ functions. For example, to see if the B button is pressed
+ try
+
+ uint8_t keys;
+ keys = joypad();
+ if (keys & J_B) {
+ ...
+ }
+
+ @see joypad
+ */
+#define J_UP 0x04U
+#define J_DOWN 0x08U
+#define J_LEFT 0x02U
+#define J_RIGHT 0x01U
+#define J_A 0x10U
+#define J_B 0x20U
+#define J_SELECT 0x40U
+#define J_START 0x80U
+
+/** Screen modes.
+ Normally used by internal functions only.
+ @see mode()
+ */
+#define M_DRAWING 0x01U
+#define M_TEXT_OUT 0x02U
+#define M_TEXT_INOUT 0x03U
+/** Set this in addition to the others to disable scrolling
+
+ If scrolling is disabled, the cursor returns to (0,0)
+ @see mode()
+*/
+#define M_NO_SCROLL 0x04U
+/** Set this to disable interpretation
+ @see mode()
+*/
+#define M_NO_INTERP 0x08U
+
+/** If this is set, sprite colours come from OBJ1PAL. Else
+ they come from OBJ0PAL
+ @see set_sprite_prop().
+*/
+#define S_PALETTE 0x10U
+/** If set the sprite will be flipped horizontally.
+ @see set_sprite_prop()
+ */
+#define S_FLIPX 0x20U
+/** If set the sprite will be flipped vertically.
+ @see set_sprite_prop()
+ */
+#define S_FLIPY 0x40U
+/** If this bit is clear, then the sprite will be displayed
+ on top of the background and window.
+ @see set_sprite_prop()
+*/
+#define S_PRIORITY 0x80U
+
+/* Interrupt flags */
+/** Disable calling of interrupt service routines
+ */
+#define EMPTY_IFLAG 0x00U
+/** VBlank Interrupt occurs at the start of the vertical blank.
+
+ During this period the video ram may be freely accessed.
+ @see set_interrupts(), @see add_VBL
+ */
+#define VBL_IFLAG 0x01U
+/** LCD Interrupt when triggered by the STAT register.
+ @see set_interrupts(), @see add_LCD
+*/
+#define LCD_IFLAG 0x02U
+/** Timer Interrupt when the timer @ref TIMA_REG overflows.
+ @see set_interrupts(), @see add_TIM
+ */
+#define TIM_IFLAG 0x04U
+/** Serial Link Interrupt occurs when the serial transfer has completed.
+ @see set_interrupts(), @see add_SIO
+ */
+#define SIO_IFLAG 0x08U
+/** Joypad Interrupt occurs on a transition of the keypad.
+ @see set_interrupts(), @see add_JOY
+ */
+#define JOY_IFLAG 0x10U
+
+
+/* DMG Palettes */
+#define DMG_BLACK 0x03
+#define DMG_DARK_GRAY 0x02
+#define DMG_LITE_GRAY 0x01
+#define DMG_WHITE 0x00
+/** Macro to create a DMG palette from 4 colors
+
+ @param C0 Color for Index 0
+ @param C1 Color for Index 1
+ @param C2 Color for Index 2
+ @param C3 Color for Index 3
+
+ The resulting format is four greyscale colors
+ packed into a single unsigned byte.
+
+ Example:
+ \code{.c}
+ REG_BGP = DMG_PALETTE(DMG_BLACK, DMG_DARK_GRAY, DMG_LITE_GRAY, DMG_WHITE);
+ \endcode
+
+ @see OBP0_REG, OBP1_REG, BGP_REG
+ @see DMG_BLACK, DMG_DARK_GRAY, DMG_LITE_GRAY, DMG_WHITE
+
+ */
+#define DMG_PALETTE(C0, C1, C2, C3) ((uint8_t)((((C3) & 0x03) << 6) | (((C2) & 0x03) << 4) | (((C1) & 0x03) << 2) | ((C0) & 0x03)))
+
+/* Limits */
+/** Width of the visible screen in pixels.
+ */
+#define SCREENWIDTH DEVICE_SCREEN_PX_WIDTH
+/** Height of the visible screen in pixels.
+ */
+#define SCREENHEIGHT DEVICE_SCREEN_PX_HEIGHT
+/** The Minimum X position of the Window Layer (Left edge of screen) @see move_win()
+ */
+#define MINWNDPOSX 0x07U
+/** The Minimum Y position of the Window Layer (Top edge of screen) @see move_win()
+ */
+#define MINWNDPOSY 0x00U
+/** The Maximum X position of the Window Layer (Right edge of screen) @see move_win()
+ */
+#define MAXWNDPOSX 0xA6U
+/** The Maximum Y position of the Window Layer (Bottom edge of screen) @see move_win()
+ */
+#define MAXWNDPOSY 0x8FU
+
+
+/** Interrupt handlers
+ */
+typedef void (*int_handler)(void) NONBANKED;
+
+/** The remove functions will remove any interrupt handler.
+
+ A handler of NULL will cause bad things
+ to happen if the given interrupt is enabled.
+
+ Removes the VBL interrupt handler. @see add_VBL()
+*/
+void remove_VBL(int_handler h) OLDCALL;
+
+/** Removes the LCD interrupt handler.
+ @see add_LCD(), remove_VBL()
+*/
+void remove_LCD(int_handler h) OLDCALL;
+
+/** Removes the TIM interrupt handler.
+ @see add_TIM(), remove_VBL()
+*/
+void remove_TIM(int_handler h) OLDCALL;
+
+/** Removes the Serial Link / SIO interrupt handler.
+ @see add_SIO(), @see remove_VBL()
+
+ The default SIO ISR gets installed automatically if
+ any of the standard SIO calls are used. These calls
+ include @ref add_SIO(), @ref remove_SIO(),
+ @ref send_byte(), @ref receive_byte().
+
+ The default SIO ISR cannot be removed once installed.
+ Only secondary chained SIO ISRs (added with @ref add_SIO() )
+ can be removed.
+*/
+void remove_SIO(int_handler h) OLDCALL;
+
+/** Removes the JOY interrupt handler.
+ @see add_JOY(), remove_VBL()
+*/
+void remove_JOY(int_handler h) OLDCALL;
+
+/** Adds a V-blank interrupt handler.
+
+ @param h The handler to be called whenever a V-blank
+ interrupt occurs.
+
+ Up to 4 handlers may be added, with the last added being
+ called last. If the @ref remove_VBL function is to be called,
+ only three may be added.
+
+ Do not use @ref CRITICAL and @ref INTERRUPT attributes for a
+ function added via add_VBL() (or LCD, etc). The attributes
+ are only required when constructing a bare jump from the
+ interrupt vector itself.
+
+ Note: The default VBL is installed automatically.
+*/
+void add_VBL(int_handler h) OLDCALL;
+
+/** Adds a LCD interrupt handler.
+
+ Called when the LCD interrupt occurs, which is normally
+ when @ref LY_REG == @ref LYC_REG.
+
+ There are various reasons for this interrupt to occur
+ as described by the @ref STAT_REG register ($FF41). One very
+ popular reason is to indicate to the user when the
+ video hardware is about to redraw a given LCD line.
+ This can be useful for dynamically controlling the
+ @ref SCX_REG / @ref SCY_REG registers ($FF43/$FF42) to perform
+ special video effects.
+
+ @see add_VBL
+*/
+void add_LCD(int_handler h) OLDCALL;
+
+/** Adds a timer interrupt handler.
+
+ Can not be used together with @ref add_low_priority_TIM
+
+ This interrupt occurs when the @ref TIMA_REG
+ register ($FF05) changes from $FF to $00.
+
+ @see add_VBL
+ @see set_interrupts() with TIM_IFLAG
+*/
+void add_TIM(int_handler h) OLDCALL;
+
+/** Adds a timer interrupt handler, that could be
+ interrupted by the other interrupts,
+ as well as itself, if it runs too slow.
+
+ Can not be used together with @ref add_TIM
+
+ This interrupt occurs when the @ref TIMA_REG
+ register ($FF05) changes from $FF to $00.
+
+ @see add_VBL
+ @see set_interrupts() with TIM_IFLAG
+*/
+void add_low_priority_TIM(int_handler h) OLDCALL;
+
+/** Adds a Serial Link transmit complete interrupt handler.
+
+ This interrupt occurs when a serial transfer has
+ completed on the game link port.
+
+ @see send_byte, receive_byte(), add_VBL()
+ @see set_interrupts() with SIO_IFLAG
+*/
+void add_SIO(int_handler h) OLDCALL;
+
+
+/** Adds a joypad button change interrupt handler.
+
+ This interrupt occurs on a transition of any of the
+ keypad input lines from high to low. Due to the fact
+ that keypad "bounce" is virtually always present,
+ software should expect this interrupt to occur one
+ or more times for every button press and one or more
+ times for every button release.
+
+ @see joypad(), add_VBL()
+*/
+void add_JOY(int_handler h) OLDCALL;
+
+
+/** Interrupt handler chain terminator that does __not__ wait for .STAT
+
+ You must add this handler last in every interrupt handler
+ chain if you want to change the default interrupt handler
+ behaviour that waits for LCD controller mode to become 1 or 0
+ before return from the interrupt.
+
+ Example:
+ \code{.c}
+ CRITICAL {
+ add_SIO(nowait_int_handler); // Disable wait on VRAM state before returning from SIO interrupt
+ }
+ \endcode
+ @see wait_int_handler()
+*/
+void nowait_int_handler();
+
+
+/** Default Interrupt handler chain terminator that waits for
+ @see STAT_REG and __only__ returns at the BEGINNING of
+ either Mode 0 or Mode 1.
+
+ Used by default at the end of interrupt chains to help
+ prevent graphical glitches. The glitches are caused when an
+ ISR interrupts a graphics operation in one mode but returns
+ in a different mode for which that graphics operation is not
+ allowed.
+
+ @see nowait_int_handler()
+*/
+void wait_int_handler();
+
+/** Cancel pending interrupts
+ */
+inline uint8_t cancel_pending_interrupts() {
+ return IF_REG = 0;
+}
+
+/** Set the current screen mode - one of M_* modes
+
+ Normally used by internal functions only.
+
+ @see M_DRAWING, M_TEXT_OUT, M_TEXT_INOUT, M_NO_SCROLL, M_NO_INTERP
+*/
+void mode(uint8_t m) OLDCALL;
+
+/** Returns the current mode
+
+ @see M_DRAWING, M_TEXT_OUT, M_TEXT_INOUT, M_NO_SCROLL, M_NO_INTERP
+*/
+uint8_t get_mode() OLDCALL PRESERVES_REGS(b, c);
+
+/** GB CPU type
+
+ @see DMG_TYPE, MGB_TYPE, CGB_TYPE, cpu_fast(), cpu_slow(), _is_GBA
+*/
+extern uint8_t _cpu;
+
+/** Hardware Model: Original GB or Super GB. @see _cpu
+*/
+#define DMG_TYPE 0x01
+/** Hardware Model: Pocket GB or Super GB 2. @see _cpu
+*/
+#define MGB_TYPE 0xFF
+/** Hardware Model: Color GB. @see _cpu
+*/
+#define CGB_TYPE 0x11
+
+/** GBA detection
+
+ @see GBA_DETECTED, GBA_NOT_DETECTED, _cpu
+*/
+extern uint8_t _is_GBA;
+
+/** Hardware Model: DMG, CGB or MGB. @see _cpu, _is_GBA
+*/
+#define GBA_NOT_DETECTED 0x00
+/** Hardware Model: GBA. @see _cpu, _is_GBA
+*/
+#define GBA_DETECTED 0x01
+
+/** Macro returns TRUE if device supports color
+ */
+#define DEVICE_SUPPORTS_COLOR (_cpu == CGB_TYPE)
+
+/** Global Time Counter in VBL periods (60Hz)
+
+ Increments once per Frame
+
+ Will wrap around every ~18 minutes (unsigned 16 bits = 65535 / 60 / 60 = 18.2)
+*/
+extern volatile uint16_t sys_time;
+
+
+
+/** Serial Link: Send the byte in @ref _io_out out through the serial port
+
+ Make sure to enable interrupts for the
+ Serial Link before trying to transfer data.
+ @see add_SIO(), remove_SIO()
+ @see set_interrupts() with @ref SIO_IFLAG
+*/
+void send_byte();
+
+/** Serial Link: Receive a byte from the serial port into @ref _io_in
+
+ Make sure to enable interrupts for the
+ Serial Link before trying to transfer data.
+ @see add_SIO(), remove_SIO()
+ @see set_interrupts() with @ref SIO_IFLAG
+*/
+void receive_byte();
+
+/** Serial Link: Current IO Status. An OR of IO_* */
+extern volatile uint8_t _io_status;
+
+/** Serial Link: Byte just read after calling @ref receive_byte()
+*/
+extern volatile uint8_t _io_in;
+
+/** Serial Link: Write byte to send here before calling @ref send_byte()
+*/
+extern volatile uint8_t _io_out;
+
+/* Status codes */
+/** Serial Link IO is completed */
+#define IO_IDLE 0x00U
+/** Serial Link Sending data */
+#define IO_SENDING 0x01U
+/** Serial Link Receiving data */
+#define IO_RECEIVING 0x02U
+/** Serial Link Error */
+#define IO_ERROR 0x04U
+
+
+
+/** Tracks current active ROM bank @see SWITCH_ROM_MBC1(), SWITCH_ROM_MBC5()
+ This variable is updated automatically when you call SWITCH_ROM_MBC1 or
+ SWITCH_ROM_MBC5, or call a BANKED function.
+*/
+__REG _current_bank;
+#define CURRENT_BANK _current_bank
+
+/** Obtains the __bank number__ of VARNAME
+
+ @param VARNAME Name of the variable which has a __bank_VARNAME companion symbol which is adjusted by bankpack
+
+ Use this to obtain the bank number from a bank reference
+ created with @ref BANKREF().
+
+ @see BANKREF_EXTERN(), BANKREF()
+*/
+#ifndef BANK
+#define BANK(VARNAME) ( (uint8_t) & __bank_ ## VARNAME )
+#endif
+
+/** Creates a reference for retrieving the bank number of a variable or function
+
+ @param VARNAME Variable name to use, which may be an existing identifier
+
+ @see BANK() for obtaining the bank number of the included data.
+
+ More than one `BANKREF()` may be created per file, but each call should
+ always use a unique VARNAME.
+
+ Use @ref BANKREF_EXTERN() within another source file
+ to make the variable and it's data accesible there.
+*/
+#define BANKREF(VARNAME) void __func_ ## VARNAME() __banked __naked { \
+__asm \
+ .local b___func_ ## VARNAME \
+ ___bank_ ## VARNAME = b___func_ ## VARNAME \
+ .globl ___bank_ ## VARNAME \
+__endasm; \
+}
+
+/** Creates extern references for accessing a BANKREF() generated variable.
+
+ @param VARNAME Name of the variable used with @ref BANKREF()
+
+ This makes a @ref BANKREF() reference in another source
+ file accessible in the current file for use with @ref BANK().
+
+ @see BANKREF(), BANK()
+*/
+#define BANKREF_EXTERN(VARNAME) extern const void __bank_ ## VARNAME;
+
+/** Makes MEGADUCK MBC switch the active ROM bank
+ @param b ROM bank to switch to
+*/
+#define SWITCH_ROM_MEGADUCK(b) \
+ _current_bank = (b), *(uint8_t *)0x0001 = (b)
+
+
+/** Makes MBC1 and other compatible MBCs switch the active ROM bank
+ @param b ROM bank to switch to
+*/
+#define SWITCH_ROM_MBC1(b) \
+ _current_bank = (b), *(uint8_t *)0x2000 = (b)
+
+/** Makes default platform MBC switch the active ROM bank
+ @param b ROM bank to switch to (max 255)
+
+ @see SWITCH_ROM_MBC1, SWITCH_ROM_MBC5, SWITCH_ROM_MEGADUCK
+*/
+#if defined(__TARGET_duck)
+#define SWITCH_ROM SWITCH_ROM_MEGADUCK
+#else
+#define SWITCH_ROM SWITCH_ROM_MBC1
+#endif
+
+/** Switches SRAM bank on MBC1 and other compaticle MBCs
+ @param b SRAM bank to switch to
+*/
+#define SWITCH_RAM_MBC1(b) \
+ *(uint8_t *)0x4000 = (b)
+
+/** Switches SRAM bank on MBC1 and other compaticle MBCs
+ @param b SRAM bank to switch to
+
+ @see SWITCH_RAM_MBC1, SWITCH_RAM_MBC5
+*/
+#define SWITCH_RAM SWITCH_RAM_MBC1
+
+/** Enables SRAM on MBC1
+*/
+#define ENABLE_RAM_MBC1 \
+ *(uint8_t *)0x0000 = 0x0A
+
+#define ENABLE_RAM ENABLE_RAM_MBC1
+
+/** Disables SRAM on MBC1
+*/
+#define DISABLE_RAM_MBC1 \
+ *(uint8_t *)0x0000 = 0x00
+
+#define DISABLE_RAM DISABLE_RAM_MBC1
+
+#define SWITCH_16_8_MODE_MBC1 \
+ *(uint8_t *)0x6000 = 0x00
+
+#define SWITCH_4_32_MODE_MBC1 \
+ *(uint8_t *)0x6000 = 0x01
+
+/** Makes MBC5 switch to the active ROM bank; only 4M roms are supported, @see SWITCH_ROM_MBC5_8M()
+ @param b ROM bank to switch to
+
+ Note the order used here. Writing the other way around on a MBC1 always selects bank 1
+*/
+#define SWITCH_ROM_MBC5(b) \
+ _current_bank = (b), \
+ *(uint8_t *)0x3000 = 0, \
+ *(uint8_t *)0x2000 = (b)
+
+/** Makes MBC5 to switch the active ROM bank; active bank number is not tracked by _current_bank if you use this macro
+ @see _current_bank
+ @param b ROM bank to switch to
+
+ Note the order used here. Writing the other way around on a MBC1 always selects bank 1
+*/
+#define SWITCH_ROM_MBC5_8M(b) \
+ *(uint8_t *)0x3000 = ((uint16_t)(b) >> 8), \
+ *(uint8_t *)0x2000 = (b)
+
+/** Switches SRAM bank on MBC5
+ @param b SRAM bank to switch to
+*/
+#define SWITCH_RAM_MBC5(b) \
+ *(uint8_t *)0x4000 = (b)
+
+/** Enables SRAM on MBC5
+*/
+#define ENABLE_RAM_MBC5 \
+ *(uint8_t *)0x0000 = 0x0A
+
+/** Disables SRAM on MBC5
+*/
+#define DISABLE_RAM_MBC5 \
+ *(uint8_t *)0x0000 = 0x00
+
+
+
+/** Delays the given number of milliseconds.
+ Uses no timers or interrupts, and can be called with
+ interrupts disabled
+ */
+void delay(uint16_t d) OLDCALL;
+
+
+
+/** Reads and returns the current state of the joypad.
+ Follows Nintendo's guidelines for reading the pad.
+ Return value is an OR of J_*
+
+ When testing for multiple different buttons, it's
+ best to read the joypad state *once* into a variable
+ and then test using that variable.
+
+ @see J_START, J_SELECT, J_A, J_B, J_UP, J_DOWN, J_LEFT, J_RIGHT
+*/
+uint8_t joypad() OLDCALL PRESERVES_REGS(b, c, h, l);
+
+/** Waits until at least one of the buttons given in mask are pressed.
+
+ @param mask Bitmask indicating which buttons to wait for
+
+ Normally only used for checking one key, but it will
+ support many, even J_LEFT at the same time as J_RIGHT. :)
+
+ Note: Checks in a loop that doesn't HALT at all, so the CPU
+ will be maxed out until this call returns.
+ @see joypad
+ @see J_START, J_SELECT, J_A, J_B, J_UP, J_DOWN, J_LEFT, J_RIGHT
+*/
+uint8_t waitpad(uint8_t mask) OLDCALL PRESERVES_REGS(b, c);
+
+/** Waits for the directional pad and all buttons to be released.
+
+ Note: Checks in a loop that doesn't HALT at all, so the CPU
+ will be maxed out until this call returns.
+*/
+void waitpadup() PRESERVES_REGS(a, b, c, d, e, h, l);
+
+/** Multiplayer joypad structure.
+
+ Must be initialized with @ref joypad_init() first then it
+ may be used to poll all avaliable joypads with @ref joypad_ex()
+*/
+typedef struct {
+ uint8_t npads;
+ union {
+ struct {
+ uint8_t joy0, joy1, joy2, joy3;
+ };
+ uint8_t joypads[4];
+ };
+} joypads_t;
+
+/** Initializes joypads_t structure for polling multiple joypads
+ (for the GB and ones connected via SGB)
+ @param npads number of joypads requested (1, 2 or 4)
+ @param joypads pointer to joypads_t structure to be initialized
+
+ Only required for @ref joypad_ex, not required for calls to regular @ref joypad()
+ @returns number of joypads avaliable
+ @see joypad_ex(), joypads_t
+*/
+uint8_t joypad_init(uint8_t npads, joypads_t * joypads) OLDCALL;
+
+/** Polls all avaliable joypads (for the GB and ones connected via SGB)
+ @param joypads pointer to joypads_t structure to be filled with joypad statuses,
+ must be previously initialized with joypad_init()
+
+ @see joypad_init(), joypads_t
+*/
+void joypad_ex(joypads_t * joypads) OLDCALL PRESERVES_REGS(b, c);
+
+
+
+/** Enables unmasked interrupts
+
+ @note Use @ref CRITICAL {...} instead for creating a block of
+ of code which should execute with interrupts temporarily
+ turned off.
+
+ @see disable_interrupts, set_interrupts, CRITICAL
+*/
+inline void enable_interrupts() PRESERVES_REGS(a, b, c, d, e, h, l) {
+ __asm__("ei");
+}
+
+/** Disables interrupts
+
+ @note Use @ref CRITICAL {...} instead for creating a block of
+ of code which should execute with interrupts temporarily
+ turned off.
+
+ This function may be called as many times as you like;
+ however the first call to @ref enable_interrupts will re-enable
+ them.
+
+ @see enable_interrupts, set_interrupts, CRITICAL
+*/
+inline void disable_interrupts() PRESERVES_REGS(a, b, c, d, e, h, l) {
+ __asm__("di");
+}
+
+/** Clears any pending interrupts and sets the interrupt mask
+ register IO to flags.
+ @param flags A logical OR of *_IFLAGS
+
+ @note: This disables and then re-enables interrupts so it
+ must be used outside of a critical section.
+
+ @see enable_interrupts(), disable_interrupts()
+ @see VBL_IFLAG, LCD_IFLAG, TIM_IFLAG, SIO_IFLAG, JOY_IFLAG
+*/
+void set_interrupts(uint8_t flags) OLDCALL PRESERVES_REGS(b, c, d, e);
+
+/** Performs a warm reset by reloading the CPU value
+ then jumping to the start of crt0 (0x0150)
+*/
+void reset();
+
+/** HALTs the CPU and waits for the vertical blank interrupt (VBL) to finish.
+
+ This is often used in main loops to idle the CPU at low power
+ until it's time to start the next frame. It's also useful for
+ syncing animation with the screen re-draw.
+
+ Warning: If the VBL interrupt is disabled, this function will
+ never return. If the screen is off this function returns
+ immediately.
+*/
+void wait_vbl_done() PRESERVES_REGS(b, c, d, e, h, l);
+
+/** Turns the display off.
+
+ Waits until the VBL interrupt before turning the display off.
+ @see DISPLAY_ON
+*/
+void display_off() PRESERVES_REGS(b, c, d, e, h, l);
+
+/** Copies data from shadow OAM to OAM
+ */
+void refresh_OAM() PRESERVES_REGS(b, c, d, e, h, l);
+
+
+/** Copies data from somewhere in the lower address space to part of hi-ram.
+ @param dst Offset in high ram (0xFF00 and above) to copy to.
+ @param src Area to copy from
+ @param n Number of bytes to copy.
+*/
+void hiramcpy(uint8_t dst, const void *src, uint8_t n) OLDCALL PRESERVES_REGS(b, c);
+
+
+/** Turns the display back on.
+ @see display_off, DISPLAY_OFF
+*/
+#define DISPLAY_ON \
+ LCDC_REG|=LCDCF_ON
+
+/** Turns the display off immediately.
+ @see display_off, DISPLAY_ON
+*/
+#define DISPLAY_OFF \
+ display_off();
+
+/** Does nothing for GB
+ */
+#define HIDE_LEFT_COLUMN
+
+/** Does nothing for GB
+ */
+#define SHOW_LEFT_COLUMN
+
+/** Turns on the background layer.
+ Sets bit 0 of the LCDC register to 1.
+*/
+#define SHOW_BKG \
+ LCDC_REG|=LCDCF_BGON
+
+/** Turns off the background layer.
+ Sets bit 0 of the LCDC register to 0.
+*/
+#define HIDE_BKG \
+ LCDC_REG&=~LCDCF_BGON
+
+/** Turns on the window layer
+ Sets bit 5 of the LCDC register to 1.
+*/
+#define SHOW_WIN \
+ LCDC_REG|=LCDCF_WINON
+
+/** Turns off the window layer.
+ Clears bit 5 of the LCDC register to 0.
+*/
+#define HIDE_WIN \
+ LCDC_REG&=~LCDCF_WINON
+
+/** Turns on the sprites layer.
+ Sets bit 1 of the LCDC register to 1.
+*/
+#define SHOW_SPRITES \
+ LCDC_REG|=LCDCF_OBJON
+
+/** Turns off the sprites layer.
+ Clears bit 1 of the LCDC register to 0.
+*/
+#define HIDE_SPRITES \
+ LCDC_REG&=~LCDCF_OBJON
+
+/** Sets sprite size to 8x16 pixels, two tiles one above the other.
+ Sets bit 2 of the LCDC register to 1.
+*/
+#define SPRITES_8x16 \
+ LCDC_REG|=LCDCF_OBJ16
+
+/** Sets sprite size to 8x8 pixels, one tile.
+ Clears bit 2 of the LCDC register to 0.
+*/
+#define SPRITES_8x8 \
+ LCDC_REG&=~LCDCF_OBJ16
+
+
+
+/**
+ * Set byte in vram at given memory location
+ *
+ * @param addr address to write to
+ * @param v value
+ */
+void set_vram_byte(uint8_t * addr, uint8_t v) OLDCALL PRESERVES_REGS(b, c);
+
+/**
+ * Get byte from vram at given memory location
+ *
+ * @param addr address to read from
+ * @return read value
+ */
+uint8_t get_vram_byte(uint8_t * addr) OLDCALL PRESERVES_REGS(b, c);
+
+
+/**
+ * Get address of X,Y tile of background map
+ */
+uint8_t * get_bkg_xy_addr(uint8_t x, uint8_t y) OLDCALL PRESERVES_REGS(b, c);
+
+#define COMPAT_PALETTE(C0,C1,C2,C3) ((uint8_t)(((C3) << 6) | ((C2) << 4) | ((C1) << 2) | (C0)))
+
+/** Sets palette for 2bpp color translation for GG/SMS, does nothing on GB
+ */
+inline void set_2bpp_palette(uint16_t palette) {
+ palette;
+}
+
+extern uint16_t _current_1bpp_colors;
+void set_1bpp_colors_ex(uint8_t fgcolor, uint8_t bgcolor, uint8_t mode) OLDCALL;
+inline void set_1bpp_colors(uint8_t fgcolor, uint8_t bgcolor) {
+ set_1bpp_colors_ex(fgcolor, bgcolor, 0);
+}
+
+/** Sets VRAM Tile Pattern data for the Background / Window
+
+ @param first_tile Index of the first tile to write
+ @param nb_tiles Number of tiles to write
+ @param data Pointer to (2 bpp) source tile data
+
+ Writes __nb_tiles__ tiles to VRAM starting at __first_tile__, tile data
+ is sourced from __data__. Each Tile is 16 bytes in size (8x8 pixels, 2 bits-per-pixel).
+
+ Note: Sprite Tiles 128-255 share the same memory region as Background Tiles 128-255.
+
+ GBC only: @ref VBK_REG determines which bank of Background tile patterns are written to.
+ \li VBK_REG=0 indicates the first bank
+ \li VBK_REG=1 indicates the second
+
+ @see set_win_data, set_tile_data
+*/
+void set_bkg_data(uint8_t first_tile, uint8_t nb_tiles, const uint8_t *data) OLDCALL PRESERVES_REGS(b, c);
+#define set_bkg_2bpp_data set_bkg_data
+
+/** Sets VRAM Tile Pattern data for the Background / Window using 1bpp source data
+
+ @param first_tile Index of the first Tile to write
+ @param nb_tiles Number of Tiles to write
+ @param data Pointer to (1bpp) source Tile Pattern data
+
+ Similar to @ref set_bkg_data, except source data is 1 bit-per-pixel
+ which gets expanded into 2 bits-per-pixel.
+
+ For a given bit that represent a pixel:
+ \li 0 will be expanded into color 0
+ \li 1 will be expanded into color 1, 2 or 3 depending on color argument
+
+ @see SHOW_BKG, HIDE_BKG, set_bkg_tiles
+*/
+void set_bkg_1bpp_data(uint8_t first_tile, uint8_t nb_tiles, const uint8_t *data) OLDCALL PRESERVES_REGS(b, c);
+
+/** Copies from Background / Window VRAM Tile Pattern data into a buffer
+
+ @param first_tile Index of the first Tile to read from
+ @param nb_tiles Number of Tiles to read
+ @param data Pointer to destination buffer for Tile Pattern data
+
+ Copies __nb_tiles__ tiles from VRAM starting at __first_tile__, Tile data
+ is copied into __data__.
+
+ Each Tile is 16 bytes, so the buffer pointed to by __data__
+ should be at least __nb_tiles__ x 16 bytes in size.
+
+ @see get_win_data, get_data
+*/
+void get_bkg_data(uint8_t first_tile, uint8_t nb_tiles, uint8_t *data) OLDCALL PRESERVES_REGS(b, c);
+
+
+/** Sets a rectangular region of Background Tile Map.
+
+ @param x X Start position in Background Map tile coordinates. Range 0 - 31
+ @param y Y Start position in Background Map tile coordinates. Range 0 - 31
+ @param w Width of area to set in tiles. Range 1 - 32
+ @param h Height of area to set in tiles. Range 1 - 32
+ @param tiles Pointer to source tile map data
+
+ Entries are copied from map at __tiles__ to the Background Tile Map starting at
+ __x__, __y__ writing across for __w__ tiles and down for __h__ tiles.
+
+ Use @ref set_bkg_submap() instead when:
+ \li Source map is wider than 32 tiles.
+ \li Writing a width that does not match the source map width __and__ more
+ than one row high at a time.
+
+ One byte per source tile map entry.
+
+ Writes that exceed coordinate 31 on the x or y axis will wrap around to
+ the Left and Top edges.
+
+ Note: Patterns 128-255 overlap with patterns 128-255 of the sprite Tile Pattern table.
+
+ GBC only: @ref VBK_REG determines whether Tile Numbers or Tile Attributes get set.
+ \li VBK_REG=0 Tile Numbers are written
+ \li VBK_REG=1 Tile Attributes are written
+
+ GBC Tile Attributes are defined as:
+ \li Bit 7 - Priority flag. When this is set, it puts the tile above the sprites
+ with colour 0 being transparent.
+ \n 0: Below sprites
+ \n 1: Above sprites
+ \n Note: @ref SHOW_BKG needs to be set for these priorities to take place.
+ \li Bit 6 - Vertical flip. Dictates which way up the tile is drawn vertically.
+ \n 0: Normal
+ \n 1: Flipped Vertically
+ \li Bit 5 - Horizontal flip. Dictates which way up the tile is drawn horizontally.
+ \n 0: Normal
+ \n 1: Flipped Horizontally
+ \li Bit 4 - Not used
+ \li Bit 3 - Character Bank specification. Dictates from which bank of
+ Background Tile Patterns the tile is taken.
+ \n 0: Bank 0
+ \n 1: Bank 1
+ \li Bit 2 - See bit 0.
+ \li Bit 1 - See bit 0.
+ \li Bit 0 - Bits 0-2 indicate which of the 7 BKG colour palettes the tile is
+ assigned.
+
+ @see SHOW_BKG
+ @see set_bkg_data, set_bkg_submap, set_win_tiles, set_tiles
+*/
+void set_bkg_tiles(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *tiles) OLDCALL PRESERVES_REGS(b, c);
+#define set_tile_map set_bkg_tiles
+
+
+extern uint8_t _map_tile_offset;
+
+/** Sets a rectangular region of Background Tile Map.
+ The offset value in __base_tile__ is added to
+ the tile ID for each map entry.
+
+ @param x X Start position in Background Map tile coordinates. Range 0 - 31
+ @param y Y Start position in Background Map tile coordinates. Range 0 - 31
+ @param w Width of area to set in tiles. Range 1 - 32
+ @param h Height of area to set in tiles. Range 1 - 32
+ @param tiles Pointer to source tile map data
+ @param base_tile Offset each tile ID entry of the source map by this value. Range 1 - 255
+
+ This is identical to @ref set_bkg_tiles() except that it
+ adds the __base_tile__ parameter for when a tile map's tiles don't
+ start at index zero. (For example, the tiles used by the map
+ range from 100 -> 120 in VRAM instead of 0 -> 20).
+
+ @see set_bkg_tiles for more details
+*/
+inline void set_bkg_based_tiles(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *tiles, uint8_t base_tile) {
+ _map_tile_offset = base_tile;
+ set_bkg_tiles(x, y, w, h, tiles);
+ _map_tile_offset = 0;
+}
+
+
+/** Sets a rectangular area of the Background Tile Map using a sub-region
+ from a source tile map. Useful for scrolling implementations of maps
+ larger than 32 x 32 tiles.
+
+ @param x X Start position in Background Map tile coordinates. Range 0 - 31
+ @param y Y Start position in Background Map tile coordinates. Range 0 - 31
+ @param w Width of area to set in tiles. Range 1 - 255
+ @param h Height of area to set in tiles. Range 1 - 255
+ @param map Pointer to source tile map data
+ @param map_w Width of source tile map in tiles. Range 1 - 255
+
+ Entries are copied from __map__ to the Background Tile Map starting at
+ __x__, __y__ writing across for __w__ tiles and down for __h__ tiles,
+ using __map_w__ as the rowstride for the source tile map.
+
+ Use this instead of @ref set_bkg_tiles when the source map is wider than
+ 32 tiles or when writing a width that does not match the source map width.
+
+ One byte per source tile map entry.
+
+ Writes that exceed coordinate 31 on the x or y axis will wrap around to
+ the Left and Top edges.
+
+ See @ref set_bkg_tiles for setting CGB attribute maps with @ref VBK_REG.
+
+ @see SHOW_BKG
+ @see set_bkg_data, set_bkg_tiles, set_win_submap, set_tiles
+*/
+void set_bkg_submap(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *map, uint8_t map_w) OLDCALL;
+#define set_tile_submap set_bkg_submap
+
+
+extern uint8_t _submap_tile_offset;
+
+/** Sets a rectangular area of the Background Tile Map using a sub-region
+ from a source tile map. The offset value in __base_tile__ is added to
+ the tile ID for each map entry.
+
+ @param x X Start position in Background Map tile coordinates. Range 0 - 31
+ @param y Y Start position in Background Map tile coordinates. Range 0 - 31
+ @param w Width of area to set in tiles. Range 1 - 255
+ @param h Height of area to set in tiles. Range 1 - 255
+ @param map Pointer to source tile map data
+ @param map_w Width of source tile map in tiles. Range 1 - 255
+ @param base_tile Offset each tile ID entry of the source map by this value. Range 1 - 255
+
+ This is identical to @ref set_bkg_based_submap() except that it
+ adds the __base_tile__ parameter for when a tile map's tiles don't
+ start at index zero. (For example, the tiles used by the map
+ range from 100 -> 120 in VRAM instead of 0 -> 20).
+
+ @see set_bkg_based_submap for more details
+*/
+inline void set_bkg_based_submap(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *map, uint8_t map_w, uint8_t base_tile) {
+ _submap_tile_offset = base_tile;
+ set_bkg_submap(x, y, w, h, map, map_w);
+ _submap_tile_offset = 0;
+}
+
+
+/** Copies a rectangular region of Background Tile Map entries into a buffer.
+
+ @param x X Start position in Background Map tile coordinates. Range 0 - 31
+ @param y Y Start position in Background Map tile coordinates. Range 0 - 31
+ @param w Width of area to copy in tiles. Range 0 - 31
+ @param h Height of area to copy in tiles. Range 0 - 31
+ @param tiles Pointer to destination buffer for Tile Map data
+
+
+ Entries are copied into __tiles__ from the Background Tile Map starting at
+ __x__, __y__ reading across for __w__ tiles and down for __h__ tiles.
+
+ One byte per tile.
+
+ The buffer pointed to by __tiles__ should be at least __x__ x __y__ bytes in size.
+
+ @see get_win_tiles, get_bkg_tile_xy, get_tiles, get_vram_byte
+*/
+void get_bkg_tiles(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t *tiles) OLDCALL PRESERVES_REGS(b, c);
+
+
+/**
+ * Set single tile t on background layer at x,y
+ * @param x X-coordinate
+ * @param y Y-coordinate
+ * @param t tile index
+ * @return returns the address of tile, so you may use faster set_vram_byte() later
+ */
+uint8_t * set_bkg_tile_xy(uint8_t x, uint8_t y, uint8_t t) OLDCALL PRESERVES_REGS(b, c);
+#define set_tile_xy set_bkg_tile_xy
+
+/**
+ * Get single tile t on background layer at x,y
+ * @param x X-coordinate
+ * @param y Y-coordinate
+ * @return returns tile index
+ */
+uint8_t get_bkg_tile_xy(uint8_t x, uint8_t y) OLDCALL PRESERVES_REGS(b, c);
+
+
+/** Moves the Background Layer to the position specified in __x__ and __y__ in pixels.
+
+ @param x X axis screen coordinate for Left edge of the Background
+ @param y Y axis screen coordinate for Top edge of the Background
+
+ 0,0 is the top left corner of the GB screen. The Background Layer wraps around the screen,
+ so when part of it goes off the screen it appears on the opposite side (factoring in the
+ larger size of the Background Layer versus the screen size).
+
+ The background layer is always under the Window Layer.
+
+ @see SHOW_BKG, HIDE_BKG
+*/
+inline void move_bkg(uint8_t x, uint8_t y) {
+ SCX_REG=x, SCY_REG=y;
+}
+
+
+/** Moves the Background relative to it's current position.
+
+ @param x Number of pixels to move the Background on the __X axis__
+ \n Range: -128 - 127
+ @param y Number of pixels to move the Background on the __Y axis__
+ \n Range: -128 - 127
+
+ @see move_bkg
+*/
+inline void scroll_bkg(int8_t x, int8_t y) {
+ SCX_REG+=x, SCY_REG+=y;
+}
+
+
+
+/**
+ * Get address of X,Y tile of window map
+ */
+uint8_t * get_win_xy_addr(uint8_t x, uint8_t y) OLDCALL PRESERVES_REGS(b, c);
+
+/** Sets VRAM Tile Pattern data for the Window / Background
+
+ @param first_tile Index of the first tile to write
+ @param nb_tiles Number of tiles to write
+ @param data Pointer to (2 bpp) source Tile Pattern data.
+
+ This is the same as @ref set_bkg_data, since the Window Layer and
+ Background Layer share the same Tile pattern data.
+
+ @see set_bkg_data
+ @see set_win_tiles, set_bkg_data, set_data
+ @see SHOW_WIN, HIDE_WIN
+*/
+void set_win_data(uint8_t first_tile, uint8_t nb_tiles, const uint8_t *data) OLDCALL PRESERVES_REGS(b, c);
+
+
+/** Sets VRAM Tile Pattern data for the Window / Background using 1bpp source data
+
+ @param first_tile Index of the first tile to write
+ @param nb_tiles Number of tiles to write
+ @param data Pointer to (1bpp) source Tile Pattern data
+
+ This is the same as @ref set_bkg_1bpp_data, since the Window Layer and
+ Background Layer share the same Tile pattern data.
+
+ @see set_bkg_data, set_bkg_1bpp_data, set_win_data
+*/
+void set_win_1bpp_data(uint8_t first_tile, uint8_t nb_tiles, const uint8_t *data) OLDCALL PRESERVES_REGS(b, c);
+
+
+/** Copies from Window / Background VRAM Tile Pattern data into a buffer
+
+ @param first_tile Index of the first Tile to read from
+ @param nb_tiles Number of Tiles to read
+ @param data Pointer to destination buffer for Tile Pattern Data
+
+ This is the same as @ref get_bkg_data, since the Window Layer and
+ Background Layer share the same Tile pattern data.
+
+ @see get_bkg_data, get_data
+*/
+void get_win_data(uint8_t first_tile, uint8_t nb_tiles, uint8_t *data) OLDCALL PRESERVES_REGS(b, c);
+
+
+/** Sets a rectangular region of the Window Tile Map.
+
+ @param x X Start position in Window Map tile coordinates. Range 0 - 31
+ @param y Y Start position in Window Map tile coordinates. Range 0 - 31
+ @param w Width of area to set in tiles. Range 1 - 32
+ @param h Height of area to set in tiles. Range 1 - 32
+ @param tiles Pointer to source tile map data
+
+ Entries are copied from map at __tiles__ to the Window Tile Map starting at
+ __x__, __y__ writing across for __w__ tiles and down for __h__ tiles.
+
+ Use @ref set_win_submap() instead when:
+ \li Source map is wider than 32 tiles.
+ \li Writing a width that does not match the source map width __and__ more
+ than one row high at a time.
+
+ One byte per source tile map entry.
+
+ Writes that exceed coordinate 31 on the x or y axis will wrap around to
+ the Left and Top edges.
+
+ Note: Patterns 128-255 overlap with patterns 128-255 of the sprite Tile Pattern table.
+
+ GBC only: @ref VBK_REG determines whether Tile Numbers or Tile Attributes get set.
+ \li VBK_REG=0 Tile Numbers are written
+ \li VBK_REG=1 Tile Attributes are written
+
+ For more details about GBC Tile Attributes see @ref set_bkg_tiles.
+
+ @see SHOW_WIN, HIDE_WIN, set_win_submap, set_bkg_tiles, set_bkg_data, set_tiles
+*/
+void set_win_tiles(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *tiles) OLDCALL PRESERVES_REGS(b, c);
+
+
+/** Sets a rectangular region of the Window Tile Map.
+ The offset value in __base_tile__ is added to
+ the tile ID for each map entry.
+
+ @param x X Start position in Window Map tile coordinates. Range 0 - 31
+ @param y Y Start position in Window Map tile coordinates. Range 0 - 31
+ @param w Width of area to set in tiles. Range 1 - 32
+ @param h Height of area to set in tiles. Range 1 - 32
+ @param tiles Pointer to source tile map data
+ @param base_tile Offset each tile ID entry of the source map by this value. Range 1 - 255
+
+ This is identical to @ref set_win_tiles() except that it
+ adds the __base_tile__ parameter for when a tile map's tiles don't
+ start at index zero. (For example, the tiles used by the map
+ range from 100 -> 120 in VRAM instead of 0 -> 20).
+
+ @see set_win_tiles for more details
+*/
+inline void set_win_based_tiles(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *tiles, uint8_t base_tile) {
+ _map_tile_offset = base_tile;
+ set_win_tiles(x, y, w, h, tiles);
+ _map_tile_offset = 0;
+}
+
+/** Sets a rectangular area of the Window Tile Map using a sub-region
+ from a source tile map.
+
+ @param x X Start position in Window Map tile coordinates. Range 0 - 31
+ @param y Y Start position in Wimdpw Map tile coordinates. Range 0 - 31
+ @param w Width of area to set in tiles. Range 1 - 255
+ @param h Height of area to set in tiles. Range 1 - 255
+ @param map Pointer to source tile map data
+ @param map_w Width of source tile map in tiles. Range 1 - 255
+
+ Entries are copied from __map__ to the Window Tile Map starting at
+ __x__, __y__ writing across for __w__ tiles and down for __h__ tiles,
+ using __map_w__ as the rowstride for the source tile map.
+
+ Use this instead of @ref set_win_tiles when the source map is wider than
+ 32 tiles or when writing a width that does not match the source map width.
+
+ One byte per source tile map entry.
+
+ Writes that exceed coordinate 31 on the x or y axis will wrap around to
+ the Left and Top edges.
+
+ GBC only: @ref VBK_REG determines whether Tile Numbers or Tile Attributes get set.
+ \li VBK_REG=0 Tile Numbers are written
+ \li VBK_REG=1 Tile Attributes are written
+
+ See @ref set_bkg_tiles for details about CGB attribute maps with @ref VBK_REG.
+
+ @see SHOW_WIN, HIDE_WIN, set_win_tiles, set_bkg_submap, set_bkg_tiles, set_bkg_data, set_tiles
+**/
+void set_win_submap(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *map, uint8_t map_w) OLDCALL;
+
+
+/** Sets a rectangular area of the Window Tile Map using a sub-region
+ from a source tile map. The offset value in __base_tile__ is added
+ to the tile ID for each map entry.
+
+ @param x X Start position in Window Map tile coordinates. Range 0 - 31
+ @param y Y Start position in Wimdpw Map tile coordinates. Range 0 - 31
+ @param w Width of area to set in tiles. Range 1 - 255
+ @param h Height of area to set in tiles. Range 1 - 255
+ @param map Pointer to source tile map data
+ @param map_w Width of source tile map in tiles. Range 1 - 255
+ @param base_tile Offset each tile ID entry of the source map by this value. Range 1 - 255
+
+ This is identical to @ref set_win_submap() except that it
+ adds the __base_tile__ parameter for when a tile map's tiles don't
+ start at index zero. (For example, the tiles used by the map
+ range from 100 -> 120 in VRAM instead of 0 -> 20).
+
+ @see set_win_submap for more details
+**/
+inline void set_win_based_submap(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *map, uint8_t map_w, uint8_t base_tile) {
+ _submap_tile_offset = base_tile;
+ set_win_submap(x, y, w, h, map, map_w);
+ _submap_tile_offset = 0;
+}
+
+
+/** Copies a rectangular region of Window Tile Map entries into a buffer.
+
+ @param x X Start position in Window Map tile coordinates. Range 0 - 31
+ @param y Y Start position in Window Map tile coordinates. Range 0 - 31
+ @param w Width of area to copy in tiles. Range 0 - 31
+ @param h Height of area to copy in tiles. Range 0 - 31
+ @param tiles Pointer to destination buffer for Tile Map data
+
+ Entries are copied into __tiles__ from the Window Tile Map starting at
+ __x__, __y__ reading across for __w__ tiles and down for __h__ tiles.
+
+ One byte per tile.
+
+ The buffer pointed to by __tiles__ should be at least __x__ x __y__ bytes in size.
+
+ @see get_bkg_tiles, get_bkg_tile_xy, get_tiles, get_vram_byte
+*/
+void get_win_tiles(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t *tiles) OLDCALL PRESERVES_REGS(b, c);
+
+
+/**
+ * Set single tile t on window layer at x,y
+ * @param x X-coordinate
+ * @param y Y-coordinate
+ * @param t tile index
+ * @return returns the address of tile, so you may use faster set_vram_byte() later
+ */
+uint8_t * set_win_tile_xy(uint8_t x, uint8_t y, uint8_t t) OLDCALL PRESERVES_REGS(b, c);
+
+
+/**
+ * Get single tile t on window layer at x,y
+ * @param x X-coordinate
+ * @param y Y-coordinate
+ * @return returns the tile index
+ */
+uint8_t get_win_tile_xy(uint8_t x, uint8_t y) OLDCALL PRESERVES_REGS(b, c);
+
+
+/** Moves the Window to the __x__, __y__ position on the screen.
+
+ @param x X coordinate for Left edge of the Window (actual displayed location will be X - 7)
+ @param y Y coordinate for Top edge of the Window
+
+ 7,0 is the top left corner of the screen in Window coordinates. The Window is locked to the bottom right corner.
+
+ The Window is always over the Background layer.
+
+ @see SHOW_WIN, HIDE_WIN
+*/
+inline void move_win(uint8_t x, uint8_t y) {
+ WX_REG=x, WY_REG=y;
+}
+
+
+/** Move the Window relative to its current position.
+
+ @param x Number of pixels to move the window on the __X axis__
+ \n Range: -128 - 127
+ @param y Number of pixels to move the window on the __Y axis__
+ \n Range: -128 - 127
+
+ @see move_win
+*/
+inline void scroll_win(int8_t x, int8_t y) {
+ WX_REG+=x, WY_REG+=y;
+}
+
+
+
+/** Sets VRAM Tile Pattern data for Sprites
+
+ @param first_tile Index of the first tile to write
+ @param nb_tiles Number of tiles to write
+ @param data Pointer to (2 bpp) source Tile Pattern data
+
+ Writes __nb_tiles__ tiles to VRAM starting at __first_tile__, tile data
+ is sourced from __data__. Each Tile is 16 bytes in size (8x8 pixels, 2 bits-per-pixel).
+
+ Note: Sprite Tiles 128-255 share the same memory region as Background Tiles 128-255.
+
+ GBC only: @ref VBK_REG determines which bank of Background tile patterns are written to.
+ \li VBK_REG=0 indicates the first bank
+ \li VBK_REG=1 indicates the second
+*/
+void set_sprite_data(uint8_t first_tile, uint8_t nb_tiles, const uint8_t *data) OLDCALL PRESERVES_REGS(b, c);
+#define set_sprite_2bpp_data set_sprite_data
+
+/** Sets VRAM Tile Pattern data for Sprites using 1bpp source data
+
+ @param first_tile Index of the first tile to write
+ @param nb_tiles Number of tiles to write
+ @param data Pointer to (1bpp) source Tile Pattern data
+
+ Similar to @ref set_sprite_data, except source data is 1 bit-per-pixel
+ which gets expanded into 2 bits-per-pixel.
+
+ For a given bit that represent a pixel:
+ \li 0 will be expanded into color 0
+ \li 1 will be expanded into color 3
+
+ @see SHOW_SPRITES, HIDE_SPRITES, set_sprite_tile
+*/
+void set_sprite_1bpp_data(uint8_t first_tile, uint8_t nb_tiles, const uint8_t *data) OLDCALL PRESERVES_REGS(b, c);
+
+/** Copies from Sprite VRAM Tile Pattern data into a buffer
+
+ @param first_tile Index of the first tile to read from
+ @param nb_tiles Number of tiles to read
+ @param data Pointer to destination buffer for Tile Pattern data
+
+ Copies __nb_tiles__ tiles from VRAM starting at __first_tile__, tile data
+ is copied into __data__.
+
+ Each Tile is 16 bytes, so the buffer pointed to by __data__
+ should be at least __nb_tiles__ x 16 bytes in size.
+*/
+void get_sprite_data(uint8_t first_tile, uint8_t nb_tiles, uint8_t *data) OLDCALL PRESERVES_REGS(b, c);
+
+
+/** Sprite Attributes structure
+ @param x X Coordinate of the sprite on screen
+ @param y Y Coordinate of the sprite on screen
+ @param tile Sprite tile number (see @ref set_sprite_tile)
+ @param prop OAM Property Flags (see @ref set_sprite_prop)
+*/
+typedef struct OAM_item_t {
+ uint8_t y, x; //< X, Y Coordinates of the sprite on screen
+ uint8_t tile; //< Sprite tile number
+ uint8_t prop; //< OAM Property Flags
+} OAM_item_t;
+
+
+/** Shadow OAM array in WRAM, that is DMA-transferred into the real OAM each VBlank
+*/
+extern volatile struct OAM_item_t shadow_OAM[];
+
+/** MSB of shadow_OAM address is used by OAM DMA copying routine
+*/
+__REG _shadow_OAM_base;
+
+#define DISABLE_OAM_DMA \
+ _shadow_OAM_base = 0
+
+/** Disable OAM DMA copy each VBlank
+*/
+#define DISABLE_VBL_TRANSFER DISABLE_OAM_DMA
+
+#define ENABLE_OAM_DMA \
+ _shadow_OAM_base = (uint8_t)((uint16_t)&shadow_OAM >> 8)
+
+/** Enable OAM DMA copy each VBlank and set it to transfer default shadow_OAM array
+*/
+#define ENABLE_VBL_TRANSFER ENABLE_OAM_DMA
+
+/** Amount of hardware sprites in OAM
+*/
+#define MAX_HARDWARE_SPRITES 40
+
+/** Enable OAM DMA copy each VBlank and set it to transfer any 256-byte aligned array
+*/
+inline void SET_SHADOW_OAM_ADDRESS(void * address) {
+ _shadow_OAM_base = (uint8_t)((uint16_t)address >> 8);
+}
+
+/** Sets sprite number __nb__in the OAM to display tile number __tile__.
+
+ @param nb Sprite number, range 0 - 39
+ @param tile Selects a tile (0 - 255) from memory at 8000h - 8FFFh
+ \n In CGB Mode this could be either in VRAM Bank
+ \n 0 or 1, depending on Bit 3 of the OAM Attribute Flag
+ \n (see @ref set_sprite_prop)
+
+ In 8x16 mode:
+ \li The sprite will also display the next tile (__tile__ + 1)
+ directly below (y + 8) the first tile.
+ \li The lower bit of the tile number is ignored:
+ the upper 8x8 tile is (__tile__ & 0xFE), and
+ the lower 8x8 tile is (__tile__ | 0x01).
+ \li See: @ref SPRITES_8x16
+*/
+inline void set_sprite_tile(uint8_t nb, uint8_t tile) {
+ shadow_OAM[nb].tile=tile;
+}
+
+
+/** Returns the tile number of sprite number __nb__ in the OAM.
+
+@param nb Sprite number, range 0 - 39
+
+@see set_sprite_tile for more details
+*/
+inline uint8_t get_sprite_tile(uint8_t nb) {
+ return shadow_OAM[nb].tile;
+}
+
+
+/** Sets the OAM Property Flags of sprite number __nb__ to those defined in __prop__.
+
+ @param nb Sprite number, range 0 - 39
+ @param prop Property setting (see bitfield description)
+
+ The bits in __prop__ represent:
+ \li Bit 7 - Priority flag. When this is set the sprites appear behind the
+ background and window layer.
+ \n 0: infront
+ \n 1: behind
+ \li Bit 6 - Vertical flip. Dictates which way up the sprite is drawn
+ vertically.
+ \n 0: normal
+ \n 1:upside down
+ \li Bit 5 - Horizontal flip. Dictates which way up the sprite is
+ drawn horizontally.
+ \n 0: normal
+ \n 1:back to front
+ \li Bit 4 - DMG/Non-CGB Mode Only. Assigns either one of the two b/w palettes to the sprite.
+ \n 0: OBJ palette 0
+ \n 1: OBJ palette 1
+ \li Bit 3 - GBC only. Dictates from which bank of Sprite Tile Patterns the tile
+ is taken.
+ \n 0: Bank 0
+ \n 1: Bank 1
+ \li Bit 2 - See bit 0.
+ \li Bit 1 - See bit 0.
+ \li Bit 0 - GBC only. Bits 0-2 indicate which of the 7 OBJ colour palettes the
+ sprite is assigned.
+*/
+inline void set_sprite_prop(uint8_t nb, uint8_t prop) {
+ shadow_OAM[nb].prop=prop;
+}
+
+
+/** Returns the OAM Property Flags of sprite number __nb__.
+
+ @param nb Sprite number, range 0 - 39
+ @see set_sprite_prop for property bitfield settings
+*/
+inline uint8_t get_sprite_prop(uint8_t nb) {
+ return shadow_OAM[nb].prop;
+}
+
+
+/** Moves sprite number __nb__ to the __x__, __y__ position on the screen.
+
+ @param nb Sprite number, range 0 - 39
+ @param x X Position. Specifies the sprites horizontal position on the screen (minus 8).
+ \n An offscreen value (X=0 or X>=168) hides the sprite, but the sprite
+ still affects the priority ordering - a better way to hide a sprite is to set
+ its Y-coordinate offscreen.
+ @param y Y Position. Specifies the sprites vertical position on the screen (minus 16).
+ \n An offscreen value (for example, Y=0 or Y>=160) hides the sprite.
+
+ Moving the sprite to 0,0 (or similar off-screen location) will hide it.
+*/
+inline void move_sprite(uint8_t nb, uint8_t x, uint8_t y) {
+ OAM_item_t * itm = &shadow_OAM[nb];
+ itm->y=y, itm->x=x;
+}
+
+
+/** Moves sprite number __nb__ relative to its current position.
+
+ @param nb Sprite number, range 0 - 39
+ @param x Number of pixels to move the sprite on the __X axis__
+ \n Range: -128 - 127
+ @param y Number of pixels to move the sprite on the __Y axis__
+ \n Range: -128 - 127
+
+ @see move_sprite for more details about the X and Y position
+ */
+inline void scroll_sprite(uint8_t nb, int8_t x, int8_t y) {
+ OAM_item_t * itm = &shadow_OAM[nb];
+ itm->y+=y, itm->x+=x;
+}
+
+
+/** Hides sprite number __nb__ by moving it to zero position by Y.
+
+ @param nb Sprite number, range 0 - 39
+ */
+inline void hide_sprite(uint8_t nb) {
+ shadow_OAM[nb].y = 0;
+}
+
+
+
+/** Copies arbitrary data to an address in VRAM
+ without taking into account the state of LCDC bits 3 or 4.
+
+ @param vram_addr Pointer to destination VRAM Address
+ @param data Pointer to source buffer
+ @param len Number of bytes to copy
+
+ Copies __len__ bytes from a buffer at __data__ to VRAM starting at __vram_addr__.
+
+ GBC only: @ref VBK_REG determines which bank of Background tile patterns are written to.
+ \li VBK_REG=0 indicates the first bank
+ \li VBK_REG=1 indicates the second
+
+ @see set_bkg_data, set_win_data, set_bkg_tiles, set_win_tiles, set_tile_data, set_tiles
+*/
+void set_data(uint8_t *vram_addr, const uint8_t *data, uint16_t len) OLDCALL PRESERVES_REGS(b, c);
+
+
+/** Copies arbitrary data from an address in VRAM into a buffer
+ without taking into account the state of LCDC bits 3 or 4.
+
+ @param vram_addr Pointer to source VRAM Address
+ @param data Pointer to destination buffer
+ @param len Number of bytes to copy
+
+ Copies __len__ bytes from VRAM starting at __vram_addr__ into a buffer at __data__.
+
+ GBC only: @ref VBK_REG determines which bank of Background tile patterns are written to.
+ \li VBK_REG=0 indicates the first bank
+ \li VBK_REG=1 indicates the second
+
+ @see get_bkg_data, get_win_data, get_bkg_tiles, get_win_tiles, get_tiles
+*/
+void get_data(uint8_t *data, uint8_t *vram_addr, uint16_t len) OLDCALL PRESERVES_REGS(b, c);
+
+/** Copies arbitrary data from an address in VRAM into a buffer
+
+ @param dest Pointer to destination buffer (may be in VRAM)
+ @param sour Pointer to source buffer (may be in VRAM)
+ @param len Number of bytes to copy
+
+ Copies __len__ bytes from or to VRAM starting at __sour__ into a buffer or to VRAM at __dest__.
+
+ GBC only: @ref VBK_REG determines which bank of Background tile patterns are written to.
+ \li VBK_REG=0 indicates the first bank
+ \li VBK_REG=1 indicates the second
+*/
+void vmemcpy(uint8_t *dest, uint8_t *sour, uint16_t len) OLDCALL PRESERVES_REGS(b, c);
+
+
+
+/** Sets a rectangular region of Tile Map entries at a given VRAM Address
+ without taking into account the state of LCDC bit 3.
+
+ @param x X Start position in Map tile coordinates. Range 0 - 31
+ @param y Y Start position in Map tile coordinates. Range 0 - 31
+ @param w Width of area to set in tiles. Range 1 - 32
+ @param h Height of area to set in tiles. Range 1 - 32
+ @param vram_addr Pointer to destination VRAM Address
+ @param tiles Pointer to source Tile Map data
+
+ Entries are copied from __tiles__ to Tile Map at address vram_addr starting at
+ __x__, __y__ writing across for __w__ tiles and down for __h__ tiles.
+
+ One byte per source tile map entry.
+
+ There are two 32x32 Tile Maps in VRAM at addresses 9800h-9BFFh and 9C00h-9FFFh.
+
+ GBC only: @ref VBK_REG determines whether Tile Numbers or Tile Attributes get set.
+ \li VBK_REG=0 Tile Numbers are written
+ \li VBK_REG=1 Tile Attributes are written
+
+ @see set_bkg_tiles, set_win_tiles
+*/
+void set_tiles(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t *vram_addr, const uint8_t *tiles) OLDCALL;
+
+/** Sets VRAM Tile Pattern data starting from given base address
+ without taking into account the state of LCDC bit 4.
+
+ @param first_tile Index of the first tile to write
+ @param nb_tiles Number of tiles to write
+ @param data Pointer to (2 bpp) source Tile Pattern data.
+ @param base MSB of the destination address in VRAM (usually 0x80 or 0x90 which gives 0x8000 or 0x9000)
+
+ @see set_bkg_data, set_win_data, set_data
+*/
+void set_tile_data(uint8_t first_tile, uint8_t nb_tiles, const uint8_t *data, uint8_t base) OLDCALL PRESERVES_REGS(b, c);
+
+/** Copies a rectangular region of Tile Map entries from a given VRAM Address into a buffer
+ without taking into account the state of LCDC bit 3.
+
+ @param x X Start position in Background Map tile coordinates. Range 0 - 31
+ @param y Y Start position in Background Map tile coordinates. Range 0 - 31
+ @param w Width of area to copy in tiles. Range 0 - 31
+ @param h Height of area to copy in tiles. Range 0 - 31
+ @param vram_addr Pointer to source VRAM Address
+ @param tiles Pointer to destination buffer for Tile Map data
+
+ Entries are copied into __tiles__ from the Background Tile Map starting at
+ __x__, __y__ reading across for __w__ tiles and down for __h__ tiles.
+
+ One byte per tile.
+
+ There are two 32x32 Tile Maps in VRAM at addresses 9800h - 9BFFh and 9C00h - 9FFFh.
+
+ The buffer pointed to by __tiles__ should be at least __x__ x __y__ bytes in size.
+
+ @see get_bkg_tiles, get_win_tiles
+*/
+void get_tiles(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t *vram_addr, uint8_t *tiles) OLDCALL;
+
+
+/** Sets VRAM Tile Pattern data in the native format
+
+ @param first_tile Index of the first tile to write (0 - 511)
+ @param nb_tiles Number of tiles to write
+ @param data Pointer to source Tile Pattern data.
+
+ When `first_tile` is larger than 256 on the GB/AP, it
+ will write to sprite data instead of background data.
+
+ The bit depth of the source Tile Pattern data depends
+ on which console is being used:
+ \li Game Boy/Analogue Pocket: loads 2bpp tiles data
+ \li SMS/GG: loads 4bpp tile data
+ */
+inline void set_native_tile_data(uint16_t first_tile, uint8_t nb_tiles, const uint8_t *data) {
+ if (first_tile < 256) {
+ set_bkg_data(first_tile, nb_tiles, data);
+ } else {
+ set_sprite_data(first_tile - 256, nb_tiles, data);
+ }
+}
+
+
+/** Initializes the entire Window Tile Map with Tile Number __c__
+ @param c Tile number to fill with
+
+ Note: This function avoids writes during modes 2 & 3
+*/
+void init_win(uint8_t c) OLDCALL PRESERVES_REGS(b, c);
+
+/** Initializes the entire Background Tile Map with Tile Number __c__
+ @param c Tile number to fill with
+
+ Note: This function avoids writes during modes 2 & 3
+*/
+void init_bkg(uint8_t c) OLDCALL PRESERVES_REGS(b, c);
+
+/** Fills the VRAM memory region __s__ of size __n__ with Tile Number __c__
+ @param s Start address in VRAM
+ @param c Tile number to fill with
+ @param n Size of memory region (in bytes) to fill
+
+ Note: This function avoids writes during modes 2 & 3
+*/
+void vmemset (void *s, uint8_t c, size_t n) OLDCALL PRESERVES_REGS(b, c);
+
+
+
+/** Fills a rectangular region of Tile Map entries for the Background layer with tile.
+
+ @param x X Start position in Background Map tile coordinates. Range 0 - 31
+ @param y Y Start position in Background Map tile coordinates. Range 0 - 31
+ @param w Width of area to set in tiles. Range 0 - 31
+ @param h Height of area to set in tiles. Range 0 - 31
+ @param tile Fill value
+*/
+void fill_bkg_rect(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t tile) OLDCALL PRESERVES_REGS(b, c);
+#define fill_rect fill_bkg_rect
+
+/** Fills a rectangular region of Tile Map entries for the Window layer with tile.
+
+ @param x X Start position in Window Map tile coordinates. Range 0 - 31
+ @param y Y Start position in Window Map tile coordinates. Range 0 - 31
+ @param w Width of area to set in tiles. Range 0 - 31
+ @param h Height of area to set in tiles. Range 0 - 31
+ @param tile Fill value
+*/
+void fill_win_rect(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t tile) OLDCALL PRESERVES_REGS(b, c);
+
+#endif /* _GB_H */
diff --git a/gbdk/gbdk-lib/include/gb/gbdecompress.h b/gbdk/gbdk-lib/include/gb/gbdecompress.h
new file mode 100644
index 00000000..79a6c985
--- /dev/null
+++ b/gbdk/gbdk-lib/include/gb/gbdecompress.h
@@ -0,0 +1,62 @@
+/** @file gb/gbdecompress.h
+
+ GB-Compress decompressor
+ Compatible with the compression used in GBTD
+ @see utility_gbcompress "gbcompress"
+*/
+
+#ifndef __GBDECOMPRESS_H_INCLUDE
+#define __GBDECOMPRESS_H_INCLUDE
+
+#include <types.h>
+#include <stdint.h>
+
+/** gb-decompress data from sour into dest
+
+ @param sour Pointer to source gb-compressed data
+ @param dest Pointer to destination buffer/address
+
+ @see gb_decompress_bkg_data, gb_decompress_win_data, gb_decompress_sprite_data
+ */
+uint16_t gb_decompress(const uint8_t * sour, uint8_t * dest) OLDCALL PRESERVES_REGS(b, c);
+
+
+/** gb-decompress background tiles into VRAM
+
+ @param first_tile Index of the first tile to write
+ @param sour Pointer to (gb-compressed 2 bpp) source Tile Pattern data.
+
+ Note: This function avoids writes during modes 2 & 3
+
+ @see gb_decompress_bkg_data, gb_decompress_win_data, gb_decompress_sprite_data
+*/
+void gb_decompress_bkg_data(uint8_t first_tile, const uint8_t * sour) OLDCALL PRESERVES_REGS(b, c);
+
+
+/** gb-decompress window tiles into VRAM
+
+ @param first_tile Index of the first tile to write
+ @param sour Pointer to (gb-compressed 2 bpp) source Tile Pattern data.
+
+ This is the same as @ref gb_decompress_bkg_data, since the Window Layer and
+ Background Layer share the same Tile pattern data.
+
+ Note: This function avoids writes during modes 2 & 3
+
+ @see gb_decompress, gb_decompress_bkg_data, gb_decompress_sprite_data
+ */
+void gb_decompress_win_data(uint8_t first_tile, const uint8_t * sour) OLDCALL PRESERVES_REGS(b, c);
+
+
+/** gb-decompress sprite tiles into VRAM
+
+ @param first_tile Index of the first tile to write
+ @param sour Pointer to source compressed data
+
+ Note: This function avoids writes during modes 2 & 3
+
+ @see gb_decompress, gb_decompress_bkg_data, gb_decompress_win_data
+ */
+void gb_decompress_sprite_data(uint8_t first_tile, const uint8_t * sour) OLDCALL PRESERVES_REGS(b, c);
+
+#endif \ No newline at end of file
diff --git a/gbdk/gbdk-lib/include/gb/hardware.h b/gbdk/gbdk-lib/include/gb/hardware.h
new file mode 100644
index 00000000..2edcce41
--- /dev/null
+++ b/gbdk/gbdk-lib/include/gb/hardware.h
@@ -0,0 +1,420 @@
+/** @file gb/hardware.h
+ Defines that let the GB's hardware registers be accessed
+ from C.
+
+ See the @ref Pandocs for more details on each register.
+*/
+#ifndef _HARDWARE_H
+#define _HARDWARE_H
+
+#include <types.h>
+
+#define __BYTES extern UBYTE
+#define __BYTE_REG extern volatile UBYTE
+#define __REG extern volatile SFR
+
+/** Memoty map */
+
+__BYTES _VRAM[];
+__BYTES _VRAM8000[];
+__BYTES _VRAM8800[];
+__BYTES _VRAM9000[];
+__BYTES _SCRN0[];
+__BYTES _SCRN1[];
+__BYTES _SRAM[];
+__BYTES _RAM[];
+__BYTES _RAMBANK[];
+__BYTES _OAMRAM[];
+__BYTE_REG _IO[];
+__BYTE_REG _AUD3WAVERAM[];
+__BYTE_REG _HRAM[];
+
+/** MBC5 registers */
+
+__BYTE_REG rRAMG;
+__BYTE_REG rROMB0;
+__BYTE_REG rROMB1;
+__BYTE_REG rRAMB;
+
+/** IO Registers */
+
+__REG P1_REG; /**< Joystick: 1.1.P15.P14.P13.P12.P11.P10 */
+#define rP1 P1_REG
+
+#define P1F_5 0b00100000
+#define P1F_4 0b00010000
+#define P1F_3 0b00001000
+#define P1F_2 0b00000100
+#define P1F_1 0b00000010
+#define P1F_0 0b00000001
+
+#define P1F_GET_DPAD P1F_5
+#define P1F_GET_BTN P1F_4
+#define P1F_GET_NONE (P1F_4 | P1F_5)
+
+__REG SB_REG; /**< Serial IO data buffer */
+#define rSB SB_REG
+__REG SC_REG; /**< Serial IO control register */
+#define rSC SC_REG
+__REG DIV_REG; /**< Divider register */
+#define rDIV DIV_REG
+__REG TIMA_REG; /**< Timer counter */
+#define rTIMA TIMA_REG
+__REG TMA_REG; /**< Timer modulo */
+#define rTMA TMA_REG
+__REG TAC_REG; /**< Timer control */
+#define rTAC TAC_REG
+
+#define TACF_START 0b00000100
+#define TACF_STOP 0b00000000
+#define TACF_4KHZ 0b00000000
+#define TACF_16KHZ 0b00000011
+#define TACF_65KHZ 0b00000010
+#define TACF_262KHZ 0b00000001
+
+#define SIOF_CLOCK_EXT 0b00000000 /**< Serial IO: Use External clock */
+#define SIOF_CLOCK_INT 0b00000001 /**< Serial IO: Use Internal clock */
+#define SIOF_SPEED_1X 0b00000000 /**< Serial IO: If internal clock then 8KHz mode, 1KB/s (16Khz in CGB high-speed mode, 2KB/s) */
+#define SIOF_SPEED_32X 0b00000010 /**< Serial IO: **CGB-Mode ONLY** If internal clock then 256KHz mode, 32KB/s (512KHz in CGB high-speed mode, 64KB/s) */
+#define SIOF_XFER_START 0b10000000 /**< Serial IO: Start Transfer. Automatically cleared at the end of transfer */
+#define SIOF_B_CLOCK 0
+#define SIOF_B_SPEED 1
+#define SIOF_B_XFER_START 7
+
+__REG IF_REG; /**< Interrupt flags: 0.0.0.JOY.SIO.TIM.LCD.VBL */
+#define rIF IF_REG
+
+__REG NR10_REG; /**< Sound Channel 1 Sweep */
+#define rAUD1SWEEP NR10_REG
+#define AUD1SWEEP_UP 0b00000000
+#define AUD1SWEEP_DOWN 0b00001000
+#define AUD1SWEEP_TIME(x) ((x) << 4)
+#define AUD1SWEEP_LENGTH(x) (x)
+__REG NR11_REG; /**< Sound Channel 1 Sound length/Wave pattern duty */
+#define rAUD1LEN NR11_REG
+__REG NR12_REG; /**< Sound Channel 1 Volume Envelope */
+#define rAUD1ENV NR12_REG
+__REG NR13_REG; /**< Sound Channel 1 Frequency Low */
+#define rAUD1LOW NR13_REG
+__REG NR14_REG; /**< Sound Channel 1 Frequency High */
+#define rAUD1HIGH NR14_REG
+
+__REG NR21_REG; /**< Sound Channel 2 Tone */
+#define rAUD2LEN NR21_REG
+__REG NR22_REG; /**< Sound Channel 2 Volume Envelope */
+#define rAUD2ENV NR22_REG
+__REG NR23_REG; /**< Sound Channel 2 Frequency data Low */
+#define rAUD2LOW NR23_REG
+__REG NR24_REG; /**< Sound Channel 2 Frequency data High */
+#define rAUD2HIGH NR24_REG
+
+__REG NR30_REG; /**< Sound Channel 3 Sound on/off */
+#define rAUD3ENA NR30_REG
+__REG NR31_REG; /**< Sound Channel 3 Sound Length */
+#define rAUD3LEN NR31_REG
+__REG NR32_REG; /**< Sound Channel 3 Select output level */
+#define rAUD3LEVEL NR32_REG
+__REG NR33_REG; /**< Sound Channel 3 Frequency data Low */
+#define rAUD3LOW NR33_REG
+__REG NR34_REG; /**< Sound Channel 3 Frequency data High */
+#define rAUD3HIGH NR34_REG
+
+__REG NR41_REG; /**< Sound Channel 4 Sound Length */
+#define rAUD4LEN NR41_REG
+__REG NR42_REG; /**< Sound Channel 4 Volume Envelope */
+#define rAUD4ENV NR42_REG
+__REG NR43_REG; /**< Sound Channel 4 Polynomial Counter */
+#define rAUD4POLY NR43_REG
+#define AUD4POLY_WIDTH_15BIT 0x00
+#define AUD4POLY_WIDTH_7BIT 0x08
+__REG NR44_REG; /**< Sound Channel 4 Counter / Consecutive and Inital */
+#define rAUD4GO NR44_REG
+
+__REG NR50_REG; /**< Sound Channel control / ON-OFF / Volume */
+#define rAUDVOL NR50_REG
+
+#define AUDVOL_VOL_LEFT(x) ((x) << 4)
+#define AUDVOL_VOL_RIGHT(x) ((x))
+#define AUDVOL_VIN_LEFT 0b10000000
+#define AUDVOL_VIN_RIGHT 0b00001000
+
+__REG NR51_REG; /**< Sound Selection of Sound output terminal */
+#define rAUDTERM NR51_REG
+
+#define AUDTERM_4_LEFT 0b10000000
+#define AUDTERM_3_LEFT 0b01000000
+#define AUDTERM_2_LEFT 0b00100000
+#define AUDTERM_1_LEFT 0b00010000
+#define AUDTERM_4_RIGHT 0b00001000
+#define AUDTERM_3_RIGHT 0b00000100
+#define AUDTERM_2_RIGHT 0b00000010
+#define AUDTERM_1_RIGHT 0b00000001
+
+__REG NR52_REG; /**< Sound Master on/off */
+#define rAUDENA NR52_REG
+
+#define AUDENA_ON 0b10000000
+#define AUDENA_OFF 0b00000000
+
+__BYTE_REG AUD3WAVE[16];
+__BYTE_REG PCM_SAMPLE[16];
+
+__REG LCDC_REG; /**< LCD control */
+#define rLCDC LCDC_REG
+
+#if defined(__TARGET_ap)
+#define LCDCF_OFF 0b00000000
+#define LCDCF_ON 0b00000001
+#define LCDCF_WIN9800 0b00000000
+#define LCDCF_WIN9C00 0b00000010
+#define LCDCF_WINOFF 0b00000000
+#define LCDCF_WINON 0b00000100
+#define LCDCF_BG8800 0b00000000
+#define LCDCF_BG8000 0b00001000
+#define LCDCF_BG9800 0b00000000
+#define LCDCF_BG9C00 0b00010000
+#define LCDCF_OBJ8 0b00000000
+#define LCDCF_OBJ16 0b00100000
+#define LCDCF_OBJOFF 0b00000000
+#define LCDCF_OBJON 0b01000000
+#define LCDCF_BGOFF 0b00000000
+#define LCDCF_BGON 0b10000000
+#define LCDCF_B_ON 0
+#define LCDCF_B_WIN9C00 1
+#define LCDCF_B_WINON 2
+#define LCDCF_B_BG8000 3
+#define LCDCF_B_BG9C00 4
+#define LCDCF_B_OBJ16 5
+#define LCDCF_B_OBJON 6
+#define LCDCF_B_BGON 7
+#elif defined(__TARGET_duck)
+#define LCDCF_OFF 0b00000000
+#define LCDCF_ON 0b10000000
+#define LCDCF_WIN9800 0b00000000
+#define LCDCF_WIN9C00 0b00001000
+#define LCDCF_WINOFF 0b00000000
+#define LCDCF_WINON 0b00100000
+#define LCDCF_BG8800 0b00000000
+#define LCDCF_BG8000 0b00010000
+#define LCDCF_BG9800 0b00000000
+#define LCDCF_BG9C00 0b00000100
+#define LCDCF_OBJ8 0b00000000
+#define LCDCF_OBJ16 0b00000010
+#define LCDCF_OBJOFF 0b00000000
+#define LCDCF_OBJON 0b00000001
+#define LCDCF_BGOFF 0b00000000
+#define LCDCF_BGON 0b01000000
+#define LCDCF_B_ON 7
+#define LCDCF_B_WIN9C00 3
+#define LCDCF_B_WINON 5
+#define LCDCF_B_BG8000 4
+#define LCDCF_B_BG9C00 2
+#define LCDCF_B_OBJ16 1
+#define LCDCF_B_OBJON 0
+#define LCDCF_B_BGON 6
+#else
+#define LCDCF_OFF 0b00000000 /**< LCD Control: Off */
+#define LCDCF_ON 0b10000000 /**< LCD Control: On */
+#define LCDCF_WIN9800 0b00000000 /**< Window Tile Map: Use 9800 Region */
+#define LCDCF_WIN9C00 0b01000000 /**< Window Tile Map: Use 9C00 Region */
+#define LCDCF_WINOFF 0b00000000 /**< Window Display: Hidden */
+#define LCDCF_WINON 0b00100000 /**< Window Display: Visible */
+#define LCDCF_BG8800 0b00000000 /**< BG & Window Tile Data: Use 8800 Region */
+#define LCDCF_BG8000 0b00010000 /**< BG & Window Tile Data: Use 8000 Region */
+#define LCDCF_BG9800 0b00000000 /**< BG Tile Map: use 9800 Region */
+#define LCDCF_BG9C00 0b00001000 /**< BG Tile Map: use 9C00 Region */
+#define LCDCF_OBJ8 0b00000000 /**< Sprites Size: 8x8 pixels */
+#define LCDCF_OBJ16 0b00000100 /**< Sprites Size: 8x16 pixels */
+#define LCDCF_OBJOFF 0b00000000 /**< Sprites Display: Hidden */
+#define LCDCF_OBJON 0b00000010 /**< Sprites Display: Visible */
+#define LCDCF_BGOFF 0b00000000 /**< Background Display: Hidden */
+#define LCDCF_BGON 0b00000001 /**< Background Display: Visible */
+#define LCDCF_B_ON 7 /**< Bit for LCD On/Off Select */
+#define LCDCF_B_WIN9C00 6 /**< Bit for Window Tile Map Region Select */
+#define LCDCF_B_WINON 5 /**< Bit for Window Display On/Off Control */
+#define LCDCF_B_BG8000 4 /**< Bit for BG & Window Tile Data Region Select */
+#define LCDCF_B_BG9C00 3 /**< Bit for BG Tile Map Region Select */
+#define LCDCF_B_OBJ16 2 /**< Bit for Sprites Size Select */
+#define LCDCF_B_OBJON 1 /**< Bit for Sprites Display Visible/Hidden Select */
+#define LCDCF_B_BGON 0 /**< Bit for Background Display Visible/Hidden Select */
+#endif
+
+__REG STAT_REG; /**< LCD status */
+#define rSTAT STAT_REG
+
+#if defined(__TARGET_ap)
+#define STATF_LYC 0b00000010
+#define STATF_MODE10 0b00000100
+#define STATF_MODE01 0b00001000
+#define STATF_MODE00 0b00010000
+#define STATF_LYCF 0b00100000
+#define STATF_HBL 0b00000000
+#define STATF_VBL 0b10000000
+#define STATF_OAM 0b01000000
+#define STATF_LCD 0b11000000
+#define STATF_BUSY 0b01000000
+#define STATF_B_LYC 1
+#define STATF_B_MODE10 2
+#define STATF_B_MODE01 3
+#define STATF_B_MODE00 4
+#define STATF_B_LYCF 5
+#define STATF_B_VBL 7
+#define STATF_B_OAM 6
+#define STATF_B_BUSY 6
+#else
+#define STATF_LYC 0b01000000 /**< STAT Interrupt: LYC=LY Coincidence Source Enable */
+#define STATF_MODE10 0b00100000 /**< STAT Interrupt: Mode 2 OAM Source Enable */
+#define STATF_MODE01 0b00010000 /**< STAT Interrupt: Mode 1 VBlank Source Enable */
+#define STATF_MODE00 0b00001000 /**< STAT Interrupt: Mode 0 HBlank Source Enable */
+#define STATF_LYCF 0b00000100 /**< LYC=LY Coincidence Status Flag, Set when LY contains the same value as LYC */
+#define STATF_HBL 0b00000000 /**< Current LCD Mode is: 0, in H-Blank */
+#define STATF_VBL 0b00000001 /**< Current LCD Mode is: 1, in V-Blank */
+#define STATF_OAM 0b00000010 /**< Current LCD Mode is: 2, in OAM-RAM is used by system (Searching OAM) */
+#define STATF_LCD 0b00000011 /**< Current LCD Mode is: 3, both OAM and VRAM used by system (Transferring Data to LCD Controller) */
+#define STATF_BUSY 0b00000010 /**< When set, VRAM access is unsafe */
+#define STATF_B_LYC 6 /**< Bit for STAT Interrupt: LYC=LY Coincidence Source Enable */
+#define STATF_B_MODE10 5 /**< Bit for STAT Interrupt: Mode 2 OAM Source Enable */
+#define STATF_B_MODE01 4 /**< Bit for STAT Interrupt: Mode 1 VBlank Source Enable */
+#define STATF_B_MODE00 3 /**< Bit for STAT Interrupt: Mode 0 HBlank Source Enable */
+#define STATF_B_LYCF 2 /**< Bit for LYC=LY Coincidence Status Flag */
+#define STATF_B_VBL 0 /**< */
+#define STATF_B_OAM 1 /**< */
+#define STATF_B_BUSY 1 /**< Bit for when VRAM access is unsafe */
+#endif
+
+__REG SCY_REG; /**< Scroll Y */
+#define rSCY
+__REG SCX_REG; /**< Scroll X */
+#define rSCX SCX_REG
+__REG LY_REG; /**< LCDC Y-coordinate */
+#define rLY LY_REG
+__REG LYC_REG; /**< LY compare */
+#define rLYC LYC_REG
+__REG DMA_REG; /**< DMA transfer */
+#define rDMA DMA_REG
+__REG BGP_REG; /**< BG palette data */
+#define rBGP BGP_REG
+__REG OBP0_REG; /**< OBJ palette 0 data */
+#define rOBP0 OBP0_REG
+__REG OBP1_REG; /**< OBJ palette 1 data */
+#define rOBP1 OBP1_REG
+__REG WY_REG; /**< Window Y coordinate */
+#define rWY WY_REG
+__REG WX_REG; /**< Window X coordinate */
+#define rWX WX_REG
+__REG KEY1_REG; /**< CPU speed */
+#define rKEY1 KEY1_REG
+#define rSPD KEY1_REG
+
+#define KEY1F_DBLSPEED 0b10000000
+#define KEY1F_PREPARE 0b00000001
+
+__REG VBK_REG; /**< VRAM bank select */
+#define rVBK VBK_REG
+__REG HDMA1_REG; /**< DMA control 1 */
+#define rHDMA1 HDMA1_REG
+__REG HDMA2_REG; /**< DMA control 2 */
+#define rHDMA2 HDMA2_REG
+__REG HDMA3_REG; /**< DMA control 3 */
+#define rHDMA3 HDMA3_REG
+__REG HDMA4_REG; /**< DMA control 4 */
+#define rHDMA4 HDMA4_REG
+__REG HDMA5_REG; /**< DMA control 5 */
+#define rHDMA5 HDMA5_REG
+
+#define HDMA5F_MODE_GP 0b00000000
+#define HDMA5F_MODE_HBL 0b10000000
+
+#define HDMA5F_BUSY 0b10000000
+
+__REG RP_REG; /**< IR port */
+#define rRP RP_REG
+
+#define RPF_ENREAD 0b11000000
+#define RPF_DATAIN 0b00000010
+#define RPF_WRITE_HI 0b00000001
+#define RPF_WRITE_LO 0b00000000
+
+__REG BCPS_REG; /**< BG color palette specification */
+#define rBCPS BCPS_REG
+
+#define BCPSF_AUTOINC 0b10000000
+__REG BCPD_REG; /**< BG color palette data */
+#define rBCPD BCPD_REG
+__REG OCPS_REG; /**< OBJ color palette specification */
+#define rOCPS OCPS_REG
+
+#define OCPSF_AUTOINC 0b10000000
+__REG OCPD_REG; /**< OBJ color palette data */
+#define rOCPD OCPD_REG
+__REG SVBK_REG; /**< WRAM bank */
+#define rSVBK SVBK_REG
+#define rSMBK SVBK_REG
+
+__REG PCM12_REG; /**< Sound channel 1&2 PCM amplitude (R) */
+#define rPCM12 PCM12_REG
+
+__REG PCM34_REG; /**< Sound channel 3&4 PCM amplitude (R) */
+#define rPCM34 PCM34_REG
+
+__REG IE_REG; /**< Interrupt enable */
+#define rIE IE_REG
+
+#define IEF_HILO 0b00010000
+#define IEF_SERIAL 0b00001000
+#define IEF_TIMER 0b00000100
+#define IEF_STAT 0b00000010
+#define IEF_VBLANK 0b00000001
+
+
+/* Square wave duty cycle */
+#define AUDLEN_DUTY_12_5 0b00000000
+#define AUDLEN_DUTY_25 0b01000000
+#define AUDLEN_DUTY_50 0b10000000
+#define AUDLEN_DUTY_75 0b11000000
+#define AUDLEN_LENGTH(x) (x)
+
+/* Audio envelope flags */
+#define AUDENV_VOL(x) ((x) << 4)
+#define AUDENV_UP 0b00001000
+#define AUDENV_DOWN 0b00000000
+#define AUDENV_LENGTH(x) (x)
+
+/* Audio trigger flags */
+#define AUDHIGH_RESTART 0b10000000
+#define AUDHIGH_LENGTH_ON 0b01000000
+#define AUDHIGH_LENGTH_OFF 0b00000000
+
+/* OAM attributes flags */
+#define OAMF_PRI 0b10000000 /**< BG and Window over Sprite Enabled */
+#define OAMF_YFLIP 0b01000000 /**< Sprite Y axis flip: Vertically mirrored */
+#define OAMF_XFLIP 0b00100000 /**< Sprite X axis flip: Horizontally mirrored */
+#define OAMF_PAL0 0b00000000 /**< Sprite Palette number: use OBP0 (Non-CGB Mode Only) */
+#define OAMF_PAL1 0b00010000 /**< Sprite Palette number: use OBP1 (Non-CGB Mode Only) */
+#define OAMF_BANK0 0b00000000 /**< Sprite Tile VRAM-Bank: Use Bank 0 (CGB Mode Only) */
+#define OAMF_BANK1 0b00001000 /**< Sprite Tile VRAM-Bank: Use Bank 1 (CGB Mode Only) */
+
+#define OAMF_CGB_PAL0 0b00000000 /**< Sprite CGB Palette number: use OCP0 (CGB Mode Only) */
+#define OAMF_CGB_PAL1 0b00000001 /**< Sprite CGB Palette number: use OCP1 (CGB Mode Only) */
+#define OAMF_CGB_PAL2 0b00000010 /**< Sprite CGB Palette number: use OCP2 (CGB Mode Only) */
+#define OAMF_CGB_PAL3 0b00000011 /**< Sprite CGB Palette number: use OCP3 (CGB Mode Only) */
+#define OAMF_CGB_PAL4 0b00000100 /**< Sprite CGB Palette number: use OCP4 (CGB Mode Only) */
+#define OAMF_CGB_PAL5 0b00000101 /**< Sprite CGB Palette number: use OCP5 (CGB Mode Only) */
+#define OAMF_CGB_PAL6 0b00000110 /**< Sprite CGB Palette number: use OCP6 (CGB Mode Only) */
+#define OAMF_CGB_PAL7 0b00000111 /**< Sprite CGB Palette number: use OCP7 (CGB Mode Only) */
+
+#define OAMF_PALMASK 0b00000111 /**< Mask for Sprite CGB Palette number (CGB Mode Only) */
+
+#define DEVICE_SCREEN_X_OFFSET 0 /**< Offset of visible screen (in tile units) from left edge of hardware map */
+#define DEVICE_SCREEN_Y_OFFSET 0 /**< Offset of visible screen (in tile units) from top edge of hardware map */
+#define DEVICE_SCREEN_WIDTH 20 /**< Width of visible screen in tile units */
+#define DEVICE_SCREEN_HEIGHT 18 /**< Height of visible screen in tile units */
+#define DEVICE_SCREEN_BUFFER_WIDTH 32 /**< Width of hardware map buffer in tile units */
+#define DEVICE_SCREEN_BUFFER_HEIGHT 32 /**< Height of hardware map buffer in tile units */
+#define DEVICE_SCREEN_MAP_ENTRY_SIZE 1 /**< Number of bytes per hardware map entry */
+#define DEVICE_SPRITE_PX_OFFSET_X 8 /**< Offset of sprite X coordinate origin (in pixels) from left edge of visible screen */
+#define DEVICE_SPRITE_PX_OFFSET_Y 16 /**< Offset of sprite Y coordinate origin (in pixels) from top edge of visible screen */
+#define DEVICE_SCREEN_PX_WIDTH (DEVICE_SCREEN_WIDTH * 8) /**< Width of visible screen in pixels */
+#define DEVICE_SCREEN_PX_HEIGHT (DEVICE_SCREEN_HEIGHT * 8) /**< Height of visible screen in pixels */
+
+#endif
diff --git a/gbdk/gbdk-lib/include/gb/isr.h b/gbdk/gbdk-lib/include/gb/isr.h
new file mode 100644
index 00000000..59b2165f
--- /dev/null
+++ b/gbdk/gbdk-lib/include/gb/isr.h
@@ -0,0 +1,74 @@
+/** @file gb/isr.h
+
+ Macros for creating raw interrupt service routines (ISRs)
+ which do not use the default GBDK ISR dispatcher.
+
+ Handlers installed this way will have less overhead than
+ ones which use the GBDK ISR dispatcher.
+*/
+#ifndef _ISR_H_INCLUDE_
+#define _ISR_H_INCLUDE_
+
+#include <stdint.h>
+#include <types.h>
+
+// #define VECTOR_VBL 0x40 // you can not define raw vector for VBlank interrupt
+#define VECTOR_STAT 0x48 /**< Address for the STAT interrupt vector */
+#define VECTOR_TIMER 0x50 /**< Address for the TIMER interrupt vector */
+#define VECTOR_SERIAL 0x58 /**< Address for the SERIAL interrupt vector */
+#define VECTOR_JOYPAD 0x60 /**< Address for the JOYPAD interrupt vector */
+
+typedef struct isr_vector_t {
+ uint8_t opcode;
+ void * func;
+} isr_vector_t;
+
+/** Creates an interrupt vector at the given address for a raw
+ interrupt service routine (which does not use the GBDK ISR dispatcher)
+
+ @param ADDR Address of the interrupt vector, any of: @ref VECTOR_STAT, @ref VECTOR_TIMER, @ref VECTOR_SERIAL, @ref VECTOR_JOYPAD
+ @param FUNC ISR function supplied by the user
+
+ This cannot be used with the VBLANK interrupt.
+
+ Do not use this in combination with interrupt installers
+ that rely on the default GBDK ISR dispatcher such as
+ @ref add_TIM(), @ref remove_TIM()
+ (and the same for all other interrupts).
+
+ Example:
+ \code{.c}
+ #include <gb/isr.h>
+
+ void TimerISR() __critical __interrupt {
+ // some ISR code here
+ }
+
+ ISR_VECTOR(VECTOR_TIMER, TimerISR)
+ \endcode
+
+ @see ISR_NESTED_VECTOR, set_interrupts
+*/
+#define ISR_VECTOR(ADDR, FUNC) \
+static const isr_vector_t AT((ADDR)) __ISR_ ## ADDR = {0xc3, (void *)&(FUNC)};
+
+typedef struct isr_nested_vector_t {
+ uint8_t opcode[2];
+ void * func;
+} isr_nested_vector_t;
+
+/** Creates an interrupt vector at the given address for a raw
+ interrupt service routine allowing nested interrupts
+
+ @param ADDR Address of the interrupt vector, any of: @ref VECTOR_STAT, @ref VECTOR_TIMER, @ref VECTOR_SERIAL, @ref VECTOR_JOYPAD
+ @param FUNC ISR function
+
+ This cannot be used with the VBLANK interrupt
+
+ @see ISR_VECTOR
+*/
+#define ISR_NESTED_VECTOR(ADDR, FUNC) \
+static const isr_nested_vector_t AT((ADDR)) __ISR_ ## ADDR = {{0xfb, 0xc3}, (void *)&(FUNC)};
+
+
+#endif // _ISR_H_INCLUDE_
diff --git a/gbdk/gbdk-lib/include/gb/metasprites.h b/gbdk/gbdk-lib/include/gb/metasprites.h
new file mode 100644
index 00000000..5bb27974
--- /dev/null
+++ b/gbdk/gbdk-lib/include/gb/metasprites.h
@@ -0,0 +1,245 @@
+/** @file gb/metasprites.h
+
+ # Metasprite support
+
+ A metasprite is a larger sprite made up from a
+ collection of smaller individual hardware sprites.
+ Different frames of the same metasprites can share
+ tile data.
+
+ The api supports metasprites in both
+ @ref SPRITES_8x8 and @ref SPRITES_8x16 mode. If
+ 8x16 mode is used then the height of the metasprite
+ must be a multiple of 16.
+
+ The origin (pivot) for the metasprite is not required
+ to be in the upper left-hand corner as with regular
+ hardware sprites.
+
+ Use the @ref utility_png2asset tool to convert single
+ or multiple frames of graphics into metasprite
+ structured data for use with the ...metasprite...()
+ functions.
+
+ # Metasprites composed of variable numbers of sprites
+
+ When using png2asset, it's common for the output of
+ different frames to be composed of different numbers
+ of hardware sprites (since it's trying to create each
+ frame as efficiently as possible). Due to that, it's
+ good practice to clear out (hide) unused sprites in the
+ shadow_OAM that have been set by previous frames.
+
+ \code
+ // Example:
+ // Hide rest of the hardware sprites, because amount
+ // of sprites differ between animation frames.
+ // (where hiwater == last hardware sprite used + 1)
+ for (uint8_t i = hiwater; i < 40; i++) shadow_OAM[i].y = 0;
+ \endcode
+
+ @anchor metasprite_and_sprite_properties
+ # Metasprites and sprite properties (including cgb palette)
+
+ When the move_metasprite_*() functions are called they
+ update all properties for the affected sprites in the
+ Shadow OAM. This means any existing property flags set
+ for a sprite (CGB palette, BG/WIN priority, Tile VRAM Bank)
+ will get overwritten.
+
+ How to use sprite property flags with metasprites:
+ - Metsaprite structures can be copied into RAM so their
+ property flags can be modified at runtime.
+ - The metasprite structures can have the property flags
+ modified before compilation (such as with `-sp <props>`
+ in the @ref utility_png2asset "png2asset" tool).
+ - Update properties for the affected sprites after calling
+ a move_metasprite_*() function.
+
+ The following functions are only available for Game Boy and
+ related clone consoles due to lack of hardware support for
+ sprite flipping in other consoles. See @ref docs_consoles_supported_list
+ - @ref move_metasprite_vflip()
+ - @ref move_metasprite_hflip()
+ - @ref move_metasprite_hvflip()
+*/
+
+#ifndef _METASPRITES_H_INCLUDE
+#define _METASPRITES_H_INCLUDE
+
+#include <gb/hardware.h>
+#include <types.h>
+#include <stdint.h>
+
+/** Metasprite sub-item structure
+ @param dy (int8_t) Y coordinate of the sprite relative to the metasprite origin (pivot)
+ @param dx (int8_t) X coordinate of the sprite relative to the metasprite origin (pivot)
+ @param dtile (uint8_t) Start tile relative to the metasprites own set of tiles
+ @param props (uint8_t) Property Flags
+
+ Metasprites are built from multiple metasprite_t items (one for each sub-sprite)
+ and a pool of tiles they reference. If a metasprite has multiple frames then each
+ frame will be built from some number of metasprite_t items (which may vary based
+ on how many sprites are required for that particular frame).
+
+ A metasprite frame is terminated with a {metasprite_end} entry.
+*/
+typedef struct metasprite_t {
+ int8_t dy, dx;
+ uint8_t dtile;
+ uint8_t props;
+} metasprite_t;
+
+#define metasprite_end -128
+#define METASPR_ITEM(dy,dx,dt,a) {(dy),(dx),(dt),(a)}
+#define METASPR_TERM {metasprite_end}
+
+extern const void * __current_metasprite;
+extern uint8_t __current_base_tile;
+extern uint8_t __render_shadow_OAM;
+
+
+static uint8_t __move_metasprite(uint8_t id, uint8_t x, uint8_t y) OLDCALL;
+static uint8_t __move_metasprite_vflip(uint8_t id, uint8_t x, uint8_t y) OLDCALL;
+static uint8_t __move_metasprite_hflip(uint8_t id, uint8_t x, uint8_t y) OLDCALL;
+static uint8_t __move_metasprite_hvflip(uint8_t id, uint8_t x, uint8_t y) OLDCALL;
+static void __hide_metasprite(uint8_t id) OLDCALL;
+
+/**
+ * Hides all hardware sprites in range from <= X < to
+ * @param from start OAM index
+ * @param to finish OAM index
+ */
+void hide_sprites_range(UINT8 from, UINT8 to) OLDCALL PRESERVES_REGS(b, c);
+
+/** Moves metasprite to the absolute position x and y
+
+ @param metasprite Pointer to the first struct of the metasprite (for the desired frame)
+ @param base_tile Number of the first tile where the metasprite's tiles start
+ @param base_sprite Number of the first hardware sprite to be used by the metasprite
+ @param x Absolute x coordinate of the sprite
+ @param y Absolute y coordinate of the sprite
+
+ Moves __metasprite__ to the absolute position __x__ and __y__
+ (with __no flip__ on the X or Y axis). Hardware sprites are
+ allocated starting from __base_sprite__, using tiles
+ starting from __base_tile__.
+
+ Sets:
+ \li __current_metasprite = metasprite;
+ \li __current_base_tile = base_tile;
+
+ Note: Overwrites OAM sprite properties (such as CGB Palette), see
+ @ref metasprite_and_sprite_properties "Metasprites and sprite properties".
+
+ @return Number of hardware sprites used to draw this metasprite
+ */
+inline uint8_t move_metasprite(const metasprite_t * metasprite, uint8_t base_tile, uint8_t base_sprite, uint8_t x, uint8_t y) {
+ __current_metasprite = metasprite;
+ __current_base_tile = base_tile;
+ return __move_metasprite(base_sprite, x, y);
+}
+
+/** Moves metasprite to the absolute position x and y, __flipped on the Y axis__
+
+ @param metasprite Pointer to the first struct of the metasprite (for the desired frame)
+ @param base_tile Number of the first tile where the metasprite's tiles start
+ @param base_sprite Number of the first hardware sprite to be used by the metasprite
+ @param x Absolute x coordinate of the sprite
+ @param y Absolute y coordinate of the sprite
+
+ Same as @ref move_metasprite(), but with the metasprite flipped on the Y axis only.
+
+ Sets:
+ \li __current_metasprite = metasprite;
+ \li __current_base_tile = base_tile;
+
+ Note: Overwrites OAM sprite properties (such as CGB palette), see
+ @ref metasprite_and_sprite_properties "Metasprites and sprite properties".
+
+ This function is only available on Game Boy and related clone consoles.
+
+ @return Number of hardware sprites used to draw this metasprite
+
+ @see move_metasprite()
+*/
+inline uint8_t move_metasprite_vflip(const metasprite_t * metasprite, uint8_t base_tile, uint8_t base_sprite, uint8_t x, uint8_t y) {
+ __current_metasprite = metasprite;
+ __current_base_tile = base_tile;
+ return __move_metasprite_vflip(base_sprite, x - 8, y);
+}
+
+
+/** Moves metasprite to the absolute position x and y, __flipped on the X axis__
+
+ @param metasprite Pointer to the first struct of the metasprite (for the desired frame)
+ @param base_tile Number of the first tile where the metasprite's tiles start
+ @param base_sprite Number of the first hardware sprite to be used by the metasprite
+ @param x Absolute x coordinate of the sprite
+ @param y Absolute y coordinate of the sprite
+
+ Same as @ref move_metasprite(), but with the metasprite flipped on the X axis only.
+
+ Sets:
+ \li __current_metasprite = metasprite;
+ \li __current_base_tile = base_tile;
+
+ Note: Overwrites OAM sprite properties (such as CGB palette), see
+ @ref metasprite_and_sprite_properties "Metasprites and sprite properties".
+
+ This function is only available on Game Boy and related clone consoles.
+
+ @return Number of hardware sprites used to draw this metasprite
+
+ @see move_metasprite()
+*/
+inline uint8_t move_metasprite_hflip(const metasprite_t * metasprite, uint8_t base_tile, uint8_t base_sprite, uint8_t x, uint8_t y) {
+ __current_metasprite = metasprite;
+ __current_base_tile = base_tile;
+ return __move_metasprite_hflip(base_sprite, x, y - ((LCDC_REG & 0x04U) ? 16 : 8) );
+}
+
+/** Moves metasprite to the absolute position x and y, __flipped on the X and Y axis__
+
+ @param metasprite Pointer to the first struct of the metasprite (for the desired frame)
+ @param base_tile Number of the first tile where the metasprite's tiles start
+ @param base_sprite Number of the first hardware sprite to be used by the metasprite
+ @param x Absolute x coordinate of the sprite
+ @param y Absolute y coordinate of the sprite
+
+ Same as @ref move_metasprite(), but with the metasprite flipped on both the X and Y axis.
+
+ Sets:
+ \li __current_metasprite = metasprite;
+ \li __current_base_tile = base_tile;
+
+ Note: Overwrites OAM sprite properties (such as CGB palette), see
+ @ref metasprite_and_sprite_properties "Metasprites and sprite properties".
+
+ This function is only available on Game Boy and related clone consoles.
+
+ @return Number of hardware sprites used to draw this metasprite
+
+ @see move_metasprite()
+*/
+inline uint8_t move_metasprite_hvflip(const metasprite_t * metasprite, uint8_t base_tile, uint8_t base_sprite, uint8_t x, uint8_t y) {
+ __current_metasprite = metasprite;
+ __current_base_tile = base_tile;
+ return __move_metasprite_hvflip(base_sprite, x - 8, y - ((LCDC_REG & 0x04U) ? 16 : 8));
+}
+
+/** Hides a metasprite from the screen
+
+ @param metasprite Pointer to first struct of the desired metasprite frame
+ @param base_sprite Number of hardware sprite to start with
+
+ Sets:
+ \li __current_metasprite = metasprite;
+
+ **/
+inline void hide_metasprite(const metasprite_t * metasprite, uint8_t base_sprite) {
+ __current_metasprite = metasprite;
+ __hide_metasprite(base_sprite);
+}
+
+#endif
diff --git a/gbdk/gbdk-lib/include/gb/sgb.h b/gbdk/gbdk-lib/include/gb/sgb.h
new file mode 100644
index 00000000..ab37a04f
--- /dev/null
+++ b/gbdk/gbdk-lib/include/gb/sgb.h
@@ -0,0 +1,65 @@
+/** @file gb/sgb.h
+ Super Gameboy definitions.
+
+ See the example SGB project for additional details.
+*/
+#ifndef _SGB_H
+#define _SGB_H
+
+#include <types.h>
+#include <stdint.h>
+
+#define SGB_PAL_01 0x00U /**< SGB Command: Set SGB Palettes 0 & 1 */
+#define SGB_PAL_23 0x01U /**< SGB Command: Set SGB Palettes 2 & 3 */
+#define SGB_PAL_03 0x02U /**< SGB Command: Set SGB Palettes 0 & 3 */
+#define SGB_PAL_12 0x03U /**< SGB Command: Set SGB Palettes 1 & 2 */
+#define SGB_ATTR_BLK 0x04U /**< SGB Command: Set color attributes for rectangular regions */
+#define SGB_ATTR_LIN 0x05U /**< SGB Command: Set color attributes for horizontal or vertical character lines */
+#define SGB_ATTR_DIV 0x06U /**< SGB Command: Split screen in half and assign separate color attribes to each side and the divider */
+#define SGB_ATTR_CHR 0x07U /**< SGB Command: Set color attributes for separate charactersSet SGB Palette 0,1 Data */
+#define SGB_SOUND 0x08U /**< SGB Command: Start and stop a internal sound effect, and sounds using internal tone data */
+#define SGB_SOU_TRN 0x09U /**< SGB Command: Transfer sound code or data to the SNES APU RAM */
+#define SGB_PAL_SET 0x0AU /**< SGB Command: Apply (previously transferred) SGB system color palettes to actual SNES palettes */
+#define SGB_PAL_TRN 0x0BU /**< SGB Command: Transfer palette data into SGB system color palettes */
+#define SGB_ATRC_EN 0x0CU /**< SGB Command: Enable/disable Attraction mode. It is enabled by default */
+#define SGB_TEST_EN 0x0DU /**< SGB Command: Enable/disable test mode for "SGB-CPU variable clock speed function" */
+#define SGB_ICON_EN 0x0EU /**< SGB Command: Enable/disable ICON functionality */
+#define SGB_DATA_SND 0x0FU /**< SGB Command: Write one or more bytes into SNES Work RAM */
+#define SGB_DATA_TRN 0x10U /**< SGB Command: Transfer code or data into SNES RAM */
+#define SGB_MLT_REQ 0x11U /**< SGB Command: Request multiplayer mode (input from more than one joypad) */
+#define SGB_JUMP 0x12U /**< SGB Command: Set the SNES program counter and NMI (vblank interrupt) handler to specific addresses */
+#define SGB_CHR_TRN 0x13U /**< SGB Command: Transfer tile data (characters) to SNES Tile memory */
+#define SGB_PCT_TRN 0x14U /**< SGB Command: Transfer tile map and palette data to SNES BG Map memory */
+#define SGB_ATTR_TRN 0x15U /**< SGB Command: Transfer data to (color) Attribute Files (ATFs) in SNES RAM */
+#define SGB_ATTR_SET 0x16U /**< SGB Command: Transfer attributes from (color) Attribute Files (ATF) to the Game Boy window */
+#define SGB_MASK_EN 0x17U /**< SGB Command: Modify Game Boy window mask settings */
+#define SGB_OBJ_TRN 0x18U /**< SGB Command: Transfer OBJ attributes to SNES OAM memory */
+
+
+/** Returns a non-null value if running on Super GameBoy */
+uint8_t sgb_check() OLDCALL PRESERVES_REGS(b, c);
+
+/** Transfer a SGB packet
+
+ @param packet Pointer to buffer with SGB packet data.
+
+ The first byte of __packet__ should be a SGB command,
+ then up to 15 bytes of command parameter data.
+
+ See the `sgb_border` GBDK example project for a
+ demo of how to use these the sgb functions.
+
+ When using the SGB with a PAL SNES, a delay should be added
+ just after program startup such as:
+
+ \code{.c}
+ // Wait 4 frames
+ // For PAL SNES this delay is required on startup
+ for (uint8_t i = 4; i != 0; i--) wait_vbl_done();
+ \endcode
+
+ @see sgb_check()
+*/
+void sgb_transfer(uint8_t * packet) OLDCALL PRESERVES_REGS(b, c);
+
+#endif /* _SGB_H */
diff --git a/gbdk/gbdk-lib/include/gbdk/bcd.h b/gbdk/gbdk-lib/include/gbdk/bcd.h
new file mode 100644
index 00000000..f2e9ef3b
--- /dev/null
+++ b/gbdk/gbdk-lib/include/gbdk/bcd.h
@@ -0,0 +1,12 @@
+#ifndef __GBDK_BCD_H_INCLUDE
+#define __GBDK_BCD_H_INCLUDE
+
+#if defined(__TARGET_gb) || defined(__TARGET_ap) || defined(__TARGET_duck)
+ #include <gb/bcd.h>
+#elif defined(__TARGET_sms) || defined(__TARGET_gg) || defined(__TARGET_msxdos)
+ #error Not implemented yet
+#else
+ #error Unrecognized port
+#endif
+
+#endif \ No newline at end of file
diff --git a/gbdk/gbdk-lib/include/gbdk/console.h b/gbdk/gbdk-lib/include/gbdk/console.h
new file mode 100644
index 00000000..9458829b
--- /dev/null
+++ b/gbdk/gbdk-lib/include/gbdk/console.h
@@ -0,0 +1,45 @@
+/** @file gbdk/console.h
+ Console functions that work like Turbo C's.
+
+ The font is 8x8, making the screen 20x18 characters.
+*/
+#ifndef _CONSOLE_H
+#define _CONSOLE_H
+
+#include <types.h>
+#include <stdint.h>
+
+/** Move the cursor to an absolute position at __x, y__.
+
+ __x__ and __y__ have units of tiles (8 pixels per unit)
+ @see setchar()
+ */
+void gotoxy(uint8_t x, uint8_t y) OLDCALL;
+
+/** Returns the current X position of the cursor.
+
+ @see gotoxy()
+ */
+uint8_t posx() OLDCALL;
+
+/** Returns the current Y position of the cursor.
+
+ @see gotoxy()
+ */
+uint8_t posy() OLDCALL;
+
+/** Writes out a single character at the current cursor
+ position.
+
+ Does not update the cursor or interpret the character.
+
+ @see gotoxy()
+*/
+void setchar(char c) OLDCALL;
+
+/** Clears the screen
+*/
+void cls();
+
+
+#endif /* _CONSOLE_H */
diff --git a/gbdk/gbdk-lib/include/gbdk/emu_debug.h b/gbdk/gbdk-lib/include/gbdk/emu_debug.h
new file mode 100644
index 00000000..33f559af
--- /dev/null
+++ b/gbdk/gbdk-lib/include/gbdk/emu_debug.h
@@ -0,0 +1,179 @@
+/** @file gbdk/emu_debug.h
+
+ Debug window logging and profiling support for emulators (BGB, Emulicious, etc).
+
+ Also see the `emu_debug` example project included with gbdk.
+
+ See the BGB Manual for more information
+ ("expressions, breakpoint conditions, and debug messages")
+ http://bgb.bircd.org/manual.html#expressions
+
+*/
+
+#ifndef __GBDK_EMU_DEBUG_H_INCLUDE
+#define __GBDK_EMU_DEBUG_H_INCLUDE
+
+#include <types.h>
+
+#if defined(__TARGET_gb) || defined(__TARGET_ap) || defined(__TARGET_sms) || defined(__TARGET_gg)
+
+/** Macro to display a message in the emulator debug message window
+
+ @param message_text Quoted text string to display in the debug message window
+
+ The following special parameters can be
+ used when bracketed with "%" characters.
+ \li CPU registers: AF, BC, DE, HL, SP, PC, B, C, D,
+ E, H, L, A, ZERO, ZF, Z, CARRY, CY, IME, ALLREGS
+ \li Other state values: ROMBANK, XRAMBANK, SRAMBANK,
+ WRAMBANK, VRAMBANK, TOTALCLKS, LASTCLKS, CLKS2VBLANK
+
+ Example: print a message along with the currently active ROM bank.
+ \code{.c}
+ EMU_MESSAGE("Current ROM Bank is: %ROMBANK%");
+ \endcode
+
+
+ See the BGB Manual for more information
+ ("expressions, breakpoint conditions, and debug messages")
+ http://bgb.bircd.org/manual.html#expressions
+
+ @see EMU_PROFILE_BEGIN(), EMU_PROFILE_END()
+ */
+#define EMU_MESSAGE(message_text) EMU_MESSAGE1(EMU_MACRONAME(__LINE__), message_text)
+#define BGB_MESSAGE(message_text) EMU_MESSAGE(message_text)
+
+/// \cond DOXYGEN_DO_NOT_DOCUMENT
+#define EMU_MACRONAME(A) EMU_MACRONAME1(A)
+#define EMU_MACRONAME1(A) EMULOG##A
+
+#define EMU_MESSAGE1(name, message_text) \
+__asm \
+.MACRO name msg_t, ?llbl\
+ ld d, d \
+ jr llbl \
+ .dw 0x6464 \
+ .dw 0x0000 \
+ .ascii msg_t \
+llbl: \
+.ENDM \
+name ^/message_text/ \
+__endasm
+
+#define EMU_MESSAGE_SUFFIX(message_text, message_suffix) EMU_MESSAGE3(EMU_MACRONAME(__LINE__), message_text, message_suffix)
+#define EMU_MESSAGE3(name, message_text, message_suffix) \
+__asm \
+.MACRO name msg_t, msg_s, ?llbl\
+ ld d, d \
+ jr llbl \
+ .dw 0x6464 \
+ .dw 0x0000 \
+ .ascii msg_t \
+ .ascii msg_s \
+llbl: \
+.ENDM \
+name ^/message_text/, ^/message_suffix/ \
+__endasm
+/// \endcond DOXYGEN_DO_NOT_DOCUMENT
+
+/** Macro to __Start__ a profiling block for the emulator (BGB, Emulicious, etc)
+
+ @param MSG Quoted text string to display in the
+ debug message window along with the result
+
+ To complete the profiling block and print
+ the result call @ref EMU_PROFILE_END.
+
+ @see EMU_PROFILE_END(), EMU_MESSAGE()
+ */
+#define EMU_PROFILE_BEGIN(MSG) EMU_MESSAGE_SUFFIX(MSG, "%ZEROCLKS%");
+#define BGB_PROFILE_BEGIN(MSG) EMU_PROFILE_BEGIN(MSG)
+/** Macro to __End__ a profiling block and print the results in the emulator debug message window
+
+ @param MSG Quoted text string to display in the
+ debug message window along with the result
+
+ This should only be called after a previous call
+ to @ref EMU_PROFILE_BEGIN()
+
+ The results are in Emulator clock units, which are
+ "1 nop in [CGB] doublespeed mode".
+
+ So when running in Normal Speed mode (i.e. non-CGB doublespeed)
+ the printed result should be __divided by 2__ to get the actual
+ ellapsed cycle count.
+
+ If running in CB Double Speed mode use the below call instead,
+ it correctly compensates for the speed difference. In this
+ scenario, the result does __not need to be divided by 2__ to
+ get the ellapsed cycle count.
+ \code{.c}
+ EMU_MESSAGE("NOP TIME: %-4+LASTCLKS%");
+ \endcode
+
+ @see EMU_PROFILE_BEGIN(), EMU_MESSAGE()
+ */
+#if defined(NINTENDO)
+#define EMU_PROFILE_END(MSG) EMU_MESSAGE_SUFFIX(MSG,"%-8+LASTCLKS%");
+#define BGB_PROFILE_END(MSG) EMU_PROFILE_END(MSG)
+#elif defined(SEGA)
+#define EMU_PROFILE_END(MSG) EMU_MESSAGE_SUFFIX(MSG,"%-16+LASTCLKS%");
+#define BGB_PROFILE_END(MSG) EMU_PROFILE_END(MSG)
+#endif
+
+#define EMU_TEXT(MSG) EMU_MESSAGE(MSG)
+#define BGB_TEXT(MSG) EMU_TEXT(MSG)
+
+/** Display preset debug information in the Emulator debug messages window.
+
+ This function is equivalent to:
+ \code{.c}
+ EMU_MESSAGE("PROFILE,%(SP+$0)%,%(SP+$1)%,%A%,%TOTALCLKS%,%ROMBANK%,%WRAMBANK%");
+ \endcode
+
+*/
+#if defined(NINTENDO)
+void EMU_profiler_message();
+#define BGB_profiler_message() EMU_profiler_message()
+#endif // NINTENDO
+
+/** Print the string and arguments given by format to the emulator debug message window
+
+ @param format The format string as per printf
+
+ Does not return the number of characters printed.
+ Result string MUST BE LESS OR EQUAL THAN 128 BYTES LONG, INCLUDING THE TRAILIG ZERO BYTE!
+
+ Currently supported:
+ \li \%hx (char as hex)
+ \li \%hu (unsigned char)
+ \li \%hd (signed char)
+ \li \%c (character)
+ \li \%u (unsigned int)
+ \li \%d (signed int)
+ \li \%x (unsigned int as hex)
+ \li \%s (string)
+
+ Warning: to correctly pass chars for printing as chars, they *must*
+ be explicitly re-cast as such when calling the function.
+ See @ref docs_chars_varargs for more details.
+ */
+void EMU_printf(const char *format, ...) OLDCALL;
+#define BGB_printf(...) EMU_printf(__VA_ARGS__)
+
+#ifdef NINTENDO
+static void * __EMU_PROFILER_INIT = &EMU_profiler_message;
+#endif // NINTENDO
+
+/** The Emulator will break into debugger when encounters this line
+ */
+#define EMU_BREAKPOINT __asm__("ld b, b");
+#define BGB_BREAKPOINT EMU_BREAKPOINT
+
+#elif defined(__TARGET_duck)
+ #error Not implemented yet
+#else
+ #error Unrecognized port
+#endif
+
+#endif \ No newline at end of file
diff --git a/gbdk/gbdk-lib/include/gbdk/far_ptr.h b/gbdk/gbdk-lib/include/gbdk/far_ptr.h
new file mode 100644
index 00000000..39f75d4e
--- /dev/null
+++ b/gbdk/gbdk-lib/include/gbdk/far_ptr.h
@@ -0,0 +1,99 @@
+/** @file gbdk/far_ptr.h
+
+ Far pointers include a segment (bank) selector so they are
+ able to point to addresses (functions or data) outside
+ of the current bank (unlike normal pointers which are not
+ bank-aware).
+
+ See the `banks_farptr` example project included with gbdk.
+
+ @todo Add link to a discussion about banking (such as, how to assign code and variables to banks)
+*/
+
+#ifndef __FAR_PTR_H_INCLUDE
+#define __FAR_PTR_H_INCLUDE
+
+#include <types.h>
+#include <stdint.h>
+
+/** Macro to obtain a far pointer at compile-time
+ @param ofs Memory address within the given Segment (Bank)
+ @param seg Segment (Bank) number
+
+ @returns A far pointer (type @ref FAR_PTR)
+*/
+#define TO_FAR_PTR(ofs, seg) (((FAR_PTR)seg << 16) | (FAR_PTR)ofs)
+
+/** Macro to get the Segment (Bank) number of a far pointer
+ @param ptr A far pointer (type @ref FAR_PTR)
+
+ @returns Segment (Bank) of the far pointer (type uint16_t)
+*/
+#define FAR_SEG(ptr) (((union __far_ptr *)&ptr)->segofs.seg)
+
+/** Macro to get the Offset (address) of a far pointer
+ @param ptr A far pointer (type @ref FAR_PTR)
+
+ @returns Offset (address) of the far pointer (type void *)
+*/
+#define FAR_OFS(ptr) (((union __far_ptr *)&ptr)->segofs.ofs)
+
+#define FAR_FUNC(ptr, typ) ((typ)(((union __far_ptr *)&ptr)->segfn.fn))
+
+/** Macro to call a function at far pointer __ptr__ of type __typ__
+ @param ptr Far pointer of a function to call (type @ref FAR_PTR)
+ @param typ Type to cast the function far pointer to.
+ @param ... VA Args list of parameters for the function
+
+ __type__ should match the definition of the function being called. For example:
+ \code{.c}
+ // A function in bank 2
+ #pragma bank 2
+ uint16_t some_function(uint16_t param1, uint16_t param2) __banked { return 1; };
+
+ ...
+ // Code elsewhere, such as unbanked main()
+ // This type declaration should match the above function
+ typedef uint16_t (*some_function_t)(uint16_t, uint16_t) __banked;
+
+ // Using FAR_CALL() with the above as *ptr*, *typ*, and two parameters.
+ result = FAR_CALL(some_function, some_function_t, 100, 50);
+ \endcode
+
+ @returns Value returned by the function (if present)
+*/
+#define FAR_CALL(ptr, typ, ...) (__call_banked_ptr=ptr,((typ)(&__call__banked))(__VA_ARGS__))
+
+/** Type for storing a FAR_PTR
+*/
+typedef uint32_t FAR_PTR;
+
+/** Union for working with members of a FAR_PTR
+*/
+union __far_ptr {
+ FAR_PTR ptr;
+ struct {
+ void * ofs;
+ uint16_t seg;
+ } segofs;
+ struct {
+ void (*fn)();
+ uint16_t seg;
+ } segfn;
+};
+
+extern volatile FAR_PTR __call_banked_ptr;
+extern volatile void * __call_banked_addr;
+extern volatile uint8_t __call_banked_bank;
+
+void __call__banked();
+
+/** Obtain a far pointer at runtime
+ @param ofs Memory address within the given Segment (Bank)
+ @param seg Segment (Bank) number
+
+ @returns A far pointer (type @ref FAR_PTR)
+*/
+uint32_t to_far_ptr(void* ofs, uint16_t seg) OLDCALL;
+
+#endif \ No newline at end of file
diff --git a/gbdk/gbdk-lib/include/gbdk/font.h b/gbdk/gbdk-lib/include/gbdk/font.h
new file mode 100644
index 00000000..05af2e49
--- /dev/null
+++ b/gbdk/gbdk-lib/include/gbdk/font.h
@@ -0,0 +1,78 @@
+/** @file gbdk/font.h
+ Multiple font support for the GameBoy
+ Michael Hope, 1999
+ michaelh@earthling.net
+*/
+#ifndef __FONT_H
+#define __FONT_H
+
+#include <types.h>
+#include <stdint.h>
+
+/** Various flags in the font header.
+ */
+#define FONT_256ENCODING 0
+#define FONT_128ENCODING 1
+#define FONT_NOENCODING 2
+
+#define FONT_COMPRESSED 4
+
+/* See gb.h/M_NO_SCROLL and gb.h/M_NO_INTERP */
+
+/** font_t is a handle to a font loaded by font_load().
+ It can be used with @ref font_set() */
+typedef uint16_t font_t;
+
+
+/*! \defgroup gbdk_fonts List of gbdk fonts
+ @{
+*/
+
+/** The default fonts */
+extern uint8_t font_spect[], font_italic[], font_ibm[], font_min[];
+
+/** Backwards compatible font */
+extern uint8_t font_ibm_fixed[];
+
+ /*! @} End of gbdk_fonts */
+
+
+/** Initializes the font system.
+ Should be called before other font functions.
+ */
+void font_init();
+
+/** Load a font and set it as the current font.
+ @param font Pointer to a font to load (usually a gbdk font)
+
+ @return Handle to the loaded font, which can be used with @ref font_set()
+ @see font_init(), font_set(), gbdk_fonts
+ */
+font_t font_load(void *font) OLDCALL;
+
+/** Set the current font.
+ @param font_handle handle of a font returned by @ref font_load()
+
+ @return The previously used font handle.
+ @see font_init(), font_load()
+*/
+font_t font_set(font_t font_handle) OLDCALL;
+
+/* Use mode() and color() to set the font modes and colours */
+
+/** Internal representation of a font.
+ What a font_t really is */
+typedef struct sfont_handle mfont_handle;
+typedef struct sfont_handle *pmfont_handle;
+
+/** Font handle structure
+*/
+struct sfont_handle {
+ uint8_t first_tile; /**< First tile used for font */
+ void *font; /**< Pointer to the base of the font */
+};
+
+/** Set the current __foreground__ colour (for pixels), __background__ colour */
+void font_color(uint8_t forecolor, uint8_t backcolor) OLDCALL;
+
+#endif /* __FONT_H */
diff --git a/gbdk/gbdk-lib/include/gbdk/gbdecompress.h b/gbdk/gbdk-lib/include/gbdk/gbdecompress.h
new file mode 100644
index 00000000..5865dd23
--- /dev/null
+++ b/gbdk/gbdk-lib/include/gbdk/gbdecompress.h
@@ -0,0 +1,12 @@
+#ifndef __GB_DECOMPRESS_H_INCLUDE
+#define __GB_DECOMPRESS_H_INCLUDE
+
+#if defined(__TARGET_gb) || defined(__TARGET_ap) || defined(__TARGET_duck)
+ #include <gb/gbdecompress.h>
+#elif defined(__TARGET_sms) || defined(__TARGET_gg)
+ #include <sms/gbdecompress.h>
+#else
+ #error Unrecognized port
+#endif
+
+#endif \ No newline at end of file
diff --git a/gbdk/gbdk-lib/include/gbdk/gbdk-lib.h b/gbdk/gbdk-lib/include/gbdk/gbdk-lib.h
new file mode 100644
index 00000000..8c9a6570
--- /dev/null
+++ b/gbdk/gbdk-lib/include/gbdk/gbdk-lib.h
@@ -0,0 +1,26 @@
+/** @file gbdk/gbdk-lib.h
+ Settings for the greater library system.
+*/
+#ifndef GBDK_LIB_INCLUDE
+#define GBDK_LIB_INCLUDE
+
+#if defined(__PORT_sm83)
+ #include <asm/sm83/provides.h>
+#elif defined(__PORT_z80)
+ #include <asm/z80/provides.h>
+#else
+ #error Unrecognized port
+#endif
+
+
+#ifndef USE_C_MEMCPY
+#define USE_C_MEMCPY 1
+#endif
+#ifndef USE_C_STRCPY
+#define USE_C_STRCPY 1
+#endif
+#ifndef USE_C_STRCMP
+#define USE_C_STRCMP 1
+#endif
+
+#endif
diff --git a/gbdk/gbdk-lib/include/gbdk/incbin.h b/gbdk/gbdk-lib/include/gbdk/incbin.h
new file mode 100644
index 00000000..b230c46c
--- /dev/null
+++ b/gbdk/gbdk-lib/include/gbdk/incbin.h
@@ -0,0 +1,84 @@
+/** @file gbdk/incbin.h
+
+ Allows binary data from other files to be included
+ into a C source file.
+
+ It is implemented using asm .incbin and macros.
+
+ See the `incbin` example project for a demo of how to use it.
+*/
+#ifndef _INCBIN_H
+#define _INCBIN_H
+
+#include <stdint.h>
+
+
+/** Creates extern entries for accessing a INCBIN() generated
+ variable and it's size in another source file.
+
+ @param VARNAME Name of the variable used with INCBIN
+
+ An entry is created for the variable and it's size variable.
+
+ @ref INCBIN(), INCBIN_SIZE()
+*/
+#define INCBIN_EXTERN(VARNAME) extern const uint8_t VARNAME[]; \
+extern const void __size_ ## VARNAME; \
+extern const void __bank_ ## VARNAME;
+
+/** Obtains the __size in bytes__ of the INCBIN() generated data
+
+ @param VARNAME Name of the variable used with INCBIN
+
+ Requires @ref INCBIN_EXTERN() to have been called earlier in the source file
+
+ @ref INCBIN(), INCBIN_EXTERN()
+*/
+#define INCBIN_SIZE(VARNAME) ( (uint16_t) & __size_ ## VARNAME )
+
+/** Obtains the __bank number__ of the INCBIN() generated data
+
+ @param VARNAME Name of the variable used with INCBIN
+
+ Requires @ref INCBIN_EXTERN() to have been called earlier in the source file
+
+ @ref INCBIN(), INCBIN_EXTERN()
+*/
+#ifndef BANK
+#define BANK(VARNAME) ( (uint8_t) & __bank_ ## VARNAME )
+#endif
+
+/** Includes binary data into a C source file
+
+ @param VARNAME Variable name to use
+ @param FILEPATH Path to the file which will be binary included into the C source file
+
+ __filepath__ is relative to the working directory of the tool
+ that is calling it (often a makefile's working directory), __NOT__
+ to the file it's being included into.
+
+ The variable name is not modified and can be used as-is.
+
+ @see INCBIN_SIZE() for obtaining the size of the included data.
+ @see BANK() for obtaining the bank number of the included data.
+
+ Use @ref INCBIN_EXTERN() within another source file
+ to make the variable and it's data accesible there.
+*/
+#define INCBIN(VARNAME, FILEPATH) void __func_ ## VARNAME() __banked __naked { \
+__asm \
+_ ## VARNAME:: \
+1$: \
+ .incbin FILEPATH \
+2$: \
+ ___size_ ## VARNAME = (2$-1$) \
+ .globl ___size_ ## VARNAME \
+ .local b___func_ ## VARNAME \
+ ___bank_ ## VARNAME = b___func_ ## VARNAME \
+ .globl ___bank_ ## VARNAME \
+__endasm; \
+}
+
+#endif // _INCBIN_H
+
+
diff --git a/gbdk/gbdk-lib/include/gbdk/metasprites.h b/gbdk/gbdk-lib/include/gbdk/metasprites.h
new file mode 100644
index 00000000..4b5ce011
--- /dev/null
+++ b/gbdk/gbdk-lib/include/gbdk/metasprites.h
@@ -0,0 +1,14 @@
+#ifndef __PLAT_METASPRITES_H_INVCLUDE
+#define __PLAT_METASPRITES_H_INVCLUDE
+
+#if defined(__TARGET_gb) || defined(__TARGET_ap) || defined(__TARGET_duck)
+ #include <gb/metasprites.h>
+#elif defined(__TARGET_sms) || defined(__TARGET_gg)
+ #include <sms/metasprites.h>
+#elif defined(__TARGET_msxdos)
+ #include <msx/metasprites.h>
+#else
+ #error Unrecognized port
+#endif
+
+#endif \ No newline at end of file
diff --git a/gbdk/gbdk-lib/include/gbdk/platform.h b/gbdk/gbdk-lib/include/gbdk/platform.h
new file mode 100644
index 00000000..b69da550
--- /dev/null
+++ b/gbdk/gbdk-lib/include/gbdk/platform.h
@@ -0,0 +1,16 @@
+#ifndef __PLATFORM_H_INCLUDE
+#define __PLATFORM_H_INCLUDE
+
+#if defined(__TARGET_gb) || defined(__TARGET_ap) || defined(__TARGET_duck)
+ #include <gb/gb.h>
+ #include <gb/cgb.h>
+ #include <gb/sgb.h>
+#elif defined(__TARGET_sms) || defined(__TARGET_gg)
+ #include <sms/sms.h>
+#elif defined(__TARGET_msxdos)
+ #include <msx/msx.h>
+#else
+ #error Unrecognized port
+#endif
+
+#endif \ No newline at end of file
diff --git a/gbdk/gbdk-lib/include/gbdk/rledecompress.h b/gbdk/gbdk-lib/include/gbdk/rledecompress.h
new file mode 100644
index 00000000..5c61ea82
--- /dev/null
+++ b/gbdk/gbdk-lib/include/gbdk/rledecompress.h
@@ -0,0 +1,47 @@
+/** @file gbdk/rledecompress.h
+
+ Decompressor for RLE encoded data
+
+ Decompresses data which has been compressed with
+ @ref utility_gbcompress "gbcompress" using the `--alg=rle` argument.
+*/
+
+#ifndef __RLEDECOMPRESS_H_INCLUDE
+#define __RLEDECOMPRESS_H_INCLUDE
+
+#include <types.h>
+#include <stdint.h>
+
+#define RLE_STOP 0
+
+#if defined(__TARGET_gb) || defined(__TARGET_ap) || defined(__TARGET_duck)
+/** Initialize the RLE decompressor with RLE data at address __data__
+
+ @param data Pointer to start of RLE compressed data
+
+ @see rle_decompress
+ */
+uint8_t rle_init(void * data) OLDCALL;
+
+/** Decompress RLE compressed data into __dest__ for length __len__ bytes
+
+ @param dest Pointer to destination buffer/address
+ @param len number of bytes to decompress
+
+ Before calling this function @ref rle_init must be called
+ one time to initialize the RLE decompressor.
+
+ Decompresses data which has been compressed with
+ @ref utility_gbcompress "gbcompress" using the `--alg=rle` argument.
+
+ @see rle_init
+ */
+uint8_t rle_decompress(void * dest, uint8_t len) OLDCALL;
+#elif defined(__TARGET_sms) || defined(__TARGET_gg)
+uint8_t rle_init(void * data) Z88DK_FASTCALL;
+uint8_t rle_decompress(void * dest, uint8_t len) Z88DK_CALLEE;
+#else
+ #error Unrecognized port
+#endif
+
+#endif \ No newline at end of file
diff --git a/gbdk/gbdk-lib/include/gbdk/version.h b/gbdk/gbdk-lib/include/gbdk/version.h
new file mode 100644
index 00000000..21ba93a5
--- /dev/null
+++ b/gbdk/gbdk-lib/include/gbdk/version.h
@@ -0,0 +1,6 @@
+#ifndef __VERSION_H_INCLUDE__
+#define __VERSION_H_INCLUDE__
+
+#define __GBDK_VERSION 406
+
+#endif
diff --git a/gbdk/gbdk-lib/include/limits.h b/gbdk/gbdk-lib/include/limits.h
new file mode 100644
index 00000000..5cadc137
--- /dev/null
+++ b/gbdk/gbdk-lib/include/limits.h
@@ -0,0 +1,69 @@
+/*-------------------------------------------------------------------------
+ limits.h - ANSI defines constants for sizes of integral types
+
+ Copyright (C) 1999, Sandeep Dutta . sandeep.dutta@usa.net
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to the
+ Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+ As a special exception, if you link this library with other files,
+ some of which are compiled with SDCC, to produce an executable,
+ this library does not by itself cause the resulting executable to
+ be covered by the GNU General Public License. This exception does
+ not however invalidate any other reasons why the executable file
+ might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
+
+#ifndef __SDC51_LIMITS_H
+#define __SDC51_LIMITS_H 1
+
+#define CHAR_BIT 8 /* bits in a char */
+#define SCHAR_MAX 127
+#define SCHAR_MIN -128
+#define UCHAR_MAX 0xff
+
+#ifdef __SDCC_CHAR_UNSIGNED
+#define CHAR_MAX UCHAR_MAX
+#define CHAR_MIN 0
+#else
+#define CHAR_MAX SCHAR_MAX
+#define CHAR_MIN SCHAR_MIN
+#endif
+
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199409L
+#define MB_LEN_MAX 4
+#endif
+
+#define INT_MIN (-32767 - 1)
+#define INT_MAX 32767
+#define SHRT_MAX INT_MAX
+#define SHRT_MIN INT_MIN
+#define UINT_MAX 0xffff
+#define UINT_MIN 0
+#define USHRT_MAX UINT_MAX
+#define USHRT_MIN UINT_MIN
+#define LONG_MIN (-2147483647L-1)
+#define LONG_MAX 2147483647L
+#define ULONG_MAX 0xffffffff
+#define ULONG_MIN 0
+
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+#define LLONG_MIN (-9223372036854775807LL-1)
+#define LLONG_MAX 9223372036854775807LL
+#define ULLONG_MAX 18446744073709551615ULL
+#endif
+
+#endif
+
diff --git a/gbdk/gbdk-lib/include/msx/hardware.h b/gbdk/gbdk-lib/include/msx/hardware.h
new file mode 100644
index 00000000..1a3b4dcb
--- /dev/null
+++ b/gbdk/gbdk-lib/include/msx/hardware.h
@@ -0,0 +1,201 @@
+/** @file msx/hardware.h
+ Defines that let the MSX hardware registers be accessed
+ from C.
+*/
+#ifndef _HARDWARE_H
+#define _HARDWARE_H
+
+#include <types.h>
+
+#define __BYTES extern UBYTE
+#define __BYTE_REG extern volatile UBYTE
+
+static volatile SFR AT(0x3E) MEMORY_CTL;
+
+#define MEMCTL_JOYON 0b00000000
+#define MEMCTL_JOYOFF 0b00000100
+#define MEMCTL_BASEON 0b00000000
+#define MEMCTL_BASEOFF 0b00001000
+#define MEMCTL_RAMON 0b00000000
+#define MEMCTL_RAMOFF 0b00010000
+#define MEMCTL_CROMON 0b00000000
+#define MEMCTL_CROMOFF 0b00100000
+#define MEMCTL_ROMON 0b00000000
+#define MEMCTL_ROMOFF 0b01000000
+#define MEMCTL_EXTON 0b00000000
+#define MEMCTL_EXTOFF 0b10000000
+
+static volatile SFR AT(0x3F) JOY_CTL;
+
+#define JOY_P1_LATCH 0b00000010
+#define JOY_P2_LATCH 0b00001000
+
+static volatile SFR AT(0x7E) VCOUNTER;
+
+static volatile SFR AT(0x7F) PSG;
+
+#define PSG_LATCH 0x80
+
+#define PSG_CH0 0b00000000
+#define PSG_CH1 0b00100000
+#define PSG_CH2 0b01000000
+#define PSG_CH3 0b01100000
+
+#define PSG_VOLUME 0b00010000
+
+static volatile SFR AT(0x7F) HCOUNTER;
+
+static volatile SFR AT(0x98) VDP_DATA;
+static volatile SFR AT(0x99) VDP_CMD;
+static volatile SFR AT(0x99) VDP_STATUS;
+
+#define STATF_INT_VBL 0b10000000
+#define STATF_9_SPR 0b01000000
+#define STATF_SPR_COLL 0b00100000
+
+#define VDP_REG_MASK 0b10000000
+#define VDP_R0 0b10000000
+extern UBYTE shadow_VDP_R0;
+
+#define R0_DEFAULT 0b00000000
+#define R0_CB_OUTPUT 0b00000000
+#define R0_CB_INPUT 0b01000000
+#define R0_IE2_OFF 0b00000000
+#define R0_IE2 0b00100000
+#define R0_IE1_OFF 0b00000000
+#define R0_IE1 0b00010000
+#define R0_SCR_MODE1 0b00000000
+#define R0_SCR_MODE2 0b00000010
+#define R0_SCR_MODE3 0b00000100
+#define R0_ES_OFF 0b00000000
+#define R0_ES 0b00000001
+
+#define VDP_R1 0b10000001
+extern UBYTE shadow_VDP_R1;
+
+#define R1_DEFAULT 0b10000000
+#define R1_DISP_OFF 0b00000000
+#define R1_DISP_ON 0b01000000
+#define R1_IE_OFF 0b00000000
+#define R1_IE 0b00100000
+#define R1_SCR_MODE1 0b00010000
+#define R1_SCR_MODE2 0b00000000
+#define R1_SCR_MODE3 0b00000000
+#define R1_SPR_8X8 0b00000000
+#define R1_SPR_16X16 0b00000010
+#define R1_SPR_MAG 0b00000001
+#define R1_SPR_MAG_OFF 0b00000000
+
+#define VDP_R2 0b10000010
+extern UBYTE shadow_VDP_R2;
+
+#define R2_MAP_0x3800 0xFF
+#define R2_MAP_0x3000 0xFD
+#define R2_MAP_0x2800 0xFB
+#define R2_MAP_0x2000 0xF9
+#define R2_MAP_0x1800 0xF7
+#define R2_MAP_0x1000 0xF5
+#define R2_MAP_0x0800 0xF3
+#define R2_MAP_0x0000 0xF1
+
+#define VDP_R3 0b10000011
+extern UBYTE shadow_VDP_R3;
+#define VDP_R4 0b10000100
+extern UBYTE shadow_VDP_R4;
+#define VDP_R5 0b10000101
+extern UBYTE shadow_VDP_R5;
+
+#define R5_SAT_0x3F00 0xFF
+#define R5_SAT_MASK 0b10000001
+
+#define VDP_R6 0b10000110
+extern UBYTE shadow_VDP_R6;
+
+#define R6_BANK0 0xFB
+#define R6_DATA_0x0000 0xFB
+#define R6_BANK1 0xFF
+#define R6_DATA_0x2000 0xFF
+
+#define VDP_R7 0b10000111
+extern UBYTE shadow_VDP_R7;
+#define VDP_RBORDER 0b10000111
+extern UBYTE shadow_VDP_RBORDER;
+
+#define R7_COLOR_MASK 0b11110000
+
+#define VDP_R8 0b10001000
+extern UBYTE shadow_VDP_R8;
+#define VDP_RSCX 0b10001000
+extern UBYTE shadow_VDP_RSCX;
+
+#define VDP_R9 0b10001001
+extern UBYTE shadow_VDP_R9;
+#define VDP_RSCY 0b10001001
+extern UBYTE shadow_VDP_RSCY;
+
+#define VDP_R10 0b10001010
+extern UBYTE shadow_VDP_R10;
+
+#define R10_INT_OFF 0xFF
+#define R10_INT_EVERY 0x00
+
+static volatile SFR AT(0xDC) JOY_PORT1;
+
+#define JOY_P1_UP 0b00000001
+#define JOY_P1_DOWN 0b00000010
+#define JOY_P1_LEFT 0b00000100
+#define JOY_P1_RIGHT 0b00001000
+#define JOY_P1_SW1 0b00010000
+#define JOY_P1_TRIGGER 0b00010000
+#define JOY_P1_SW2 0b00100000
+#define JOY_P2_UP 0b01000000
+#define JOY_P2_DOWN 0b10000000
+
+static volatile SFR AT(0xDD) JOY_PORT2;
+
+#define JOY_P2_LEFT 0b00000001
+#define JOY_P2_RIGHT 0b00000010
+#define JOY_P2_SW1 0b00000100
+#define JOY_P2_TRIGGER 0b00000100
+#define JOY_P2_SW2 0b00001000
+#define JOY_RESET 0b00010000
+#define JOY_P1_LIGHT 0b01000000
+#define JOY_P2_LIGHT 0b10000000
+
+static volatile SFR AT(0xF0) FMADDRESS;
+static volatile SFR AT(0xF1) FMDATA;
+static volatile SFR AT(0xF2) AUDIOCTRL;
+
+static volatile SFR AT(0xfc) MAP_FRAME0;
+static volatile SFR AT(0xfd) MAP_FRAME1;
+static volatile SFR AT(0xfe) MAP_FRAME2;
+static volatile SFR AT(0xff) MAP_FRAME3;
+
+extern const UBYTE _BIOS;
+
+extern const UBYTE _SYSTEM;
+
+#define SYSTEM_PAL 0x00
+#define SYSTEM_NTSC 0x01
+
+extern volatile UBYTE VDP_ATTR_SHIFT;
+
+#define VDP_SAT_TERM 0xD0
+
+#if defined(__TARGET_msxdos)
+#define DEVICE_SCREEN_X_OFFSET 0
+#define DEVICE_SCREEN_Y_OFFSET 0
+#define DEVICE_SCREEN_WIDTH 32
+#define DEVICE_SCREEN_HEIGHT 24
+#define DEVICE_SCREEN_BUFFER_WIDTH 32
+#define DEVICE_SCREEN_BUFFER_HEIGHT 28
+#define DEVICE_SCREEN_MAP_ENTRY_SIZE 2
+#define DEVICE_SPRITE_PX_OFFSET_X 0
+#define DEVICE_SPRITE_PX_OFFSET_Y -1
+#else
+#error Unrecognized port
+#endif
+#define DEVICE_SCREEN_PX_WIDTH (DEVICE_SCREEN_WIDTH * 8)
+#define DEVICE_SCREEN_PX_HEIGHT (DEVICE_SCREEN_HEIGHT * 8)
+
+#endif
diff --git a/gbdk/gbdk-lib/include/msx/metasprites.h b/gbdk/gbdk-lib/include/msx/metasprites.h
new file mode 100644
index 00000000..92e7bbc6
--- /dev/null
+++ b/gbdk/gbdk-lib/include/msx/metasprites.h
@@ -0,0 +1,118 @@
+/** @file sms/metasprites.h
+
+ # Metasprite support
+
+ A metasprite is a larger sprite made up from a
+ collection of smaller individual hardware sprites.
+ Different frames of the same metasprites can share
+ tile data.
+
+ The api supports metasprites in both
+ @ref SPRITES_8x8 and @ref SPRITES_8x16 mode. If
+ 8x16 mode is used then the height of the metasprite
+ must be a multiple of 16.
+
+ The origin (pivot) for the metasprite is not required
+ to be in the upper left-hand corner as with regular
+ hardware sprites.
+
+ Use the @ref utility_png2asset tool to convert single
+ or multiple frames of graphics into metasprite
+ structured data for use with the ...metasprite...()
+ functions.
+
+ # Metasprites composed of variable numbers of sprites
+
+ When using png2asset, it's common for the output of
+ different frames to be composed of different numbers
+ of hardware sprites (since it's trying to create each
+ frame as efficiently as possible). Due to that, it's
+ good practice to clear out (hide) unused sprites in the
+ shadow_OAM that have been set by previous frames.
+*/
+
+#ifndef _METASPRITES_H_INCLUDE
+#define _METASPRITES_H_INCLUDE
+
+#include <msx/hardware.h>
+#include <types.h>
+#include <stdint.h>
+
+/** Metasprite sub-item structure
+ @param dy (int8_t) Y coordinate of the sprite relative to the metasprite origin (pivot)
+ @param dx (int8_t) X coordinate of the sprite relative to the metasprite origin (pivot)
+ @param dtile (uint8_t) Start tile relative to the metasprites own set of tiles
+ @param props (uint8_t) Property Flags
+
+ Metasprites are built from multiple metasprite_t items (one for each sub-sprite)
+ and a pool of tiles they reference. If a metasprite has multiple frames then each
+ frame will be built from some number of metasprite_t items (which may vary based
+ on how many sprites are required for that particular frame).
+
+ A metasprite frame is terminated with a {metasprite_end} entry.
+*/
+typedef struct metasprite_t {
+ int8_t dy, dx;
+ uint8_t dtile;
+ uint8_t props;
+} metasprite_t;
+
+#define metasprite_end -128
+#define METASPR_ITEM(dy,dx,dt,a) {(dy),(dx),(dt),(a)}
+#define METASPR_TERM {metasprite_end}
+
+extern const void * __current_metasprite;
+extern uint8_t __current_base_tile;
+extern uint8_t __render_shadow_OAM;
+
+
+static uint8_t __move_metasprite(uint8_t id, uint8_t x, uint8_t y) Z88DK_CALLEE PRESERVES_REGS(iyh, iyl);
+static void __hide_metasprite(uint8_t id) Z88DK_FASTCALL PRESERVES_REGS(iyh, iyl);
+
+/**
+ * Hides all hardware sprites in range from <= X < to
+ * @param from start OAM index
+ * @param to finish OAM index
+ */
+void hide_sprites_range(UINT8 from, UINT8 to) Z88DK_CALLEE PRESERVES_REGS(iyh, iyl);
+
+/** Moves metasprite to the absolute position x and y
+
+ @param metasprite Pointer to the first struct of the metasprite (for the desired frame)
+ @param base_tile Number of the first tile where the metasprite's tiles start
+ @param base_sprite Number of the first hardware sprite to be used by the metasprite
+ @param x Absolute x coordinate of the sprite
+ @param y Absolute y coordinate of the sprite
+
+ Moves __metasprite__ to the absolute position __x__ and __y__
+ (with __no flip__ on the X or Y axis). Hardware sprites are
+ allocated starting from __base_sprite__, using tiles
+ starting from __base_tile__.
+
+ Sets:
+ \li __current_metasprite = metasprite;
+ \li __current_base_tile = base_tile;
+
+ @return Number of hardware sprites used to draw this metasprite
+ */
+inline uint8_t move_metasprite(const metasprite_t * metasprite, uint8_t base_tile, uint8_t base_sprite, uint8_t x, uint8_t y) {
+ __current_metasprite = metasprite;
+ __current_base_tile = base_tile;
+ return __move_metasprite(base_sprite, x, y);
+}
+
+/** Hides a metasprite from the screen
+
+ @param metasprite Pointer to first struct of the desired metasprite frame
+ @param base_sprite Number of hardware sprite to start with
+
+ Sets:
+ \li __current_metasprite = metasprite;
+
+ **/
+inline void hide_metasprite(const metasprite_t * metasprite, uint8_t base_sprite) {
+ __current_metasprite = metasprite;
+ __hide_metasprite(base_sprite);
+}
+
+#endif
diff --git a/gbdk/gbdk-lib/include/msx/msx.h b/gbdk/gbdk-lib/include/msx/msx.h
new file mode 100644
index 00000000..58dce3b5
--- /dev/null
+++ b/gbdk/gbdk-lib/include/msx/msx.h
@@ -0,0 +1,751 @@
+/** @file msx/msx.h
+ MSX specific functions.
+*/
+#ifndef _MSX_H
+#define _MSX_H
+
+#include <types.h>
+#include <stdint.h>
+#include <gbdk/version.h>
+#include <msx/hardware.h>
+
+#define MSX
+#ifdef NINTENDO
+#undef NINTENDO
+#endif
+#ifdef SEGA
+#undef SEGA
+#endif
+#if defined(__TARGET_msxdos)
+#define MSXDOS
+#endif
+
+
+#define VBK_REG VDP_ATTR_SHIFT
+
+/** Joypad bits.
+ A logical OR of these is used in the wait_pad and joypad
+ functions. For example, to see if the B button is pressed
+ try
+
+ uint8_t keys;
+ keys = joypad();
+ if (keys & J_B) {
+ ...
+ }
+
+ @see joypad
+ */
+#define J_UP 0b00100000
+#define J_DOWN 0b01000000
+#define J_LEFT 0b00010000
+#define J_RIGHT 0b10000000
+#define J_A 0b00000001
+#define J_B 0b00000100
+#define J_SELECT 0b00001000
+#define J_START 0b00000010
+
+/** Screen modes.
+ Normally used by internal functions only.
+ @see mode()
+ */
+#define M_TEXT_OUT 0x02U
+#define M_TEXT_INOUT 0x03U
+/** Set this in addition to the others to disable scrolling
+
+ If scrolling is disabled, the cursor returns to (0,0)
+ @see mode()
+*/
+#define M_NO_SCROLL 0x04U
+/** Set this to disable interpretation
+ @see mode()
+*/
+#define M_NO_INTERP 0x08U
+
+/** If set the background tile will be flipped horizontally.
+ */
+#define S_FLIPX 0x02U
+/** If set the background tile will be flipped vertically.
+ */
+#define S_FLIPY 0x04U
+/** If set the background tile palette.
+ */
+#define S_PALETTE 0x08U
+/** If set the background tile priority.
+ */
+#define S_PRIORITY 0x10U
+
+// VDP helper macros
+#define __WRITE_VDP_REG(REG, v) shadow_##REG=(v);__critical{VDP_CMD=(shadow_##REG),VDP_CMD=REG;}
+#define __READ_VDP_REG(REG) shadow_##REG
+
+void WRITE_VDP_CMD(uint16_t cmd) Z88DK_FASTCALL PRESERVES_REGS(b, c, d, e, iyh, iyl);
+void WRITE_VDP_DATA(uint16_t data) Z88DK_FASTCALL PRESERVES_REGS(b, c, d, e, iyh, iyl);
+
+/** Set the current screen mode - one of M_* modes
+
+ Normally used by internal functions only.
+
+ @see M_TEXT_OUT, M_TEXT_INOUT, M_NO_SCROLL, M_NO_INTERP
+*/
+void mode(uint8_t m) OLDCALL;
+
+/** Returns the current mode
+
+ @see M_TEXT_OUT, M_TEXT_INOUT, M_NO_SCROLL, M_NO_INTERP
+*/
+uint8_t get_mode() OLDCALL;
+
+/* Interrupt flags */
+/** Disable calling of interrupt service routines
+ */
+#define EMPTY_IFLAG 0x00U
+/** VBlank Interrupt occurs at the start of the vertical blank.
+
+ During this period the video ram may be freely accessed.
+ @see set_interrupts(), @see add_VBL
+ */
+#define VBL_IFLAG 0x01U
+/** LCD Interrupt when triggered by the STAT register.
+ @see set_interrupts(), @see add_LCD
+*/
+#define LCD_IFLAG 0x02U
+/** Does nothing on MSX
+ */
+#define TIM_IFLAG 0x04U
+/** Does nothing on MSX
+ */
+#define SIO_IFLAG 0x08U
+/** Does nothing on MSX
+ */
+#define JOY_IFLAG 0x10U
+
+void set_interrupts(uint8_t flags) Z88DK_FASTCALL;
+
+/* Limits */
+/** Width of the visible screen in pixels.
+ */
+#define SCREENWIDTH DEVICE_SCREEN_PX_WIDTH
+/** Height of the visible screen in pixels.
+ */
+#define SCREENHEIGHT DEVICE_SCREEN_PX_HEIGHT
+/** The Minimum X position of the Window Layer (Left edge of screen) @see move_win()
+ */
+#define MINWNDPOSX 0x00U
+/** The Minimum Y position of the Window Layer (Top edge of screen) @see move_win()
+ */
+#define MINWNDPOSY 0x00U
+/** The Maximum X position of the Window Layer (Right edge of screen) @see move_win()
+ */
+#define MAXWNDPOSX 0x00U
+/** The Maximum Y position of the Window Layer (Bottom edge of screen) @see move_win()
+ */
+#define MAXWNDPOSY 0x00U
+
+
+/** Interrupt handlers
+ */
+typedef void (*int_handler)(void) NONBANKED;
+
+/** Removes the VBL interrupt handler.
+ @see add_VBL()
+*/
+void remove_VBL(int_handler h) Z88DK_FASTCALL PRESERVES_REGS(iyh, iyl);
+
+/** Removes the LCD interrupt handler.
+ @see add_LCD(), remove_VBL()
+*/
+void remove_LCD(int_handler h) Z88DK_FASTCALL PRESERVES_REGS(b, c, iyh, iyl);
+
+void remove_TIM(int_handler h) Z88DK_FASTCALL;
+void remove_SIO(int_handler h) Z88DK_FASTCALL;
+void remove_JOY(int_handler h) Z88DK_FASTCALL;
+
+/** Adds a V-blank interrupt handler.
+*/
+void add_VBL(int_handler h) Z88DK_FASTCALL PRESERVES_REGS(d, e, iyh, iyl);
+
+/** Adds a LCD interrupt handler.
+*/
+void add_LCD(int_handler h) Z88DK_FASTCALL PRESERVES_REGS(b, c, iyh, iyl);
+
+/** Does nothing on MSX
+ */
+void add_TIM(int_handler h) Z88DK_FASTCALL;
+
+/** Does nothing on MSX
+ */
+void add_SIO(int_handler h) Z88DK_FASTCALL;
+
+/** Does nothing on MSX
+ */
+void add_JOY(int_handler h) Z88DK_FASTCALL;
+
+/** Cancel pending interrupts
+ */
+inline uint8_t cancel_pending_interrupts() {
+ return VDP_STATUS;
+}
+
+inline void move_bkg(uint8_t x, uint8_t y) {
+ __WRITE_VDP_REG(VDP_RSCX, -x);
+ __WRITE_VDP_REG(VDP_RSCY, y);
+}
+
+inline void scroll_bkg(int8_t x, int8_t y) {
+ __WRITE_VDP_REG(VDP_RSCX, __READ_VDP_REG(VDP_RSCX) - x);
+ int16_t tmp = __READ_VDP_REG(VDP_RSCY) + y;
+ __WRITE_VDP_REG(VDP_RSCY, (tmp < 0) ? 224 + tmp : tmp % 224u);
+}
+
+/** HALTs the CPU and waits for the vertical blank interrupt (VBL) to finish.
+
+ This is often used in main loops to idle the CPU at low power
+ until it's time to start the next frame. It's also useful for
+ syncing animation with the screen re-draw.
+
+ Warning: If the VBL interrupt is disabled, this function will
+ never return. If the screen is off this function returns
+ immediately.
+*/
+void wait_vbl_done() PRESERVES_REGS(b, c, d, e, h, l, iyh, iyl);
+
+/** Turns the display off.
+
+ @see DISPLAY_ON
+*/
+inline void display_off() {
+ __WRITE_VDP_REG(VDP_R1, __READ_VDP_REG(VDP_R1) &= (~R1_DISP_ON));
+}
+
+/** Turns the display back on.
+ @see display_off, DISPLAY_OFF
+*/
+#define DISPLAY_ON \
+ __WRITE_VDP_REG(VDP_R1, __READ_VDP_REG(VDP_R1) |= R1_DISP_ON)
+
+/** Turns the display off immediately.
+ @see display_off, DISPLAY_ON
+*/
+#define DISPLAY_OFF \
+ display_off();
+
+/** Copies data from shadow OAM to OAM
+ */
+void refresh_OAM();
+
+/** Blanks leftmost column, so it is not garbaged when you use horizontal scroll
+ @see SHOW_LEFT_COLUMN
+*/
+#define HIDE_LEFT_COLUMN \
+ __WRITE_VDP_REG(VDP_R0, __READ_VDP_REG(VDP_R0) |= R0_LCB)
+
+/** Shows leftmost column
+ @see HIDE_LEFT_COLUMN
+*/
+#define SHOW_LEFT_COLUMN \
+ __WRITE_VDP_REG(VDP_R0, __READ_VDP_REG(VDP_R0) &= (~R0_LCB))
+
+/** Turns on the background layer.
+ Not yet implemented
+*/
+#define SHOW_BKG
+
+/** Turns off the background layer.
+ Not yet implemented
+*/
+#define HIDE_BKG
+
+/** Turns on the window layer
+ Not yet implemented
+*/
+#define SHOW_WIN
+
+/** Turns off the window layer.
+ Not yet implemented
+*/
+#define HIDE_WIN
+
+/** Turns on the sprites layer.
+ Not yet implemented
+*/
+#define SHOW_SPRITES
+
+/** Turns off the sprites layer.
+ Not yet implemented
+*/
+#define HIDE_SPRITES
+
+/** Sets sprite size to 8x16 pixels, two tiles one above the other.
+*/
+#define SPRITES_16x16 \
+ __WRITE_VDP_REG(VDP_R1, __READ_VDP_REG(VDP_R1) |= R1_SPR_16X16)
+
+/** Sets sprite size to 8x8 pixels, one tile.
+*/
+#define SPRITES_8x8 \
+ __WRITE_VDP_REG(VDP_R1, __READ_VDP_REG(VDP_R1) &= (~R1_SPR_16X16))
+
+/** Macro returns TRUE if device supports color
+ * (it always does on MSX)
+ */
+#define DEVICE_SUPPORTS_COLOR (TRUE)
+
+/** Global Time Counter in VBL periods (60Hz)
+
+ Increments once per Frame
+
+ Will wrap around every ~18 minutes (unsigned 16 bits = 65535 / 60 / 60 = 18.2)
+*/
+extern volatile uint16_t sys_time;
+
+/** Tracks current active ROM bank in frame 1
+*/
+extern volatile uint8_t _current_bank;
+#define CURRENT_BANK _current_bank
+
+/** Obtains the __bank number__ of VARNAME
+
+ @param VARNAME Name of the variable which has a __bank_VARNAME companion symbol which is adjusted by bankpack
+
+ Use this to obtain the bank number from a bank reference
+ created with @ref BANKREF().
+
+ @see BANKREF_EXTERN(), BANKREF()
+*/
+#ifndef BANK
+#define BANK(VARNAME) ( (uint8_t) & __bank_ ## VARNAME )
+#endif
+
+/** Creates a reference for retrieving the bank number of a variable or function
+
+ @param VARNAME Variable name to use, which may be an existing identifier
+
+ @see BANK() for obtaining the bank number of the included data.
+
+ More than one `BANKREF()` may be created per file, but each call should
+ always use a unique VARNAME.
+
+ Use @ref BANKREF_EXTERN() within another source file
+ to make the variable and it's data accesible there.
+*/
+#define BANKREF(VARNAME) void __func_ ## VARNAME() __banked __naked { \
+__asm \
+ .local b___func_ ## VARNAME \
+ ___bank_ ## VARNAME = b___func_ ## VARNAME \
+ .globl ___bank_ ## VARNAME \
+__endasm; \
+}
+
+/** Creates extern references for accessing a BANKREF() generated variable.
+
+ @param VARNAME Name of the variable used with @ref BANKREF()
+
+ This makes a @ref BANKREF() reference in another source
+ file accessible in the current file for use with @ref BANK().
+
+ @see BANKREF(), BANK()
+*/
+#define BANKREF_EXTERN(VARNAME) extern const void __bank_ ## VARNAME;
+
+
+/** Makes switch the active ROM bank in frame 1
+ @param b ROM bank to switch to
+*/
+
+void SWITCH_ROM(uint8_t bank) Z88DK_FASTCALL PRESERVES_REGS(b, c, d, e, iyh, iyl);
+#define SWITCH_ROM1 SWITCH_ROM
+
+/** Makes switch the active ROM bank in frame 2
+ @param b ROM bank to switch to
+*/
+
+#define SWITCH_ROM2(b) MAP_FRAME2=(b)
+
+/** Switches RAM bank
+ @param b SRAM bank to switch to
+*/
+
+#define SWITCH_RAM(b) RAM_CONTROL=((b)&1)?RAM_CONTROL|RAMCTL_BANK:RAM_CONTROL&(~RAMCTL_BANK)
+
+/** Enables RAM
+*/
+
+#define ENABLE_RAM RAM_CONTROL|=RAMCTL_RAM
+
+/** Disables RAM
+*/
+
+#define DISABLE_RAM RAM_CONTROL&=(~RAMCTL_RAM)
+
+
+/** Delays the given number of milliseconds.
+ Uses no timers or interrupts, and can be called with
+ interrupts disabled
+ */
+void delay(uint16_t d) Z88DK_FASTCALL;
+
+
+/** Reads and returns the current state of the joypad.
+*/
+uint8_t joypad() OLDCALL PRESERVES_REGS(b, c, d, e, h, iyh, iyl);
+
+/** Waits until at least one of the buttons given in mask are pressed.
+*/
+uint8_t waitpad(uint8_t mask) Z88DK_FASTCALL PRESERVES_REGS(b, c, d, e, iyh, iyl);
+
+/** Waits for the directional pad and all buttons to be released.
+
+ Note: Checks in a loop that doesn't HALT at all, so the CPU
+ will be maxed out until this call returns.
+*/
+void waitpadup() PRESERVES_REGS(b, c, d, e, iyh, iyl);
+
+/** Multiplayer joypad structure.
+
+ Must be initialized with @ref joypad_init() first then it
+ may be used to poll all avaliable joypads with @ref joypad_ex()
+*/
+typedef struct {
+ uint8_t npads;
+ union {
+ struct {
+ uint8_t joy0, joy1, joy2, joy3;
+ };
+ uint8_t joypads[4];
+ };
+} joypads_t;
+
+/** Initializes joypads_t structure for polling multiple joypads
+ @param npads number of joypads requested (1, 2 or 4)
+ @param joypads pointer to joypads_t structure to be initialized
+
+ Only required for @ref joypad_ex, not required for calls to regular @ref joypad()
+ @returns number of joypads avaliable
+ @see joypad_ex(), joypads_t
+*/
+uint8_t joypad_init(uint8_t npads, joypads_t * joypads) Z88DK_CALLEE;
+
+/** Polls all avaliable joypads
+ @param joypads pointer to joypads_t structure to be filled with joypad statuses,
+ must be previously initialized with joypad_init()
+
+ @see joypad_init(), joypads_t
+*/
+void joypad_ex(joypads_t * joypads) Z88DK_FASTCALL PRESERVES_REGS(iyh, iyl);
+
+
+#if defined(__TARGET_msxdos)
+
+#define RGB(r,g,b) ((r) | ((g) << 2) | ((b) << 4))
+#define RGB8(r,g,b) (((r) >> 6) | (((g) >> 6) << 2) | (((b) >> 6) << 4))
+#define RGBHTML(RGB24bit) (((RGB24bit) >> 22) | ((((RGB24bit) & 0xFFFF) >> 14) << 2) | ((((RGB24bit) & 0xFF) >> 6) << 4))
+
+/** Common colors based on the EGA default palette.
+ */
+#define RGB_RED RGB( 3, 0, 0)
+#define RGB_DARKRED RGB( 2, 0, 0)
+#define RGB_GREEN RGB( 0, 3, 0)
+#define RGB_DARKGREEN RGB( 0, 2, 0)
+#define RGB_BLUE RGB( 0, 0, 3)
+#define RGB_DARKBLUE RGB( 0, 0, 2)
+#define RGB_YELLOW RGB( 3, 3, 0)
+#define RGB_DARKYELLOW RGB( 2, 2, 0)
+#define RGB_CYAN RGB( 0, 3, 3)
+#define RGB_AQUA RGB( 3, 1, 2)
+#define RGB_PINK RGB( 3, 0, 3)
+#define RGB_PURPLE RGB( 2, 0, 2)
+#define RGB_BLACK RGB( 0, 0, 0)
+#define RGB_DARKGRAY RGB( 1, 1, 1)
+#define RGB_LIGHTGRAY RGB( 2, 2, 2)
+#define RGB_WHITE RGB( 3, 3, 3)
+
+typedef uint8_t palette_color_t;
+
+#else
+#error Unrecognized port
+#endif
+
+void set_default_palette();
+inline void cpu_fast() {}
+
+void set_palette_entry(uint8_t palette, uint8_t entry, uint16_t rgb_data) Z88DK_CALLEE PRESERVES_REGS(iyh, iyl);
+#define set_bkg_palette_entry set_palette_entry
+#define set_sprite_palette_entry(palette,entry,rgb_data) set_palette_entry(1,entry,rgb_data)
+void set_palette(uint8_t first_palette, uint8_t nb_palettes, palette_color_t *rgb_data) Z88DK_CALLEE;
+#define set_bkg_palette set_palette
+#define set_sprite_palette(first_palette,nb_palettes,rgb_data) set_palette(1,1,rgb_data)
+
+void set_native_tile_data(uint16_t start, uint16_t ntiles, const void *src) Z88DK_CALLEE;
+inline void set_bkg_4bpp_data(uint16_t start, uint16_t ntiles, const void *src) {
+ set_native_tile_data(start, ntiles, src);
+}
+void set_sprite_1bpp_data(uint16_t start, uint16_t ntiles, const void *src) Z88DK_CALLEE;
+inline void set_native_sprite_data(uint16_t start, uint16_t ntiles, const void *src) {
+ set_sprite_1bpp_data(start, ntiles, src);
+}
+
+#define COMPAT_PALETTE(C0,C1,C2,C3) (((uint16_t)(C3) << 12) | ((uint16_t)(C2) << 8) | ((uint16_t)(C1) << 4) | (uint16_t)(C0))
+extern uint16_t _current_2bpp_palette;
+inline void set_2bpp_palette(uint16_t palette) {
+ _current_2bpp_palette = palette;
+}
+//void set_tile_2bpp_data(uint16_t start, uint16_t ntiles, const void *src, uint16_t palette) Z88DK_CALLEE PRESERVES_REGS(iyh, iyl);
+inline void set_bkg_data(uint16_t start, uint16_t ntiles, const void *src) {
+ set_native_tile_data(start, ntiles, src);
+}
+inline void set_sprite_data(uint16_t start, uint16_t ntiles, const void *src) {
+ set_sprite_1bpp_data(start, ntiles, src);
+}
+//inline void set_bkg_2bpp_data(uint16_t start, uint16_t ntiles, const void *src) {
+// set_tile_2bpp_data(start, ntiles, src, _current_2bpp_palette);
+//}
+//inline void set_sprite_2bpp_data(uint16_t start, uint16_t ntiles, const void *src) {
+// set_tile_2bpp_data((uint8_t)(start) + 0x100u, ntiles, src, _current_2bpp_palette);
+//}
+
+extern uint16_t _current_1bpp_colors;
+inline void set_1bpp_colors(uint8_t fgcolor, uint8_t bgcolor) {
+ _current_1bpp_colors = ((uint16_t)bgcolor << 8) | fgcolor;
+}
+void set_tile_1bpp_data(uint16_t start, uint16_t ntiles, const void *src, uint16_t colors) Z88DK_CALLEE PRESERVES_REGS(iyh, iyl);
+inline void set_bkg_1bpp_data(uint16_t start, uint16_t ntiles, const void *src) {
+ set_tile_1bpp_data(start, ntiles, src, _current_1bpp_colors);
+}
+
+
+/** Copies arbitrary data to an address in VRAM
+
+ @param dst destination VRAM Address
+ @param src Pointer to source buffer
+ @param size Number of bytes to copy
+
+ Copies __size__ bytes from a buffer at _src__ to VRAM starting at __dst__.
+*/
+void set_data(uint16_t dst, const void *src, uint16_t size) Z88DK_CALLEE PRESERVES_REGS(iyh, iyl);
+void vmemcpy(uint16_t dst, const void *src, uint16_t size) Z88DK_CALLEE PRESERVES_REGS(iyh, iyl);
+
+void set_tile_map(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *tiles) Z88DK_CALLEE PRESERVES_REGS(iyh, iyl);
+#define set_bkg_tiles set_tile_map
+#define set_win_tiles set_tile_map
+
+extern uint8_t _map_tile_offset;
+inline void set_bkg_based_tiles(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *tiles, uint8_t base_tile) {
+ _map_tile_offset = base_tile;
+ set_tile_map(x, y, w, h, tiles);
+ _map_tile_offset = 0;
+}
+inline void set_win_based_tiles(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *tiles, uint8_t base_tile) {
+ _map_tile_offset = base_tile;
+ set_tile_map(x, y, w, h, tiles);
+ _map_tile_offset = 0;
+}
+
+void set_tile_submap(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t map_w, const uint8_t *map) Z88DK_CALLEE PRESERVES_REGS(iyh, iyl);
+void set_tile_submap_compat(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t map_w, const uint8_t *map) Z88DK_CALLEE PRESERVES_REGS(iyh, iyl);
+inline void set_bkg_submap(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *map, uint8_t map_w) {
+ set_tile_submap_compat(x, y, w, h, map_w, map);
+}
+inline void set_win_submap(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *map, uint8_t map_w) {
+ set_tile_submap_compat(x, y, w, h, map_w, map);
+}
+
+extern uint8_t _submap_tile_offset;
+inline void set_bkg_based_submap(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *map, uint8_t map_w, uint8_t base_tile) {
+ _submap_tile_offset = base_tile;
+ set_tile_submap_compat(x, y, w, h, map_w, map);
+ _submap_tile_offset = 0;
+}
+inline void set_win_based_submap(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *map, uint8_t map_w, uint8_t base_tile) {
+ _submap_tile_offset = base_tile;
+ set_tile_submap_compat(x, y, w, h, map_w, map);
+ _submap_tile_offset = 0;
+}
+
+void fill_rect(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint16_t tile) Z88DK_CALLEE PRESERVES_REGS(iyh, iyl);
+#define fill_bkg_rect fill_rect
+#define fill_win_rect fill_rect
+
+/** Sprite Attributes structure
+ @param x X Coordinate of the sprite on screen
+ @param y Y Coordinate of the sprite on screen
+ @param tile Sprite tile number (see @ref set_sprite_tile)
+ @param prop OAM Property Flags (see @ref set_sprite_prop)
+*/
+typedef struct OAM_item_t {
+ uint8_t y, x; //< X, Y Coordinates of the sprite on screen
+ uint8_t tile; //< Sprite tile number
+ uint8_t prop; //< OAM Property Flags
+} OAM_item_t;
+
+
+/** Shadow OAM array in WRAM, that is DMA-transferred into the real OAM each VBlank
+*/
+extern volatile struct OAM_item_t shadow_OAM[];
+
+/** MSB of shadow_OAM address is used by OAM copying routine
+*/
+extern volatile uint8_t _shadow_OAM_base;
+
+/** Flag for disabling of OAM copying routine
+
+ Values:
+ \li 1: OAM copy routine is disabled (non-isr VDP operation may be in progress)
+ \li 0: OAM copy routine is enabled
+
+ This flag is modified by all MSX GBDK API calls that write to the VDP.
+ It is set to DISABLED when they start and ENABLED when they complete.
+
+ @note It is recommended to avoid writing to the Video Display Processor
+ (VDP) during an interrupt service routine (ISR) since it can corrupt
+ the VDP pointer of an VDP operation already in progress.
+
+ If it is necessary, this flag can be used during an ISR to determine
+ whether a VDP operation is already in progress. If the value is `1`
+ then avoid writing to the VDP (tiles, map, scrolling, colors, etc).
+
+ \code{.c}
+ // at the beginning of and ISR that would write to the VDP
+ if (_shadow_OAM_OFF) return;
+ \endcode
+
+ @see @ref docs_consoles_safe_display_controller_access
+*/
+extern volatile uint8_t _shadow_OAM_OFF;
+
+/** Disable shadow OAM to VRAM copy on each VBlank
+*/
+#define DISABLE_VBL_TRANSFER \
+ _shadow_OAM_base = 0
+
+/** Enable shadow OAM to VRAM copy on each VBlank
+*/
+#define ENABLE_VBL_TRANSFER \
+ _shadow_OAM_base = (uint8_t)((uint16_t)&shadow_OAM >> 8)
+
+/** Amount of hardware sprites in OAM
+*/
+#define MAX_HARDWARE_SPRITES 32
+
+/** Sets address of 256-byte aligned array of shadow OAM to be transferred on each VBlank
+*/
+inline void SET_SHADOW_OAM_ADDRESS(void * address) {
+ _shadow_OAM_base = (uint8_t)((uint16_t)address >> 8);
+}
+
+/** Sets sprite number __nb__in the OAM to display tile number __tile__.
+
+ @param nb Sprite number, range 0 - 39
+ @param tile Selects a tile (0 - 255) from memory at 8000h - 8FFFh
+ \n In CGB Mode this could be either in VRAM Bank
+ \n 0 or 1, depending on Bit 3 of the OAM Attribute Flag
+ \n (see @ref set_sprite_prop)
+
+ In 8x16 mode:
+ \li The sprite will also display the next tile (__tile__ + 1)
+ directly below (y + 8) the first tile.
+ \li The lower bit of the tile number is ignored:
+ the upper 8x8 tile is (__tile__ & 0xFE), and
+ the lower 8x8 tile is (__tile__ | 0x01).
+ \li See: @ref SPRITES_8x16
+*/
+inline void set_sprite_tile(uint8_t nb, uint8_t tile) {
+ shadow_OAM[nb].tile=tile;
+}
+
+
+/** Returns the tile number of sprite number __nb__ in the OAM.
+
+@param nb Sprite number, range 0 - 39
+
+@see set_sprite_tile for more details
+*/
+inline uint8_t get_sprite_tile(uint8_t nb) {
+ return shadow_OAM[nb].tile;
+}
+
+inline void set_sprite_prop(uint8_t nb, uint8_t prop) {
+ shadow_OAM[nb].prop = prop;
+}
+
+inline uint8_t get_sprite_prop(uint8_t nb) {
+ return shadow_OAM[nb].prop;
+}
+
+/** Moves sprite number __nb__ to the __x__, __y__ position on the screen.
+
+ @param nb Sprite number, range 0 - 39
+ @param x X Position. Specifies the sprites horizontal position on the screen (minus 8).
+ \n An offscreen value (X=0 or X>=168) hides the sprite, but the sprite
+ still affects the priority ordering - a better way to hide a sprite is to set
+ its Y-coordinate offscreen.
+ @param y Y Position. Specifies the sprites vertical position on the screen (minus 16).
+ \n An offscreen value (for example, Y=0 or Y>=160) hides the sprite.
+
+ Moving the sprite to 0,0 (or similar off-screen location) will hide it.
+*/
+inline void move_sprite(uint8_t nb, uint8_t x, uint8_t y) {
+ OAM_item_t * itm = &shadow_OAM[nb];
+ itm->y=y, itm->x=x;
+}
+
+
+/** Moves sprite number __nb__ relative to its current position.
+
+ @param nb Sprite number, range 0 - 39
+ @param x Number of pixels to move the sprite on the __X axis__
+ \n Range: -128 - 127
+ @param y Number of pixels to move the sprite on the __Y axis__
+ \n Range: -128 - 127
+
+ @see move_sprite for more details about the X and Y position
+ */
+inline void scroll_sprite(uint8_t nb, int8_t x, int8_t y) {
+ OAM_item_t * itm = &shadow_OAM[nb];
+ itm->y+=y, itm->x+=x;
+}
+
+
+/** Hides sprite number __nb__ by moving it to zero position by Y.
+
+ @param nb Sprite number, range 0 - 39
+ */
+inline void hide_sprite(uint8_t nb) {
+ shadow_OAM[nb].y = 0xC0;
+}
+
+/**
+ * Set byte in vram at given memory location
+ *
+ * @param addr address to write to
+ * @param v value
+ */
+void set_vram_byte(uint8_t * addr, uint8_t v) Z88DK_CALLEE PRESERVES_REGS(iyh, iyl);
+
+/**
+ * Set single tile t with attributes on background layer at x,y
+ * @param x X-coordinate
+ * @param y Y-coordinate
+ * @param t tile index
+ * @return returns the address of tile, so you may use faster set_vram_byte() later
+ */
+uint8_t * set_attributed_tile_xy(uint8_t x, uint8_t y, uint16_t t) Z88DK_CALLEE PRESERVES_REGS(iyh, iyl);
+
+/**
+ * Set single tile t on background layer at x,y
+ * @param x X-coordinate
+ * @param y Y-coordinate
+ * @param t tile index
+ * @return returns the address of tile, so you may use faster set_vram_byte() later
+ */
+uint8_t * set_tile_xy(uint8_t x, uint8_t y, uint8_t t) Z88DK_CALLEE PRESERVES_REGS(iyh, iyl);
+#define set_bkg_tile_xy set_tile_xy
+#define set_win_tile_xy set_tile_xy
+
+/**
+ * Get address of X,Y tile of background map
+ */
+uint8_t * get_bkg_xy_addr(uint8_t x, uint8_t y) Z88DK_CALLEE PRESERVES_REGS(iyh, iyl);
+#define get_win_xy_addr get_bkg_xy_addr
+
+#endif /* _MSX_H */
diff --git a/gbdk/gbdk-lib/include/rand.h b/gbdk/gbdk-lib/include/rand.h
new file mode 100644
index 00000000..af477280
--- /dev/null
+++ b/gbdk/gbdk-lib/include/rand.h
@@ -0,0 +1,83 @@
+/** @file rand.h
+ Random generator using the linear congruential method
+
+ @author Luc Van den Borre
+*/
+#ifndef RAND_INCLUDE
+#define RAND_INCLUDE
+
+#include <types.h>
+#include <stdint.h>
+
+/** Initalise the pseudo-random number generator.
+
+ @param seed The value for initializing the random number generator.
+
+ The seed should be different each time, otherwise the same pseudo-random
+ sequence will be generated.
+
+ The DIV Register (@ref DIV_REG) is sometimes used as a seed,
+ particularly if read at some variable point in time (such
+ as when the player presses a button).
+
+ Only needs to be called once to initialize, but may be called
+ again to re-initialize with the same or a different seed.
+
+ @see rand(), randw()
+*/
+#if defined(__PORT_sm83)
+void initrand(uint16_t seed) OLDCALL;
+#elif defined(__PORT_z80)
+void initrand(uint16_t seed) Z88DK_FASTCALL;
+#endif
+
+#define RAND_MAX 255
+#define RANDW_MAX 65535
+
+/** The random number seed is stored in __rand_seed and can be
+ saved and restored if needed.
+
+ \code{.c}
+ // Save
+ some_uint16 = __rand_seed;
+ ...
+ // Restore
+ __rand_seed = some_uint16;
+ \endcode
+*/
+extern uint16_t __rand_seed;
+
+/** Returns a random byte (8 bit) value.
+
+ @ref initrand() should be used to initialize the random number generator before using rand()
+ */
+uint8_t rand() OLDCALL;
+
+/** Returns a random word (16 bit) value.
+
+ @ref initrand() should be used to initialize the random number generator before using rand()
+ */
+uint16_t randw() OLDCALL;
+
+/** Random generator using the linear lagged additive method
+
+ @param seed The value for initializing the random number generator.
+
+ Note: initarand() calls @ref initrand() with the same seed value, and
+ uses @ref rand() to initialize the random generator.
+
+ @see initrand() for suggestions about seed values, arand()
+*/
+#if defined(__PORT_sm83)
+void initarand(uint16_t seed) OLDCALL;
+#elif defined(__PORT_z80)
+void initarand(uint16_t seed) Z88DK_FASTCALL;
+#endif
+
+/** Returns a random number generated with the linear lagged additive method.
+
+ @ref initarand() should be used to initialize the random number generator before using arand()
+ */
+uint8_t arand() OLDCALL;
+
+#endif
diff --git a/gbdk/gbdk-lib/include/setjmp.h b/gbdk/gbdk-lib/include/setjmp.h
new file mode 100644
index 00000000..e0572596
--- /dev/null
+++ b/gbdk/gbdk-lib/include/setjmp.h
@@ -0,0 +1,83 @@
+/*-------------------------------------------------------------------------
+ setjmp.h - header file for setjmp & longjmp ANSI routines
+
+ Copyright (C) 1999, Sandeep Dutta . sandeep.dutta@usa.net
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to the
+ Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+ As a special exception, if you link this library with other files,
+ some of which are compiled with SDCC, to produce an executable,
+ this library does not by itself cause the resulting executable to
+ be covered by the GNU General Public License. This exception does
+ not however invalidate any other reasons why the executable file
+ might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
+
+#ifndef __SDCC_SETJMP_H
+#define __SDCC_SETJMP_H
+
+#define SP_SIZE 1
+
+#ifdef __SDCC_STACK_AUTO
+#define BP_SIZE SP_SIZE
+#else
+#define BP_SIZE 0
+#endif
+
+#ifdef __SDCC_USE_XSTACK
+#define SPX_SIZE 1
+#else
+#define SPX_SIZE 0
+#endif
+
+#define BPX_SIZE SPX_SIZE
+
+#ifdef __SDCC_MODEL_HUGE
+#define RET_SIZE 3
+#else
+#define RET_SIZE 2
+#endif
+
+#if defined (__SDCC_z80) || defined (__SDCC_z180) || defined (__SDCC_r2k) || defined (__SDCC_r3ka) || defined (__SDCC_tlcs90) || defined (__SDCC_ez80_z80) || defined (__SDCC_z80n)
+typedef unsigned char jmp_buf[6]; /* 2 for the stack pointer, 2 for the return address, 2 for the frame pointer. */
+#elif defined (__SDCC_ds390) || defined (__SDCC_stm8) && defined (__SDCC_MODEL_LARGE)
+typedef unsigned char jmp_buf[5]; /* 2 for the stack pointer, 3 for the return address. */
+#elif defined (__SDCC_stm8) || defined (__SDCC_sm83) || defined (__SDCC_hc08) || defined (__SDCC_s08)
+typedef unsigned char jmp_buf[4]; /* 2 for the stack pointer, 2 for the return address. */
+#elif defined (__SDCC_pdk13) || defined (__SDCC_pdk14) || defined (__SDCC_pdk15)
+typedef unsigned char jmp_buf[3]; /* 1 for the stack pointer, 2 for the return address. */
+#else
+typedef unsigned char jmp_buf[RET_SIZE + SP_SIZE + BP_SIZE + SPX_SIZE + BPX_SIZE];
+#endif
+
+int __setjmp (jmp_buf) OLDCALL;
+
+/* C99 might require setjmp to be a macro. The standard seems self-contradicting on this issue. */
+/* However, it is clear that the standards allow setjmp to be a macro. */
+#define setjmp(jump_buf) __setjmp(jump_buf)
+
+#ifndef __SDCC_HIDE_LONGJMP
+_Noreturn void longjmp(jmp_buf, int) OLDCALL;
+#endif
+
+#undef RET_SIZE
+#undef SP_SIZE
+#undef BP_SIZE
+#undef SPX_SIZE
+#undef BPX_SIZE
+
+#endif
+
diff --git a/gbdk/gbdk-lib/include/sms/gbdecompress.h b/gbdk/gbdk-lib/include/sms/gbdecompress.h
new file mode 100644
index 00000000..4bcbcc12
--- /dev/null
+++ b/gbdk/gbdk-lib/include/sms/gbdecompress.h
@@ -0,0 +1,24 @@
+/** @file gb/gbdecompress.h
+
+ GB-Compress decompressor
+ Compatible with the compression used in GBTD
+*/
+
+#ifndef __GBDECOMPRESS_H_INCLUDE
+#define __GBDECOMPRESS_H_INCLUDE
+
+#include <types.h>
+#include <stdint.h>
+
+/** gb-decompress data from sour into dest
+
+ @param sour Pointer to source gb-compressed data
+ @param dest Pointer to destination buffer/address
+
+ @return Return value is number of bytes decompressed
+
+ @see gb_decompress_bkg_data, gb_decompress_win_data, gb_decompress_sprite_data
+ */
+uint16_t gb_decompress(const uint8_t * sour, uint8_t * dest) Z88DK_CALLEE PRESERVES_REGS(b, c);
+
+#endif \ No newline at end of file
diff --git a/gbdk/gbdk-lib/include/sms/hardware.h b/gbdk/gbdk-lib/include/sms/hardware.h
new file mode 100644
index 00000000..2c3ac1eb
--- /dev/null
+++ b/gbdk/gbdk-lib/include/sms/hardware.h
@@ -0,0 +1,216 @@
+/** @file sms/hardware.h
+ Defines that let the SMS/GG hardware registers be accessed
+ from C.
+*/
+#ifndef _HARDWARE_H
+#define _HARDWARE_H
+
+#include <types.h>
+
+#define __BYTES extern UBYTE
+#define __BYTE_REG extern volatile UBYTE
+
+static volatile SFR AT(0x3E) MEMORY_CTL;
+
+#define MEMCTL_JOYON 0b00000000
+#define MEMCTL_JOYOFF 0b00000100
+#define MEMCTL_BASEON 0b00000000
+#define MEMCTL_BASEOFF 0b00001000
+#define MEMCTL_RAMON 0b00000000
+#define MEMCTL_RAMOFF 0b00010000
+#define MEMCTL_CROMON 0b00000000
+#define MEMCTL_CROMOFF 0b00100000
+#define MEMCTL_ROMON 0b00000000
+#define MEMCTL_ROMOFF 0b01000000
+#define MEMCTL_EXTON 0b00000000
+#define MEMCTL_EXTOFF 0b10000000
+
+static volatile SFR AT(0x3F) JOY_CTL;
+
+#define JOY_P1_LATCH 0b00000010
+#define JOY_P2_LATCH 0b00001000
+
+static volatile SFR AT(0x7E) VCOUNTER;
+
+static volatile SFR AT(0x7F) PSG;
+
+#define PSG_LATCH 0x80
+
+#define PSG_CH0 0b00000000
+#define PSG_CH1 0b00100000
+#define PSG_CH2 0b01000000
+#define PSG_CH3 0b01100000
+
+#define PSG_VOLUME 0b00010000
+
+static volatile SFR AT(0x7F) HCOUNTER;
+
+static volatile SFR AT(0xBE) VDP_DATA;
+static volatile SFR AT(0xBF) VDP_CMD;
+static volatile SFR AT(0xBF) VDP_STATUS;
+
+#define STATF_INT_VBL 0b10000000
+#define STATF_9_SPR 0b01000000
+#define STATF_SPR_COLL 0b00100000
+
+#define VDP_REG_MASK 0b10000000
+#define VDP_R0 0b10000000
+extern UBYTE shadow_VDP_R0;
+
+#define R0_VSCRL 0b00000000
+#define R0_VSCRL_INH 0b10000000
+#define R0_HSCRL 0b00000000
+#define R0_HSCRL_INH 0b01000000
+#define R0_NO_LCB 0b00000000
+#define R0_LCB 0b00100000
+#define R0_IE1_OFF 0b00000000
+#define R0_IE1 0b00010000
+#define R0_SS_OFF 0b00000000
+#define R0_SS 0b00001000
+#define R0_DEFAULT 0b00000110
+#define R0_ES_OFF 0b00000000
+#define R0_ES 0b00000001
+
+#define VDP_R1 0b10000001
+extern UBYTE shadow_VDP_R1;
+
+#define R1_DEFAULT 0b10000000
+#define R1_DISP_OFF 0b00000000
+#define R1_DISP_ON 0b01000000
+#define R1_IE_OFF 0b00000000
+#define R1_IE 0b00100000
+#define R1_SPR_8X8 0b00000000
+#define R1_SPR_8X16 0b00000010
+
+#define VDP_R2 0b10000010
+extern UBYTE shadow_VDP_R2;
+
+#define R2_MAP_0x3800 0xFF
+#define R2_MAP_0x3000 0xFD
+#define R2_MAP_0x2800 0xFB
+#define R2_MAP_0x2000 0xF9
+#define R2_MAP_0x1800 0xF7
+#define R2_MAP_0x1000 0xF5
+#define R2_MAP_0x0800 0xF3
+#define R2_MAP_0x0000 0xF1
+
+#define VDP_R3 0b10000011
+extern UBYTE shadow_VDP_R3;
+#define VDP_R4 0b10000100
+extern UBYTE shadow_VDP_R4;
+#define VDP_R5 0b10000101
+extern UBYTE shadow_VDP_R5;
+
+#define R5_SAT_0x3F00 0xFF
+#define R5_SAT_MASK 0b10000001
+
+#define VDP_R6 0b10000110
+extern UBYTE shadow_VDP_R6;
+
+#define R6_BANK0 0xFB
+#define R6_DATA_0x0000 0xFB
+#define R6_BANK1 0xFF
+#define R6_DATA_0x2000 0xFF
+
+#define VDP_R7 0b10000111
+extern UBYTE shadow_VDP_R7;
+#define VDP_RBORDER 0b10000111
+extern UBYTE shadow_VDP_RBORDER;
+
+#define R7_COLOR_MASK 0b11110000
+
+#define VDP_R8 0b10001000
+extern UBYTE shadow_VDP_R8;
+#define VDP_RSCX 0b10001000
+extern UBYTE shadow_VDP_RSCX;
+
+#define VDP_R9 0b10001001
+extern UBYTE shadow_VDP_R9;
+#define VDP_RSCY 0b10001001
+extern UBYTE shadow_VDP_RSCY;
+
+#define VDP_R10 0b10001010
+extern UBYTE shadow_VDP_R10;
+
+#define R10_INT_OFF 0xFF
+#define R10_INT_EVERY 0x00
+
+static volatile SFR AT(0xDC) JOY_PORT1;
+
+#define JOY_P1_UP 0b00000001
+#define JOY_P1_DOWN 0b00000010
+#define JOY_P1_LEFT 0b00000100
+#define JOY_P1_RIGHT 0b00001000
+#define JOY_P1_SW1 0b00010000
+#define JOY_P1_TRIGGER 0b00010000
+#define JOY_P1_SW2 0b00100000
+#define JOY_P2_UP 0b01000000
+#define JOY_P2_DOWN 0b10000000
+
+static volatile SFR AT(0xDD) JOY_PORT2;
+
+#define JOY_P2_LEFT 0b00000001
+#define JOY_P2_RIGHT 0b00000010
+#define JOY_P2_SW1 0b00000100
+#define JOY_P2_TRIGGER 0b00000100
+#define JOY_P2_SW2 0b00001000
+#define JOY_RESET 0b00010000
+#define JOY_P1_LIGHT 0b01000000
+#define JOY_P2_LIGHT 0b10000000
+
+static volatile SFR AT(0xF0) FMADDRESS;
+static volatile SFR AT(0xF1) FMDATA;
+static volatile SFR AT(0xF2) AUDIOCTRL;
+
+static volatile UBYTE AT(0xfffc) RAM_CONTROL;
+
+#define RAMCTL_BANK 0b00000100
+#define RAMCTL_ROM 0b00000000
+#define RAMCTL_RAM 0b00001000
+#define RAMCTL_RO 0b00010000
+#define RAMCTL_PROT 0b10000000
+
+static volatile UBYTE AT(0xfff8) GLASSES_3D;
+
+static volatile UBYTE AT(0xfffd) MAP_FRAME0;
+static volatile UBYTE AT(0xfffe) MAP_FRAME1;
+static volatile UBYTE AT(0xffff) MAP_FRAME2;
+
+extern const UBYTE _BIOS;
+
+extern const UBYTE _SYSTEM;
+
+#define SYSTEM_PAL 0x00
+#define SYSTEM_NTSC 0x01
+
+extern volatile UBYTE VDP_ATTR_SHIFT;
+
+#define VDP_SAT_TERM 0xD0
+
+#if defined(__TARGET_sms)
+#define DEVICE_SCREEN_X_OFFSET 0
+#define DEVICE_SCREEN_Y_OFFSET 0
+#define DEVICE_SCREEN_WIDTH 32
+#define DEVICE_SCREEN_HEIGHT 24
+#define DEVICE_SCREEN_BUFFER_WIDTH 32
+#define DEVICE_SCREEN_BUFFER_HEIGHT 28
+#define DEVICE_SCREEN_MAP_ENTRY_SIZE 2
+#define DEVICE_SPRITE_PX_OFFSET_X 0
+#define DEVICE_SPRITE_PX_OFFSET_Y -1
+#elif defined(__TARGET_gg)
+#define DEVICE_SCREEN_X_OFFSET 6
+#define DEVICE_SCREEN_Y_OFFSET 3
+#define DEVICE_SCREEN_WIDTH 20
+#define DEVICE_SCREEN_HEIGHT 18
+#define DEVICE_SCREEN_BUFFER_WIDTH 32
+#define DEVICE_SCREEN_BUFFER_HEIGHT 28
+#define DEVICE_SCREEN_MAP_ENTRY_SIZE 2
+#define DEVICE_SPRITE_PX_OFFSET_X 48
+#define DEVICE_SPRITE_PX_OFFSET_Y 23
+#else
+#error Unrecognized port
+#endif
+#define DEVICE_SCREEN_PX_WIDTH (DEVICE_SCREEN_WIDTH * 8)
+#define DEVICE_SCREEN_PX_HEIGHT (DEVICE_SCREEN_HEIGHT * 8)
+
+#endif
diff --git a/gbdk/gbdk-lib/include/sms/metasprites.h b/gbdk/gbdk-lib/include/sms/metasprites.h
new file mode 100644
index 00000000..5719e1a8
--- /dev/null
+++ b/gbdk/gbdk-lib/include/sms/metasprites.h
@@ -0,0 +1,116 @@
+/** @file sms/metasprites.h
+
+ # Metasprite support
+
+ A metasprite is a larger sprite made up from a
+ collection of smaller individual hardware sprites.
+ Different frames of the same metasprites can share
+ tile data.
+
+ The api supports metasprites in both
+ @ref SPRITES_8x8 and @ref SPRITES_8x16 mode. If
+ 8x16 mode is used then the height of the metasprite
+ must be a multiple of 16.
+
+ The origin (pivot) for the metasprite is not required
+ to be in the upper left-hand corner as with regular
+ hardware sprites.
+
+ Use the @ref utility_png2asset tool to convert single
+ or multiple frames of graphics into metasprite
+ structured data for use with the ...metasprite...()
+ functions.
+
+ # Metasprites composed of variable numbers of sprites
+
+ When using png2asset, it's common for the output of
+ different frames to be composed of different numbers
+ of hardware sprites (since it's trying to create each
+ frame as efficiently as possible). Due to that, it's
+ good practice to clear out (hide) unused sprites in the
+ shadow_OAM that have been set by previous frames.
+*/
+
+#ifndef _METASPRITES_H_INCLUDE
+#define _METASPRITES_H_INCLUDE
+
+#include <sms/hardware.h>
+#include <types.h>
+#include <stdint.h>
+
+/** Metasprite sub-item structure
+ @param dy (int8_t) Y coordinate of the sprite relative to the metasprite origin (pivot)
+ @param dx (int8_t) X coordinate of the sprite relative to the metasprite origin (pivot)
+ @param dtile (uint8_t) Start tile relative to the metasprites own set of tiles
+
+ Metasprites are built from multiple metasprite_t items (one for each sub-sprite)
+ and a pool of tiles they reference. If a metasprite has multiple frames then each
+ frame will be built from some number of metasprite_t items (which may vary based
+ on how many sprites are required for that particular frame).
+
+ A metasprite frame is terminated with a {metasprite_end} entry.
+*/
+typedef struct metasprite_t {
+ int8_t dy, dx;
+ uint8_t dtile;
+} metasprite_t;
+
+#define metasprite_end -128
+#define METASPR_ITEM(dy,dx,dt,a) {(dy),(dx),(dt)}
+#define METASPR_TERM {metasprite_end}
+
+extern const void * __current_metasprite;
+extern uint8_t __current_base_tile;
+extern uint8_t __render_shadow_OAM;
+
+
+static uint8_t __move_metasprite(uint8_t id, uint8_t x, uint8_t y) Z88DK_CALLEE PRESERVES_REGS(iyh, iyl);
+static void __hide_metasprite(uint8_t id) Z88DK_FASTCALL PRESERVES_REGS(iyh, iyl);
+
+/**
+ * Hides all hardware sprites in range from <= X < to
+ * @param from start OAM index
+ * @param to finish OAM index
+ */
+void hide_sprites_range(UINT8 from, UINT8 to) Z88DK_CALLEE PRESERVES_REGS(iyh, iyl);
+
+/** Moves metasprite to the absolute position x and y
+
+ @param metasprite Pointer to the first struct of the metasprite (for the desired frame)
+ @param base_tile Number of the first tile where the metasprite's tiles start
+ @param base_sprite Number of the first hardware sprite to be used by the metasprite
+ @param x Absolute x coordinate of the sprite
+ @param y Absolute y coordinate of the sprite
+
+ Moves __metasprite__ to the absolute position __x__ and __y__
+ (with __no flip__ on the X or Y axis). Hardware sprites are
+ allocated starting from __base_sprite__, using tiles
+ starting from __base_tile__.
+
+ Sets:
+ \li __current_metasprite = metasprite;
+ \li __current_base_tile = base_tile;
+
+ @return Number of hardware sprites used to draw this metasprite
+ */
+inline uint8_t move_metasprite(const metasprite_t * metasprite, uint8_t base_tile, uint8_t base_sprite, uint8_t x, uint8_t y) {
+ __current_metasprite = metasprite;
+ __current_base_tile = base_tile;
+ return __move_metasprite(base_sprite, x, y);
+}
+
+/** Hides a metasprite from the screen
+
+ @param metasprite Pointer to first struct of the desired metasprite frame
+ @param base_sprite Number of hardware sprite to start with
+
+ Sets:
+ \li __current_metasprite = metasprite;
+
+ **/
+inline void hide_metasprite(const metasprite_t * metasprite, uint8_t base_sprite) {
+ __current_metasprite = metasprite;
+ __hide_metasprite(base_sprite);
+}
+
+#endif
diff --git a/gbdk/gbdk-lib/include/sms/sms.h b/gbdk/gbdk-lib/include/sms/sms.h
new file mode 100644
index 00000000..1c34617d
--- /dev/null
+++ b/gbdk/gbdk-lib/include/sms/sms.h
@@ -0,0 +1,780 @@
+/** @file sms/sms.h
+ SMS/GG specific functions.
+*/
+#ifndef _SMS_H
+#define _SMS_H
+
+#include <types.h>
+#include <stdint.h>
+#include <gbdk/version.h>
+#include <sms/hardware.h>
+
+#define SEGA
+#ifdef NINTENDO
+#undef NINTENDO
+#endif
+#if defined(__TARGET_sms)
+#define MASTERSYSTEM
+#elif defined(__TARGET_gg)
+#define GAMEGEAR
+#endif
+
+
+#define VBK_REG VDP_ATTR_SHIFT
+
+/** Joypad bits.
+ A logical OR of these is used in the wait_pad and joypad
+ functions. For example, to see if the B button is pressed
+ try
+
+ uint8_t keys;
+ keys = joypad();
+ if (keys & J_B) {
+ ...
+ }
+
+ @see joypad
+ */
+#define J_UP 0b00000001
+#define J_DOWN 0b00000010
+#define J_LEFT 0b00000100
+#define J_RIGHT 0b00001000
+#define J_A 0b00010000
+#define J_B 0b00100000
+#if defined(__TARGET_sms)
+#define J_SELECT 0b00100000
+#define J_START 0b00010000
+#elif defined(__TARGET_gg)
+#define J_SELECT 0b00100000
+#define J_START 0b10000000
+#endif
+
+/** Screen modes.
+ Normally used by internal functions only.
+ @see mode()
+ */
+#define M_TEXT_OUT 0x02U
+#define M_TEXT_INOUT 0x03U
+/** Set this in addition to the others to disable scrolling
+
+ If scrolling is disabled, the cursor returns to (0,0)
+ @see mode()
+*/
+#define M_NO_SCROLL 0x04U
+/** Set this to disable interpretation
+ @see mode()
+*/
+#define M_NO_INTERP 0x08U
+
+/** If set the background tile will be flipped horizontally.
+ */
+#define S_FLIPX 0x02U
+/** If set the background tile will be flipped vertically.
+ */
+#define S_FLIPY 0x04U
+/** If set the background tile palette.
+ */
+#define S_PALETTE 0x08U
+/** If set the background tile priority.
+ */
+#define S_PRIORITY 0x10U
+
+// VDP helper macros
+#define __WRITE_VDP_REG(REG, v) shadow_##REG=(v);__critical{VDP_CMD=(shadow_##REG),VDP_CMD=REG;}
+#define __READ_VDP_REG(REG) shadow_##REG
+
+void WRITE_VDP_CMD(uint16_t cmd) Z88DK_FASTCALL PRESERVES_REGS(b, c, d, e, iyh, iyl);
+void WRITE_VDP_DATA(uint16_t data) Z88DK_FASTCALL PRESERVES_REGS(b, c, d, e, iyh, iyl);
+
+/** Set the current screen mode - one of M_* modes
+
+ Normally used by internal functions only.
+
+ @see M_TEXT_OUT, M_TEXT_INOUT, M_NO_SCROLL, M_NO_INTERP
+*/
+void mode(uint8_t m) OLDCALL;
+
+/** Returns the current mode
+
+ @see M_TEXT_OUT, M_TEXT_INOUT, M_NO_SCROLL, M_NO_INTERP
+*/
+uint8_t get_mode() OLDCALL;
+
+/* Interrupt flags */
+/** Disable calling of interrupt service routines
+ */
+#define EMPTY_IFLAG 0x00U
+/** VBlank Interrupt occurs at the start of the vertical blank.
+
+ During this period the video ram may be freely accessed.
+ @see set_interrupts(), @see add_VBL
+ */
+#define VBL_IFLAG 0x01U
+/** LCD Interrupt when triggered by the STAT register.
+ @see set_interrupts(), @see add_LCD
+*/
+#define LCD_IFLAG 0x02U
+/** Does nothing on SMS/GG
+ */
+#define TIM_IFLAG 0x04U
+/** Does nothing on SMS/GG
+ */
+#define SIO_IFLAG 0x08U
+/** Does nothing on SMS/GG
+ */
+#define JOY_IFLAG 0x10U
+
+void set_interrupts(uint8_t flags) Z88DK_FASTCALL;
+
+/* Limits */
+/** Width of the visible screen in pixels.
+ */
+#define SCREENWIDTH DEVICE_SCREEN_PX_WIDTH
+/** Height of the visible screen in pixels.
+ */
+#define SCREENHEIGHT DEVICE_SCREEN_PX_HEIGHT
+/** The Minimum X position of the Window Layer (Left edge of screen) @see move_win()
+ */
+#define MINWNDPOSX 0x00U
+/** The Minimum Y position of the Window Layer (Top edge of screen) @see move_win()
+ */
+#define MINWNDPOSY 0x00U
+/** The Maximum X position of the Window Layer (Right edge of screen) @see move_win()
+ */
+#define MAXWNDPOSX 0x00U
+/** The Maximum Y position of the Window Layer (Bottom edge of screen) @see move_win()
+ */
+#define MAXWNDPOSY 0x00U
+
+
+/** Interrupt handlers
+ */
+typedef void (*int_handler)(void) NONBANKED;
+
+/** Removes the VBL interrupt handler.
+ @see add_VBL()
+*/
+void remove_VBL(int_handler h) Z88DK_FASTCALL PRESERVES_REGS(iyh, iyl);
+
+/** Removes the LCD interrupt handler.
+ @see add_LCD(), remove_VBL()
+*/
+void remove_LCD(int_handler h) Z88DK_FASTCALL PRESERVES_REGS(b, c, iyh, iyl);
+
+void remove_TIM(int_handler h) Z88DK_FASTCALL;
+void remove_SIO(int_handler h) Z88DK_FASTCALL;
+void remove_JOY(int_handler h) Z88DK_FASTCALL;
+
+/** Adds a V-blank interrupt handler.
+*/
+void add_VBL(int_handler h) Z88DK_FASTCALL PRESERVES_REGS(d, e, iyh, iyl);
+
+/** Adds a LCD interrupt handler.
+*/
+void add_LCD(int_handler h) Z88DK_FASTCALL PRESERVES_REGS(b, c, iyh, iyl);
+
+/** Does nothing on SMS/GG
+ */
+void add_TIM(int_handler h) Z88DK_FASTCALL;
+
+/** Does nothing on SMS/GG
+ */
+void add_SIO(int_handler h) Z88DK_FASTCALL;
+
+/** Does nothing on SMS/GG
+ */
+void add_JOY(int_handler h) Z88DK_FASTCALL;
+
+/** Cancel pending interrupts
+ */
+inline uint8_t cancel_pending_interrupts() {
+ return VDP_STATUS;
+}
+
+inline void move_bkg(uint8_t x, uint8_t y) {
+ __WRITE_VDP_REG(VDP_RSCX, -x);
+ __WRITE_VDP_REG(VDP_RSCY, y);
+}
+
+inline void scroll_bkg(int8_t x, int8_t y) {
+ __WRITE_VDP_REG(VDP_RSCX, __READ_VDP_REG(VDP_RSCX) - x);
+ int16_t tmp = __READ_VDP_REG(VDP_RSCY) + y;
+ __WRITE_VDP_REG(VDP_RSCY, (tmp < 0) ? 224 + tmp : tmp % 224u);
+}
+
+/** HALTs the CPU and waits for the vertical blank interrupt (VBL) to finish.
+
+ This is often used in main loops to idle the CPU at low power
+ until it's time to start the next frame. It's also useful for
+ syncing animation with the screen re-draw.
+
+ Warning: If the VBL interrupt is disabled, this function will
+ never return. If the screen is off this function returns
+ immediately.
+*/
+void wait_vbl_done() PRESERVES_REGS(b, c, d, e, h, l, iyh, iyl);
+
+/** Turns the display off.
+
+ @see DISPLAY_ON
+*/
+inline void display_off() {
+ __WRITE_VDP_REG(VDP_R1, __READ_VDP_REG(VDP_R1) &= (~R1_DISP_ON));
+}
+
+/** Turns the display back on.
+ @see display_off, DISPLAY_OFF
+*/
+#define DISPLAY_ON \
+ __WRITE_VDP_REG(VDP_R1, __READ_VDP_REG(VDP_R1) |= R1_DISP_ON)
+
+/** Turns the display off immediately.
+ @see display_off, DISPLAY_ON
+*/
+#define DISPLAY_OFF \
+ display_off();
+
+/** Copies data from shadow OAM to OAM
+ */
+void refresh_OAM();
+
+/** Blanks leftmost column, so it is not garbaged when you use horizontal scroll
+ @see SHOW_LEFT_COLUMN
+*/
+#define HIDE_LEFT_COLUMN \
+ __WRITE_VDP_REG(VDP_R0, __READ_VDP_REG(VDP_R0) |= R0_LCB)
+
+/** Shows leftmost column
+ @see HIDE_LEFT_COLUMN
+*/
+#define SHOW_LEFT_COLUMN \
+ __WRITE_VDP_REG(VDP_R0, __READ_VDP_REG(VDP_R0) &= (~R0_LCB))
+
+/** Turns on the background layer.
+ Not yet implemented
+*/
+#define SHOW_BKG
+
+/** Turns off the background layer.
+ Not yet implemented
+*/
+#define HIDE_BKG
+
+/** Turns on the window layer
+ Not yet implemented
+*/
+#define SHOW_WIN
+
+/** Turns off the window layer.
+ Not yet implemented
+*/
+#define HIDE_WIN
+
+/** Turns on the sprites layer.
+ Not yet implemented
+*/
+#define SHOW_SPRITES
+
+/** Turns off the sprites layer.
+ Not yet implemented
+*/
+#define HIDE_SPRITES
+
+/** Sets sprite size to 8x16 pixels, two tiles one above the other.
+*/
+#define SPRITES_8x16 \
+ __WRITE_VDP_REG(VDP_R1, __READ_VDP_REG(VDP_R1) |= R1_SPR_8X16)
+
+/** Sets sprite size to 8x8 pixels, one tile.
+*/
+#define SPRITES_8x8 \
+ __WRITE_VDP_REG(VDP_R1, __READ_VDP_REG(VDP_R1) &= (~R1_SPR_8X16))
+
+/** Macro returns TRUE if device supports color
+ * (it always does on SMS/GG)
+ */
+#define DEVICE_SUPPORTS_COLOR (TRUE)
+
+/** Global Time Counter in VBL periods (60Hz)
+
+ Increments once per Frame
+
+ Will wrap around every ~18 minutes (unsigned 16 bits = 65535 / 60 / 60 = 18.2)
+*/
+extern volatile uint16_t sys_time;
+
+/** Tracks current active ROM bank in frame 1
+*/
+#define _current_bank MAP_FRAME1
+#define CURRENT_BANK MAP_FRAME1
+
+/** Obtains the __bank number__ of VARNAME
+
+ @param VARNAME Name of the variable which has a __bank_VARNAME companion symbol which is adjusted by bankpack
+
+ Use this to obtain the bank number from a bank reference
+ created with @ref BANKREF().
+
+ @see BANKREF_EXTERN(), BANKREF()
+*/
+#ifndef BANK
+#define BANK(VARNAME) ( (uint8_t) & __bank_ ## VARNAME )
+#endif
+
+/** Creates a reference for retrieving the bank number of a variable or function
+
+ @param VARNAME Variable name to use, which may be an existing identifier
+
+ @see BANK() for obtaining the bank number of the included data.
+
+ More than one `BANKREF()` may be created per file, but each call should
+ always use a unique VARNAME.
+
+ Use @ref BANKREF_EXTERN() within another source file
+ to make the variable and it's data accesible there.
+*/
+#define BANKREF(VARNAME) void __func_ ## VARNAME() __banked __naked { \
+__asm \
+ .local b___func_ ## VARNAME \
+ ___bank_ ## VARNAME = b___func_ ## VARNAME \
+ .globl ___bank_ ## VARNAME \
+__endasm; \
+}
+
+/** Creates extern references for accessing a BANKREF() generated variable.
+
+ @param VARNAME Name of the variable used with @ref BANKREF()
+
+ This makes a @ref BANKREF() reference in another source
+ file accessible in the current file for use with @ref BANK().
+
+ @see BANKREF(), BANK()
+*/
+#define BANKREF_EXTERN(VARNAME) extern const void __bank_ ## VARNAME;
+
+
+/** Makes switch the active ROM bank in frame 1
+ @param b ROM bank to switch to
+*/
+
+#define SWITCH_ROM(b) MAP_FRAME1=(b)
+#define SWITCH_ROM1 SWITCH_ROM
+
+/** Makes switch the active ROM bank in frame 2
+ @param b ROM bank to switch to
+*/
+
+#define SWITCH_ROM2(b) MAP_FRAME2=(b)
+
+/** Switches RAM bank
+ @param b SRAM bank to switch to
+*/
+
+#define SWITCH_RAM(b) RAM_CONTROL=((b)&1)?RAM_CONTROL|RAMCTL_BANK:RAM_CONTROL&(~RAMCTL_BANK)
+
+/** Enables RAM
+*/
+
+#define ENABLE_RAM RAM_CONTROL|=RAMCTL_RAM
+
+/** Disables RAM
+*/
+
+#define DISABLE_RAM RAM_CONTROL&=(~RAMCTL_RAM)
+
+
+/** Delays the given number of milliseconds.
+ Uses no timers or interrupts, and can be called with
+ interrupts disabled
+ */
+void delay(uint16_t d) Z88DK_FASTCALL;
+
+
+/** Reads and returns the current state of the joypad.
+*/
+uint8_t joypad() OLDCALL PRESERVES_REGS(b, c, d, e, h, iyh, iyl);
+
+/** Waits until at least one of the buttons given in mask are pressed.
+*/
+uint8_t waitpad(uint8_t mask) Z88DK_FASTCALL PRESERVES_REGS(b, c, d, e, iyh, iyl);
+
+/** Waits for the directional pad and all buttons to be released.
+
+ Note: Checks in a loop that doesn't HALT at all, so the CPU
+ will be maxed out until this call returns.
+*/
+void waitpadup() PRESERVES_REGS(b, c, d, e, iyh, iyl);
+
+/** Multiplayer joypad structure.
+
+ Must be initialized with @ref joypad_init() first then it
+ may be used to poll all avaliable joypads with @ref joypad_ex()
+*/
+typedef struct {
+ uint8_t npads;
+ union {
+ struct {
+ uint8_t joy0, joy1, joy2, joy3;
+ };
+ uint8_t joypads[4];
+ };
+} joypads_t;
+
+/** Initializes joypads_t structure for polling multiple joypads
+ @param npads number of joypads requested (1, 2 or 4)
+ @param joypads pointer to joypads_t structure to be initialized
+
+ Only required for @ref joypad_ex, not required for calls to regular @ref joypad()
+ @returns number of joypads avaliable
+ @see joypad_ex(), joypads_t
+*/
+uint8_t joypad_init(uint8_t npads, joypads_t * joypads) Z88DK_CALLEE;
+
+/** Polls all avaliable joypads
+ @param joypads pointer to joypads_t structure to be filled with joypad statuses,
+ must be previously initialized with joypad_init()
+
+ @see joypad_init(), joypads_t
+*/
+void joypad_ex(joypads_t * joypads) Z88DK_FASTCALL PRESERVES_REGS(iyh, iyl);
+
+
+#if defined(__TARGET_sms)
+
+#define RGB(r,g,b) ((r) | ((g) << 2) | ((b) << 4))
+#define RGB8(r,g,b) (((r) >> 6) | (((g) >> 6) << 2) | (((b) >> 6) << 4))
+#define RGBHTML(RGB24bit) (((RGB24bit) >> 22) | ((((RGB24bit) & 0xFFFF) >> 14) << 2) | ((((RGB24bit) & 0xFF) >> 6) << 4))
+
+/** Common colors based on the EGA default palette.
+ */
+#define RGB_RED RGB( 3, 0, 0)
+#define RGB_DARKRED RGB( 2, 0, 0)
+#define RGB_GREEN RGB( 0, 3, 0)
+#define RGB_DARKGREEN RGB( 0, 2, 0)
+#define RGB_BLUE RGB( 0, 0, 3)
+#define RGB_DARKBLUE RGB( 0, 0, 2)
+#define RGB_YELLOW RGB( 3, 3, 0)
+#define RGB_DARKYELLOW RGB( 2, 2, 0)
+#define RGB_CYAN RGB( 0, 3, 3)
+#define RGB_AQUA RGB( 3, 1, 2)
+#define RGB_PINK RGB( 3, 0, 3)
+#define RGB_PURPLE RGB( 2, 0, 2)
+#define RGB_BLACK RGB( 0, 0, 0)
+#define RGB_DARKGRAY RGB( 1, 1, 1)
+#define RGB_LIGHTGRAY RGB( 2, 2, 2)
+#define RGB_WHITE RGB( 3, 3, 3)
+
+typedef uint8_t palette_color_t;
+
+#elif defined(__TARGET_gg)
+
+#define RGB(r,g,b) ((uint16_t)(r) | (uint16_t)((g) << 4) | (uint16_t)((b) << 8))
+#define RGB8(r,g,b) ((uint16_t)((r) >> 4) | ((uint16_t)((g) >> 4) << 4) | ((uint16_t)((b) >> 4) << 8))
+#define RGBHTML(RGB24bit) (((RGB24bit) >> 20) | ((((RGB24bit) & 0xFFFF) >> 12) << 4)|((((RGB24bit) & 0xFF) >> 4) << 8))
+
+/** Common colors based on the EGA default palette.
+ */
+#define RGB_RED RGB(15, 0, 0)
+#define RGB_DARKRED RGB( 7, 0, 0)
+#define RGB_GREEN RGB( 0, 15, 0)
+#define RGB_DARKGREEN RGB( 0, 7, 0)
+#define RGB_BLUE RGB( 0, 0, 15)
+#define RGB_DARKBLUE RGB( 0, 0, 7)
+#define RGB_YELLOW RGB(15, 15, 0)
+#define RGB_DARKYELLOW RGB( 7, 7, 0)
+#define RGB_CYAN RGB( 0, 15, 15)
+#define RGB_AQUA RGB(14, 2, 11)
+#define RGB_PINK RGB(15, 0, 15)
+#define RGB_PURPLE RGB(10, 0, 10)
+#define RGB_BLACK RGB( 0, 0, 0)
+#define RGB_DARKGRAY RGB( 5, 5, 5)
+#define RGB_LIGHTGRAY RGB(10, 10, 10)
+#define RGB_WHITE RGB(15, 15, 15)
+
+#define RGB_LIGHTFLESH RGB(15, 10, 7)
+#define RGB_BROWN RGB( 5, 5, 0)
+#define RGB_ORANGE RGB(15, 10, 0)
+#define RGB_TEAL RGB( 7, 7, 0)
+
+typedef uint16_t palette_color_t;
+
+#else
+#error Unrecognized port
+#endif
+
+void set_default_palette();
+inline void cpu_fast() {}
+
+void set_palette_entry(uint8_t palette, uint8_t entry, uint16_t rgb_data) Z88DK_CALLEE PRESERVES_REGS(iyh, iyl);
+#define set_bkg_palette_entry set_palette_entry
+#define set_sprite_palette_entry(palette,entry,rgb_data) set_palette_entry(1,entry,rgb_data)
+void set_palette(uint8_t first_palette, uint8_t nb_palettes, palette_color_t *rgb_data) Z88DK_CALLEE;
+#define set_bkg_palette set_palette
+#define set_sprite_palette(first_palette,nb_palettes,rgb_data) set_palette(1,1,rgb_data)
+
+void set_native_tile_data(uint16_t start, uint16_t ntiles, const void *src) Z88DK_CALLEE PRESERVES_REGS(iyh, iyl);
+inline void set_bkg_4bpp_data(uint16_t start, uint16_t ntiles, const void *src) {
+ set_native_tile_data(start, ntiles, src);
+}
+inline void set_sprite_4bpp_data(uint16_t start, uint16_t ntiles, const void *src) {
+ set_native_tile_data((uint8_t)(start) + 0x100u, ntiles, src);
+}
+
+#define COMPAT_PALETTE(C0,C1,C2,C3) (((uint16_t)(C3) << 12) | ((uint16_t)(C2) << 8) | ((uint16_t)(C1) << 4) | (uint16_t)(C0))
+extern uint16_t _current_2bpp_palette;
+inline void set_2bpp_palette(uint16_t palette) {
+ _current_2bpp_palette = palette;
+}
+void set_tile_2bpp_data(uint16_t start, uint16_t ntiles, const void *src, uint16_t palette) Z88DK_CALLEE PRESERVES_REGS(iyh, iyl);
+inline void set_bkg_data(uint16_t start, uint16_t ntiles, const void *src) {
+ set_tile_2bpp_data(start, ntiles, src, _current_2bpp_palette);
+}
+inline void set_sprite_data(uint16_t start, uint16_t ntiles, const void *src) {
+ set_tile_2bpp_data((uint8_t)(start) + 0x100u, ntiles, src, _current_2bpp_palette);
+}
+inline void set_bkg_2bpp_data(uint16_t start, uint16_t ntiles, const void *src) {
+ set_tile_2bpp_data(start, ntiles, src, _current_2bpp_palette);
+}
+inline void set_sprite_2bpp_data(uint16_t start, uint16_t ntiles, const void *src) {
+ set_tile_2bpp_data((uint8_t)(start) + 0x100u, ntiles, src, _current_2bpp_palette);
+}
+
+extern uint16_t _current_1bpp_colors;
+inline void set_1bpp_colors(uint8_t fgcolor, uint8_t bgcolor) {
+ _current_1bpp_colors = ((uint16_t)bgcolor << 8) | fgcolor;
+}
+void set_tile_1bpp_data(uint16_t start, uint16_t ntiles, const void *src, uint16_t colors) Z88DK_CALLEE PRESERVES_REGS(iyh, iyl);
+inline void set_bkg_1bpp_data(uint16_t start, uint16_t ntiles, const void *src) {
+ set_tile_1bpp_data(start, ntiles, src, _current_1bpp_colors);
+}
+inline void set_sprite_1bpp_data(uint16_t start, uint16_t ntiles, const void *src) {
+ set_tile_1bpp_data((uint8_t)(start) + 0x100u, ntiles, src, _current_1bpp_colors);
+}
+
+
+/** Copies arbitrary data to an address in VRAM
+
+ @param dst destination VRAM Address
+ @param src Pointer to source buffer
+ @param size Number of bytes to copy
+
+ Copies __size__ bytes from a buffer at _src__ to VRAM starting at __dst__.
+*/
+void set_data(uint16_t dst, const void *src, uint16_t size) Z88DK_CALLEE PRESERVES_REGS(iyh, iyl);
+void vmemcpy(uint16_t dst, const void *src, uint16_t size) Z88DK_CALLEE PRESERVES_REGS(iyh, iyl);
+
+void set_tile_map(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *tiles) Z88DK_CALLEE PRESERVES_REGS(iyh, iyl);
+void set_tile_map_compat(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *tiles) Z88DK_CALLEE PRESERVES_REGS(iyh, iyl);
+#define set_bkg_tiles set_tile_map_compat
+#define set_win_tiles set_tile_map_compat
+
+extern uint8_t _map_tile_offset;
+inline void set_bkg_based_tiles(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *tiles, uint8_t base_tile) {
+ _map_tile_offset = base_tile;
+ set_tile_map_compat(x, y, w, h, tiles);
+ _map_tile_offset = 0;
+}
+inline void set_win_based_tiles(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *tiles, uint8_t base_tile) {
+ _map_tile_offset = base_tile;
+ set_tile_map_compat(x, y, w, h, tiles);
+ _map_tile_offset = 0;
+}
+
+void set_tile_submap(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t map_w, const uint8_t *map) Z88DK_CALLEE PRESERVES_REGS(iyh, iyl);
+void set_tile_submap_compat(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t map_w, const uint8_t *map) Z88DK_CALLEE PRESERVES_REGS(iyh, iyl);
+inline void set_bkg_submap(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *map, uint8_t map_w) {
+ set_tile_submap_compat(x, y, w, h, map_w, map);
+}
+inline void set_win_submap(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *map, uint8_t map_w) {
+ set_tile_submap_compat(x, y, w, h, map_w, map);
+}
+
+extern uint8_t _submap_tile_offset;
+inline void set_bkg_based_submap(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *map, uint8_t map_w, uint8_t base_tile) {
+ _submap_tile_offset = base_tile;
+ set_tile_submap_compat(x, y, w, h, map_w, map);
+ _submap_tile_offset = 0;
+}
+inline void set_win_based_submap(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *map, uint8_t map_w, uint8_t base_tile) {
+ _submap_tile_offset = base_tile;
+ set_tile_submap_compat(x, y, w, h, map_w, map);
+ _submap_tile_offset = 0;
+}
+
+void fill_rect(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint16_t tile) Z88DK_CALLEE PRESERVES_REGS(iyh, iyl);
+void fill_rect_compat(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint16_t tile) Z88DK_CALLEE PRESERVES_REGS(iyh, iyl);
+#define fill_bkg_rect fill_rect_compat
+#define fill_win_rect fill_rect_compat
+
+/** Shadow OAM array in WRAM, that is transferred into the real OAM each VBlank
+*/
+extern volatile uint8_t shadow_OAM[];
+
+/** MSB of shadow_OAM address is used by OAM copying routine
+*/
+extern volatile uint8_t _shadow_OAM_base;
+
+/** Flag for disabling of OAM copying routine
+
+ Values:
+ \li 1: OAM copy routine is disabled (non-isr VDP operation may be in progress)
+ \li 0: OAM copy routine is enabled
+
+ This flag is modified by all sms/gg GBDK API calls that write to the VDP.
+ It is set to DISABLED when they start and ENABLED when they complete.
+
+ @note It is recommended to avoid writing to the Video Display Processor
+ (VDP) during an interrupt service routine (ISR) since it can corrupt
+ the VDP pointer of an VDP operation already in progress.
+
+ If it is necessary, this flag can be used during an ISR to determine
+ whether a VDP operation is already in progress. If the value is `1`
+ then avoid writing to the VDP (tiles, map, scrolling, colors, etc).
+
+ \code{.c}
+ // at the beginning of and ISR that would write to the VDP
+ if (_shadow_OAM_OFF) return;
+ \endcode
+
+ @see @ref docs_consoles_safe_display_controller_access
+*/
+extern volatile uint8_t _shadow_OAM_OFF;
+
+/** Disable shadow OAM to VRAM copy on each VBlank
+*/
+#define DISABLE_VBL_TRANSFER \
+ _shadow_OAM_base = 0
+
+/** Enable shadow OAM to VRAM copy on each VBlank
+*/
+#define ENABLE_VBL_TRANSFER \
+ _shadow_OAM_base = (uint8_t)((uint16_t)&shadow_OAM >> 8)
+
+/** Amount of hardware sprites in OAM
+*/
+#define MAX_HARDWARE_SPRITES 64
+
+/** Sets address of 256-byte aligned array of shadow OAM to be transferred on each VBlank
+*/
+inline void SET_SHADOW_OAM_ADDRESS(void * address) {
+ _shadow_OAM_base = (uint8_t)((uint16_t)address >> 8);
+}
+
+/** Sets sprite number __nb__in the OAM to display tile number __tile__.
+
+ @param nb Sprite number, range 0 - 39
+ @param tile Selects a tile (0 - 255) from memory at 8000h - 8FFFh
+ \n In CGB Mode this could be either in VRAM Bank
+ \n 0 or 1, depending on Bit 3 of the OAM Attribute Flag
+ \n (see @ref set_sprite_prop)
+
+ In 8x16 mode:
+ \li The sprite will also display the next tile (__tile__ + 1)
+ directly below (y + 8) the first tile.
+ \li The lower bit of the tile number is ignored:
+ the upper 8x8 tile is (__tile__ & 0xFE), and
+ the lower 8x8 tile is (__tile__ | 0x01).
+ \li See: @ref SPRITES_8x16
+*/
+inline void set_sprite_tile(uint8_t nb, uint8_t tile) {
+ shadow_OAM[0x41+(nb << 1)] = tile;
+}
+
+
+/** Returns the tile number of sprite number __nb__ in the OAM.
+
+@param nb Sprite number, range 0 - 39
+
+@see set_sprite_tile for more details
+*/
+inline uint8_t get_sprite_tile(uint8_t nb) {
+ return shadow_OAM[0x41+(nb << 1)];
+}
+
+inline void set_sprite_prop(uint8_t nb, uint8_t prop) {
+ nb; prop;
+}
+
+inline uint8_t get_sprite_prop(uint8_t nb) {
+ nb;
+ return 0;
+}
+
+/** Moves sprite number __nb__ to the __x__, __y__ position on the screen.
+
+ @param nb Sprite number, range 0 - 39
+ @param x X Position. Specifies the sprites horizontal position on the screen (minus 8).
+ \n An offscreen value (X=0 or X>=168) hides the sprite, but the sprite
+ still affects the priority ordering - a better way to hide a sprite is to set
+ its Y-coordinate offscreen.
+ @param y Y Position. Specifies the sprites vertical position on the screen (minus 16).
+ \n An offscreen value (for example, Y=0 or Y>=160) hides the sprite.
+
+ Moving the sprite to 0,0 (or similar off-screen location) will hide it.
+*/
+inline void move_sprite(uint8_t nb, uint8_t x, uint8_t y) {
+ shadow_OAM[nb] = (y < VDP_SAT_TERM) ? y : 0xC0;
+ shadow_OAM[0x40+(nb << 1)] = x;
+}
+
+
+/** Moves sprite number __nb__ relative to its current position.
+
+ @param nb Sprite number, range 0 - 39
+ @param x Number of pixels to move the sprite on the __X axis__
+ \n Range: -128 - 127
+ @param y Number of pixels to move the sprite on the __Y axis__
+ \n Range: -128 - 127
+
+ @see move_sprite for more details about the X and Y position
+ */
+inline void scroll_sprite(uint8_t nb, int8_t x, int8_t y) {
+ uint8_t new_y = shadow_OAM[nb] + y;
+ shadow_OAM[nb] = (new_y < VDP_SAT_TERM) ? new_y : 0xC0;
+ shadow_OAM[0x40+(nb << 1)] = x;
+}
+
+
+/** Hides sprite number __nb__ by moving it to zero position by Y.
+
+ @param nb Sprite number, range 0 - 39
+ */
+inline void hide_sprite(uint8_t nb) {
+ shadow_OAM[nb] = 0xC0;
+}
+
+/**
+ * Set byte in vram at given memory location
+ *
+ * @param addr address to write to
+ * @param v value
+ */
+void set_vram_byte(uint8_t * addr, uint8_t v) Z88DK_CALLEE PRESERVES_REGS(iyh, iyl);
+
+/**
+ * Set single tile t with attributes on background layer at x,y
+ * @param x X-coordinate
+ * @param y Y-coordinate
+ * @param t tile index
+ * @return returns the address of tile, so you may use faster set_vram_byte() later
+ */
+uint8_t * set_attributed_tile_xy(uint8_t x, uint8_t y, uint16_t t) Z88DK_CALLEE PRESERVES_REGS(iyh, iyl);
+
+/**
+ * Set single tile t on background layer at x,y
+ * @param x X-coordinate
+ * @param y Y-coordinate
+ * @param t tile index
+ * @return returns the address of tile, so you may use faster set_vram_byte() later
+ */
+uint8_t * set_tile_xy(uint8_t x, uint8_t y, uint8_t t) Z88DK_CALLEE PRESERVES_REGS(iyh, iyl);
+#define set_bkg_tile_xy set_tile_xy
+#define set_win_tile_xy set_tile_xy
+
+/**
+ * Get address of X,Y tile of background map
+ */
+uint8_t * get_bkg_xy_addr(uint8_t x, uint8_t y) Z88DK_CALLEE PRESERVES_REGS(iyh, iyl);
+#define get_win_xy_addr get_bkg_xy_addr
+
+#endif /* _SMS_H */
diff --git a/gbdk/gbdk-lib/include/stdarg.h b/gbdk/gbdk-lib/include/stdarg.h
new file mode 100644
index 00000000..6c870bc8
--- /dev/null
+++ b/gbdk/gbdk-lib/include/stdarg.h
@@ -0,0 +1,12 @@
+#ifndef STDARG_INCLUDE
+#define STDARG_INCLUDE
+
+#if defined(__PORT_sm83)
+#include <asm/sm83/stdarg.h>
+#elif defined(__PORT_z80)
+#include <asm/z80/stdarg.h>
+#else
+#error Unrecognised port.
+#endif
+
+#endif
diff --git a/gbdk/gbdk-lib/include/stdatomic.h b/gbdk/gbdk-lib/include/stdatomic.h
new file mode 100644
index 00000000..747179d0
--- /dev/null
+++ b/gbdk/gbdk-lib/include/stdatomic.h
@@ -0,0 +1,21 @@
+#ifndef __SDCC_STDATOMIC_H
+#define __SDCC_STDATOMIC_H 1
+
+#include <types.h>
+
+typedef struct {unsigned char flag;} atomic_flag;
+
+#if defined(__SDCC_z80) || defined(__SDCC_z180) || defined(__SDCC_ez80_z80) || defined(__SDCC_sm83) || defined(__SDCC_r2k) || defined(__SDCC_r3ka) || defined(__SDCC_stm8) || defined(__SDCC_hc08) || defined(__SDCC_s08)
+#define ATOMIC_FLAG_INIT {1}
+//#elif defined(__SDCC_mcs51)
+//#define ATOMIC_FLAG_INIT {0}
+#else
+#error Support for atomic_flag not implemented
+#endif
+
+_Bool atomic_flag_test_and_set(volatile atomic_flag *object) OLDCALL;
+
+void atomic_flag_clear(volatile atomic_flag *object);
+
+#endif
+
diff --git a/gbdk/gbdk-lib/include/stdbool.h b/gbdk/gbdk-lib/include/stdbool.h
new file mode 100644
index 00000000..018bfe6b
--- /dev/null
+++ b/gbdk/gbdk-lib/include/stdbool.h
@@ -0,0 +1,40 @@
+/*-------------------------------------------------------------------------
+ stdbool.h - ANSI functions forward declarations
+
+ Copyright (C) 2004, Maarten Brock, sourceforge.brock@dse.nl
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to the
+ Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+ As a special exception, if you link this library with other files,
+ some of which are compiled with SDCC, to produce an executable,
+ this library does not by itself cause the resulting executable to
+ be covered by the GNU General Public License. This exception does
+ not however invalidate any other reasons why the executable file
+ might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
+
+#ifndef __SDC51_STDBOOL_H
+#define __SDC51_STDBOOL_H 1
+
+/* Define true and false of type _Bool in a way compatible with the preprocessor (see N 2229 for details). */
+#define true ((_Bool)+1)
+#define false ((_Bool)+0)
+
+#define bool _Bool
+#define __bool_true_false_are_defined 1
+
+#endif
+
diff --git a/gbdk/gbdk-lib/include/stddef.h b/gbdk/gbdk-lib/include/stddef.h
new file mode 100644
index 00000000..fa03894a
--- /dev/null
+++ b/gbdk/gbdk-lib/include/stddef.h
@@ -0,0 +1,78 @@
+/*-------------------------------------------------------------------------
+ stddef.h - ANSI functions forward declarations
+
+ Copyright (C) 2004, Maarten Brock / sourceforge.brock@dse.nl
+ Copyright (C) 2011, Philipp Klaus Krause / pkk@spth.de
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to the
+ Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+ As a special exception, if you link this library with other files,
+ some of which are compiled with SDCC, to produce an executable,
+ this library does not by itself cause the resulting executable to
+ be covered by the GNU General Public License. This exception does
+ not however invalidate any other reasons why the executable file
+ might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
+
+#ifndef __SDCC_STDDEF_H
+#define __SDCC_STDDEF_H 1
+
+#ifndef NULL
+ #define NULL (void *)0
+#endif
+
+#ifndef __PTRDIFF_T_DEFINED
+#define __PTRDIFF_T_DEFINED
+#if defined (__SDCC_mcs51) || defined (__SDCC_ds390)
+ typedef long int ptrdiff_t;
+#else
+ typedef int ptrdiff_t;
+#endif
+#endif
+
+#ifndef __SIZE_T_DEFINED
+#define __SIZE_T_DEFINED
+ typedef unsigned int size_t;
+#endif
+
+#if __STDC_VERSION__ >= 201112L
+ typedef unsigned char max_align_t;
+#endif
+
+#ifndef __WCHAR_T_DEFINED
+#define __WCHAR_T_DEFINED
+ typedef unsigned long int wchar_t;
+#endif
+
+/* Bounds-checking interfaces from annex K of the C11 standard. */
+#if defined (__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__
+
+#ifndef __RSIZE_T_DEFINED
+#define __RSIZE_T_DEFINED
+typedef size_t rsize_t;
+#endif
+
+#ifndef __ERRNO_T_DEFINED
+#define __ERRNO_T_DEFINED
+typedef int errno_t;
+#endif
+
+#endif
+
+#define offsetof(s, m) __builtin_offsetof (s, m)
+
+#endif
+
diff --git a/gbdk/gbdk-lib/include/stdint.h b/gbdk/gbdk-lib/include/stdint.h
new file mode 100644
index 00000000..9401212c
--- /dev/null
+++ b/gbdk/gbdk-lib/include/stdint.h
@@ -0,0 +1,274 @@
+/*-------------------------------------------------------------------------
+ stdint.h - ISO C99 7.18 Integer types <stdint.h>
+
+ Copyright (C) 2005, Maarten Brock, sourceforge.brock@dse.nl
+ Copyright (C) 2011, Philipp Klaus Krause, pkk@spth.de
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to the
+ Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+ As a special exception, if you link this library with other files,
+ some of which are compiled with SDCC, to produce an executable,
+ this library does not by itself cause the resulting executable to
+ be covered by the GNU General Public License. This exception does
+ not however invalidate any other reasons why the executable file
+ might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
+
+#ifndef _STDINT_H
+#define _STDINT_H 1
+
+/* Exact integral types. */
+
+#if !defined(__SDCC_pic14) && !defined(__SDCC_pic16)
+#if __STDC_VERSION__ >= 199901L
+#define __SDCC_LONGLONG
+#endif
+#endif
+
+/* Signed. */
+
+typedef signed char int8_t;
+typedef short int int16_t;
+typedef long int int32_t;
+#ifdef __SDCC_LONGLONG
+typedef long long int int64_t;
+#endif
+
+/* Unsigned. */
+typedef unsigned char uint8_t;
+typedef unsigned short int uint16_t;
+typedef unsigned long int uint32_t;
+#ifdef __SDCC_LONGLONG
+typedef unsigned long long int uint64_t;
+#endif
+
+/* Small types. */
+
+/* Signed. */
+typedef signed char int_least8_t;
+typedef short int int_least16_t;
+typedef long int int_least32_t;
+#ifdef __SDCC_LONGLONG
+typedef long long int int_least64_t;
+#endif
+
+/* Unsigned. */
+typedef unsigned char uint_least8_t;
+typedef unsigned short int uint_least16_t;
+typedef unsigned long int uint_least32_t;
+#ifdef __SDCC_LONGLONG
+typedef unsigned long long int uint_least64_t;
+#endif
+
+/* Fast types. */
+
+/* Signed. */
+typedef signed char int_fast8_t;
+typedef int int_fast16_t;
+typedef long int int_fast32_t;
+#ifdef __SDCC_LONGLONG
+typedef long long int int_fast64_t;
+#endif
+
+/* Unsigned. */
+typedef unsigned char uint_fast8_t;
+typedef unsigned int uint_fast16_t;
+typedef unsigned long int uint_fast32_t;
+#ifdef __SDCC_LONGLONG
+typedef unsigned long long int uint_fast64_t;
+#endif
+
+/* Types for `void *' pointers. */
+#if defined (__SDCC_mcs51) || defined (__SDCC_ds390)
+ typedef long int intptr_t;
+ typedef unsigned long int uintptr_t;
+#else
+ typedef int intptr_t;
+ typedef unsigned int uintptr_t;
+#endif
+
+
+/* Largest integral types. */
+#ifndef __SDCC_LONGLONG
+typedef long int intmax_t;
+typedef unsigned long int uintmax_t;
+#else
+typedef long long int intmax_t;
+typedef unsigned long long int uintmax_t;
+#endif
+
+/* Limits of integral types. */
+
+/* Minimum of signed integral types. */
+#define INT8_MIN (-128)
+#define INT16_MIN (-32767-1)
+#define INT32_MIN (-2147483647L-1)
+#ifdef __SDCC_LONGLONG
+#define INT64_MIN (-9223372036854775807LL-1)
+#endif
+
+/* Maximum of signed integral types. */
+#define INT8_MAX (127)
+#define INT16_MAX (32767)
+#define INT32_MAX (2147483647L)
+#ifdef __SDCC_LONGLONG
+#define INT64_MAX (9223372036854775807LL)
+#endif
+
+/* Maximum of unsigned integral types. */
+#define UINT8_MAX (255)
+#define UINT16_MAX (65535)
+#define UINT32_MAX (4294967295UL)
+#ifdef __SDCC_LONGLONG
+#define UINT64_MAX (18446744073709551615ULL)
+#endif
+
+/* Minimum of signed integral types having a minimum size. */
+#define INT_LEAST8_MIN INT8_MIN
+#define INT_LEAST16_MIN INT16_MIN
+#define INT_LEAST32_MIN INT32_MIN
+#ifdef __SDCC_LONGLONG
+#define INT_LEAST64_MIN INT64_MIN
+#endif
+
+/* Maximum of signed integral types having a minimum size. */
+#define INT_LEAST8_MAX INT8_MAX
+#define INT_LEAST16_MAX INT16_MAX
+#define INT_LEAST32_MAX INT32_MAX
+#ifdef __SDCC_LONGLONG
+#define INT_LEAST64_MAX INT64_MAX
+#endif
+
+/* Maximum of unsigned integral types having a minimum size. */
+#define UINT_LEAST8_MAX UINT8_MAX
+#define UINT_LEAST16_MAX UINT16_MAX
+#define UINT_LEAST32_MAX UINT32_MAX
+#ifdef __SDCC_LONGLONG
+#define UINT_LEAST64_MAX UINT64_MAX
+#endif
+
+/* Minimum of fast signed integral types having a minimum size. */
+#define INT_FAST8_MIN INT8_MIN
+#define INT_FAST16_MIN INT16_MIN
+#define INT_FAST32_MIN INT32_MIN
+#ifdef __SDCC_LONGLONG
+#define INT_FAST64_MIN INT64_MIN
+#endif
+
+/* Maximum of fast signed integral types having a minimum size. */
+#define INT_FAST8_MAX INT8_MAX
+#define INT_FAST16_MAX INT16_MAX
+#define INT_FAST32_MAX INT32_MAX
+#ifdef __SDCC_LONGLONG
+#define INT_FAST64_MAX INT64_MAX
+#endif
+
+/* Maximum of fast unsigned integral types having a minimum size. */
+#define UINT_FAST8_MAX UINT8_MAX
+#define UINT_FAST16_MAX UINT16_MAX
+#define UINT_FAST32_MAX UINT32_MAX
+#ifdef __SDCC_LONGLONG
+#define UINT_FAST64_MAX UINT64_MAX
+#endif
+
+/* Values to test for integral types holding `void *' pointer. */
+#if defined (__SDCC_mcs51) || defined (__SDCC_ds390)
+#define INTPTR_MIN (-2147483647L-1)
+#define INTPTR_MAX (2147483647L)
+#define UINTPTR_MAX (4294967295UL)
+#else
+#define INTPTR_MIN (-32767-1)
+#define INTPTR_MAX (32767)
+#define UINTPTR_MAX (65535)
+#endif
+
+/* Minimum for largest signed integral type. */
+#ifndef __SDCC_LONGLONG
+#define INTMAX_MIN (-2147483647L-1)
+#else
+#define INTMAX_MIN (-9223372036854775807LL-1)
+#endif
+
+/* Maximum for largest signed integral type. */
+#ifndef __SDCC_LONGLONG
+#define INTMAX_MAX (2147483647L)
+#else
+#define INTMAX_MAX (9223372036854775807LL)
+#endif
+
+/* Maximum for largest unsigned integral type. */
+#ifndef __SDCC_LONGLONG
+#define UINTMAX_MAX (4294967295UL)
+#else
+#define UINTMAX_MAX (18446744073709551615ULL)
+#endif
+
+/* Limits of other integer types. */
+
+/* Limits of `ptrdiff_t' type. */
+#if defined (__SDCC_mcs51) || defined (__SDCC_ds390)
+#define PTRDIFF_MIN (-2147483647L-1)
+#define PTRDIFF_MAX (2147483647L)
+#else
+#define PTRDIFF_MIN (-32767-1)
+#define PTRDIFF_MAX (32767)
+#endif
+
+/* */
+#define SIG_ATOMIC_MIN (0)
+#define SIG_ATOMIC_MAX (255)
+
+/* Limit of `size_t' type. */
+#define SIZE_MAX (65535u)
+
+/* Signed. */
+#define INT8_C(c) c
+#define INT16_C(c) c
+#define INT32_C(c) c ## L
+#ifdef __SDCC_LONGLONG
+#define INT64_C(c) c ## LL
+#endif
+
+/* Unsigned. */
+#define UINT8_C(c) c ## U
+#define UINT16_C(c) c ## U
+#define UINT32_C(c) c ## UL
+#ifdef __SDCC_LONGLONG
+#define UINT64_C(c) c ## ULL
+#endif
+
+#define WCHAR_MIN 0
+#define WCHAR_MAX 0xffffffff
+
+#define WINT_MIN 0
+#define WINT_MAX 0xffffffff
+
+/* Maximal type. */
+#ifdef __SDCC_LONGLONG
+#define INTMAX_C(c) c ## LL
+#define UINTMAX_C(c) c ## ULL
+#else
+#define INTMAX_C(c) c ## L
+#define UINTMAX_C(c) c ## UL
+#endif
+
+/* Bounds-checking interfaces from annex K of the C11 standard. */
+#if defined (__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__
+#define RSIZE_MAX SIZE_MAX
+#endif
+
+#endif /* stdint.h */
+
diff --git a/gbdk/gbdk-lib/include/stdio.h b/gbdk/gbdk-lib/include/stdio.h
new file mode 100644
index 00000000..894c3f03
--- /dev/null
+++ b/gbdk/gbdk-lib/include/stdio.h
@@ -0,0 +1,70 @@
+/** @file stdio.h
+ Basic file/console input output functions.
+
+ Including stdio.h will use a large number of the
+ background tiles for font characters. If stdio.h
+ is not included then that space will be available
+ for use with other tiles instead.
+ */
+#ifndef STDIO_INCLUDE
+#define STDIO_INCLUDE
+
+#include <types.h>
+
+/** Print char to stdout.
+ @param c Character to print
+ */
+
+void putchar(char c) OLDCALL;
+
+/** Print the string and arguments given by format to stdout.
+
+ @param format The format string as per printf
+
+ Does not return the number of characters printed.
+
+ Currently supported:
+ \li \%hx (char as hex)
+ \li \%hu (unsigned char)
+ \li \%hd (signed char)
+ \li \%c (character)
+ \li \%u (unsigned int)
+ \li \%d (signed int)
+ \li \%x (unsigned int as hex)
+ \li \%s (string)
+
+ Warning: to correctly pass chars for printing as chars, they *must*
+ be explicitly re-cast as such when calling the function.
+ See @ref docs_chars_varargs for more details.
+ */
+void printf(const char *format, ...) OLDCALL;
+
+/** Print the string and arguments given by format to a buffer.
+
+ @param str The buffer to print into
+ @param format The format string as per @ref printf
+
+ Does not return the number of characters printed.
+ */
+void sprintf(char *str, const char *format, ...) OLDCALL;
+
+/** puts() writes the string __s__ and a trailing newline to stdout.
+*/
+void puts(const char *s);
+
+/** gets() Reads a line from stdin into a buffer pointed to by __s__.
+
+ @param s Buffer to store string in
+
+ Reads until either a terminating newline or an EOF, which it replaces with '\0'. No
+ check for buffer overrun is performed.
+
+ Returns: Buffer pointed to by __s__
+*/
+char *gets(char *s) OLDCALL;
+
+/** getchar() Reads and returns a single character from stdin.
+ */
+char getchar() OLDCALL;
+
+#endif
diff --git a/gbdk/gbdk-lib/include/stdlib.h b/gbdk/gbdk-lib/include/stdlib.h
new file mode 100644
index 00000000..eef0fe73
--- /dev/null
+++ b/gbdk/gbdk-lib/include/stdlib.h
@@ -0,0 +1,143 @@
+/** file stdlib.h
+ 'Standard library' functions, for whatever that means.
+*/
+#ifndef STDLIB_INCLUDE
+#define STDLIB_INCLUDE
+
+#include <types.h>
+
+#if !defined(__SDCC_mcs51) && !defined(__SDCC_ds390) && !defined(__SDCC_ds400) && !defined(__SDCC_hc08) && !defined(__SDCC_s08) && !defined(__SDCC_pic14) && !defined(__SDCC_pic16) && !defined(__SDCC_pdk13) && !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15)
+#define __reentrant
+#endif
+
+/** Causes normal program termination and the value of status is
+ returned to the parent.
+ All open streams are flushed and closed.
+*/
+void exit(int status) OLDCALL;
+
+#if 0
+/** Compatibility function. Not implemented.
+ */
+int getkey(void) OLDCALL;
+#endif
+
+/** Returns the absolute value of int __i__
+ @param i Int to obtain absolute value of
+
+ If i is negative, returns -i; else returns i.
+*/
+int abs(int i) OLDCALL;
+
+
+/** Returns the absolute value of long int __num__
+
+ @param num Long integer to obtain absolute value of
+ */
+long labs(long num) OLDCALL;
+
+
+/** Converts an ASCII string to an int
+
+ @param s String to convert to an int
+
+ The string may be of the format
+ \code{.c}
+ [\s]*[+-][\d]+[\D]*
+ \endcode
+ i.e. any number of spaces, an optional + or -, then an
+ arbitrary number of digits.
+
+ The result is undefined if the number doesnt fit in an int.
+
+ Returns: Int value of string
+ */
+int atoi(const char *s);
+
+
+/** Converts an ASCII string to a long.
+ @param s String to convert to an long int
+ @see atoi()
+
+ Returns: Long int value of string
+ */
+long atol(const char *s);
+
+/** Converts an int into a base 10 ASCII string.
+ @param n Int to convert to a string
+ @param s String to store the converted number
+ @param radix Numerical base for converted number, ex: 10 is decimal base
+ (parameter is required but not utilized on Game Boy and Analogue Pocket)
+
+ Returns: Pointer to converted string
+ */
+char *itoa(int n, char *s, unsigned char radix) OLDCALL;
+
+/** Converts an unsigned int into a base 10 ASCII string.
+ @param n Unsigned Int to convert to a string
+ @param s String to store the converted number
+ @param radix Numerical base for converted number, ex: 10 is decimal base
+ (parameter is required but not utilized on Game Boy and Analogue Pocket)
+
+ Returns: Pointer to converted string
+ */
+char *uitoa(unsigned int n, char *s, unsigned char radix) OLDCALL;
+
+/** Converts a long into a base 10 ASCII string.
+ @param n Long int to convert to a string
+ @param s String to store the converted number
+ @param radix Numerical base for converted number, ex: 10 is decimal base
+ (parameter is required but not utilized on Game Boy and Analogue Pocket)
+
+ Returns: Pointer to converted string
+ */
+char *ltoa(long n, char *s, unsigned char radix) OLDCALL;
+
+/** Converts an unsigned long into a base 10 ASCII string.
+ @param n Unsigned Long Int to convert to a string
+ @param s String to store the converted number
+ @param radix Numerical base for converted number, ex: 10 is decimal base
+ (parameter is required but not utilized on Game Boy and Analogue Pocket)
+
+ Returns: Pointer to converted string
+ */
+char *ultoa(unsigned long n, char *s, unsigned char radix) OLDCALL;
+
+
+/** Memory allocation functions
+ */
+void *calloc (size_t nmemb, size_t size);
+void *malloc (size_t size);
+void *realloc (void *ptr, size_t size);
+#if __STDC_VERSION__ >= 201112L
+inline void *aligned_alloc(size_t alignment, size_t size)
+{
+ (void)alignment;
+ return malloc(size);
+}
+#endif
+extern void free (void * ptr);
+
+/* Searching and sorting utilities (ISO C11 7.22.5) */
+/** search a sorted array of __nmemb__ items
+ @param key Pointer to object that is the key for the search
+ @param base Pointer to first object in the array to search
+ @param nmemb Number of elements in the array
+ @param size Size in bytes of each element in the array
+ @param compar Function used to compare two elements of the array
+
+ Returns: Pointer to array entry that matches the search key.
+ If key is not found, NULL is returned.
+*/
+extern void *bsearch(const void *key, const void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *) __reentrant);
+
+
+/** Sort an array of __nmemb__ items
+ @param base Pointer to first object in the array to sort
+ @param nmemb Number of elements in the array
+ @param size Size in bytes of each element in the array
+ @param compar Function used to compare and sort two elements of the array
+*/
+extern void qsort(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *) __reentrant);
+
+#endif
diff --git a/gbdk/gbdk-lib/include/stdnoreturn.h b/gbdk/gbdk-lib/include/stdnoreturn.h
new file mode 100644
index 00000000..992f9b96
--- /dev/null
+++ b/gbdk/gbdk-lib/include/stdnoreturn.h
@@ -0,0 +1,7 @@
+#ifndef __SDCC_STDNORETURN_H
+#define __SDCC_STDNORETURN_H 1
+
+#define noreturn _Noreturn
+
+#endif
+
diff --git a/gbdk/gbdk-lib/include/string.h b/gbdk/gbdk-lib/include/string.h
new file mode 100644
index 00000000..d79b5c17
--- /dev/null
+++ b/gbdk/gbdk-lib/include/string.h
@@ -0,0 +1,17 @@
+/** @file string.h
+ Generic string functions.
+ */
+#ifndef STD_STRING_INCLUDE
+#define STD_STRING_INCLUDE
+
+#ifdef __PORT_sm83
+ #include <asm/sm83/string.h>
+#else
+ #ifdef __PORT_z80
+ #include <asm/z80/string.h>
+ #else
+ #error Unrecognised port
+ #endif
+#endif
+
+#endif
diff --git a/gbdk/gbdk-lib/include/time.h b/gbdk/gbdk-lib/include/time.h
new file mode 100644
index 00000000..40e1a100
--- /dev/null
+++ b/gbdk/gbdk-lib/include/time.h
@@ -0,0 +1,38 @@
+/** @file time.h
+ Sort of ANSI compliant time functions.
+*/
+#ifndef TIME_INCLUDE
+#define TIME_INCLUDE
+
+#include <types.h>
+#include <stdint.h>
+
+#define CLOCKS_PER_SEC 60
+
+typedef uint16_t time_t;
+
+/** Returns an approximation of processor time used by the program in Clocks
+
+ The value returned is the CPU time (ticks) used so far as a @ref clock_t.
+
+ To get the number of seconds used, divide by @ref CLOCKS_PER_SEC.
+
+ This is based on @ref sys_time, which will wrap around every ~18 minutes.
+ (unsigned 16 bits = 65535 / 60 / 60 = 18.2)
+
+ @see sys_time, time()
+*/
+clock_t clock() OLDCALL;
+
+/** Converts clock() time to Seconds
+
+ @param t If pointer __t__ is not NULL, it's value will be set to the same seconds calculation as returned by the function.
+
+ The calculation is clock() / CLOCKS_PER_SEC
+
+ Returns: time in seconds
+ @see sys_time, clock()
+*/
+time_t time(time_t *t);
+
+#endif
diff --git a/gbdk/gbdk-lib/include/typeof.h b/gbdk/gbdk-lib/include/typeof.h
new file mode 100644
index 00000000..e1f6f97f
--- /dev/null
+++ b/gbdk/gbdk-lib/include/typeof.h
@@ -0,0 +1,54 @@
+/*-------------------------------------------------------------------------
+ typeof.h - Contains enumerations of values returned by __typeof
+
+ Copyright (C) 2001, Sandeep Dutta . sandeep.dutta@usa.net
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to the
+ Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+ As a special exception, if you link this library with other files,
+ some of which are compiled with SDCC, to produce an executable,
+ this library does not by itself cause the resulting executable to
+ be covered by the GNU General Public License. This exception does
+ not however invalidate any other reasons why the executable file
+ might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
+
+#ifndef __SDC51_TYPEOF_H
+#define __SDC51_TYPEOF_H 1
+
+#define TYPEOF_INT 1
+#define TYPEOF_SHORT 2
+#define TYPEOF_CHAR 3
+#define TYPEOF_LONG 4
+#define TYPEOF_FLOAT 5
+#define TYPEOF_FIXED16X16 6
+#define TYPEOF_BIT 7
+#define TYPEOF_BITFIELD 8
+#define TYPEOF_SBIT 9
+#define TYPEOF_SFR 10
+#define TYPEOF_VOID 11
+#define TYPEOF_STRUCT 12
+#define TYPEOF_ARRAY 13
+#define TYPEOF_FUNCTION 14
+#define TYPEOF_POINTER 15
+#define TYPEOF_FPOINTER 16
+#define TYPEOF_CPOINTER 17
+#define TYPEOF_GPOINTER 18
+#define TYPEOF_PPOINTER 19
+#define TYPEOF_IPOINTER 20
+#define TYPEOF_EEPPOINTER 21
+
+#endif
diff --git a/gbdk/gbdk-lib/include/types.h b/gbdk/gbdk-lib/include/types.h
new file mode 100644
index 00000000..3710bdf8
--- /dev/null
+++ b/gbdk/gbdk-lib/include/types.h
@@ -0,0 +1,25 @@
+/** @file types.h
+ Basic types.
+ Directly include the port specific file.
+*/
+#ifndef TYPES_INCLUDE
+#define TYPES_INCLUDE
+
+#include <asm/types.h>
+
+/** Good 'ol NULL.
+ */
+#define NULL 0
+
+/** A 'false' value.
+ */
+#define FALSE 0
+/** A 'true' value.
+ */
+#define TRUE 1
+
+/** No longer used.
+ */
+typedef void * POINTER;
+
+#endif
diff --git a/gbdk/gbdk-lib/libc/Makefile b/gbdk/gbdk-lib/libc/Makefile
new file mode 100644
index 00000000..d7ba3828
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/Makefile
@@ -0,0 +1,53 @@
+# Makefile for libc
+
+.EXPORT_ALL_VARIABLES:
+
+ifeq ($(PORTS),)
+ PORTS = sm83 z80
+endif
+
+ifeq ($(PLATFORMS),)
+ PLATFORMS = gb ap duck gg sms msxdos
+endif
+
+TOPDIR = ..
+
+CSRC = atoi.c atol.c isalpha.c isdigit.c \
+ islower.c isspace.c isupper.c \
+ sprintf.c printf.c puts.c scanf.c strcat.c string.c \
+ strncat.c strncmp.c strncpy.c time.c \
+ tolower.c toupper.c \
+ __assert.c \
+ _modulong.c _modslong.c _divulong.c _divslong.c _mullong.c \
+ bsearch.c qsort.c atomic_flag_clear.c \
+ free.c malloc.c realloc.c calloc.c
+
+include $(TOPDIR)/Makefile.common
+
+all: ports platforms
+
+clean: port-clean ports-clean platform-clean
+
+ports:
+ for i in $(PORTS); do make port THIS=$$i PORT=$$i; done
+
+platforms:
+ for j in $(PORTS); do for i in $(PLATFORMS); do if [ -d "targets/$$j/$$i" ]; then make -C targets/$$j/$$i platform THIS=$$i; fi done done
+
+# Make all the std libs
+# Make all the port specific libs
+
+# Uses the LIB <- OBJ rule from Makefile.rules
+port: port-clean $(LIB)
+ make -C asm/$(PORT) port
+
+port-clean:
+ rm -f $(LIBC_OBJ) $(CLEANSPEC)
+
+ports-clean:
+ for i in $(PORTS); do make -C asm/$$i clean THIS=$$i; done
+
+platform-clean:
+ for j in $(PORTS); do for i in $(PLATFORMS); do if [ -d "targets/$$j/$$i" ]; then make -C targets/$$j/$$i clean THIS=$$i; fi done done
+
+include Makefile.rules
diff --git a/gbdk/gbdk-lib/libc/Makefile.platform b/gbdk/gbdk-lib/libc/Makefile.platform
new file mode 100644
index 00000000..0f384ec5
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/Makefile.platform
@@ -0,0 +1,8 @@
+# Shared Makefile for all the platforms.
+# Provides a way of building the lib with little brains.
+
+all: platform
+
+platform: $(LIB)
+
+include $(TOPDIR)/libc/Makefile.rules
diff --git a/gbdk/gbdk-lib/libc/Makefile.rules b/gbdk/gbdk-lib/libc/Makefile.rules
new file mode 100644
index 00000000..160bc6eb
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/Makefile.rules
@@ -0,0 +1,19 @@
+ifeq ($(MODEL),small)
+NEAR_CALLS = 1
+else
+NEAR_CALLS = 0
+endif
+
+include $(TOPDIR)/libc/rules-$(ASM).mk
+
+clean:
+ rm -f $(OBJ) $(CLEANSPEC)
+
+set-model:
+ if [ -e global.s ]; then \
+ sed -e "s/.NEAR_CALLS\W=\W[0-9]\+/.NEAR_CALLS = $(NEAR_CALLS)/" global.s > tmp1.txt ;\
+ mv tmp1.txt global.s; \
+ fi
+
+build-dir:
+ mkdir -p $(BUILD)
diff --git a/gbdk/gbdk-lib/libc/__assert.c b/gbdk/gbdk-lib/libc/__assert.c
new file mode 100644
index 00000000..a4404513
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/__assert.c
@@ -0,0 +1,38 @@
+/*-------------------------------------------------------------------------
+ assert.c
+
+ Copyright (C) 2000, Michael Hope
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to the
+ Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+ As a special exception, if you link this library with other files,
+ some of which are compiled with SDCC, to produce an executable,
+ this library does not by itself cause the resulting executable to
+ be covered by the GNU General Public License. This exception does
+ not however invalidate any other reasons why the executable file
+ might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
+
+#include <stdio.h>
+#include <stdlib.h>
+
+void __assert(const char *expression, const char *functionname, const char *filename, unsigned int linenumber)
+{
+ printf("Assert(%s) failed in function %s at line %u in file %s.\n",
+ expression, functionname, linenumber, filename);
+ for(;;);
+}
+
diff --git a/gbdk/gbdk-lib/libc/_divslong.c b/gbdk/gbdk-lib/libc/_divslong.c
new file mode 100644
index 00000000..ed2ab573
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/_divslong.c
@@ -0,0 +1,35 @@
+/*-------------------------------------------------------------------------
+ _divslong.c - routine for division of 32 bit long
+
+ Copyright (C) 1999, Sandeep Dutta . sandeep.dutta@usa.net
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to the
+ Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+ As a special exception, if you link this library with other files,
+ some of which are compiled with SDCC, to produce an executable,
+ this library does not by itself cause the resulting executable to
+ be covered by the GNU General Public License. This exception does
+ not however invalidate any other reasons why the executable file
+ might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
+
+unsigned long _divulong (unsigned long a, unsigned long b);
+
+long _divslong (long a, long b) {
+ long r;
+ r = _divulong((a < 0 ? -a : a), (b < 0 ? -b : b));
+ return ((a < 0) ^ (b < 0)) ? -r : r;
+}
diff --git a/gbdk/gbdk-lib/libc/_divulong.c b/gbdk/gbdk-lib/libc/_divulong.c
new file mode 100644
index 00000000..f98eb857
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/_divulong.c
@@ -0,0 +1,351 @@
+/*-------------------------------------------------------------------------
+ _divulong.c - routine for division of 32 bit unsigned long
+
+ Ecrit par - Jean-Louis Vern . jlvern@writeme.com (1999)
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ In other words, you are welcome to use, share and improve this program.
+ You are forbidden to forbid anyone else to use, share and improve
+ what you give them. Help stamp out software-hoarding!
+-------------------------------------------------------------------------*/
+
+/* Assembler-functions are provided for:
+ mcs51 small
+ mcs51 small stack-auto
+*/
+
+#if !defined(SDCC_USE_XSTACK) && !defined(_SDCC_NO_ASM_LIB_FUNCS)
+# if defined(SDCC_mcs51)
+# if defined(SDCC_MODEL_SMALL)
+# if defined(SDCC_STACK_AUTO)
+# define _DIVULONG_ASM_SMALL_AUTO
+# else
+# define _DIVULONG_ASM_SMALL
+# endif
+# endif
+# endif
+#endif
+
+#if defined _DIVULONG_ASM_SMALL
+
+static void
+_divlong_dummy (void) _naked
+{
+ _asm
+
+ .globl __divulong
+
+ __divulong:
+
+ #define count r2
+
+ #define a0 dpl
+ #define a1 dph
+ #define a2 b
+ #define a3 r3
+
+ #define reste0 r4
+ #define reste1 r5
+ #define reste2 r6
+ #define reste3 r7
+
+#if defined(SDCC_NOOVERLAY)
+ .area DSEG (DATA)
+#else
+ .area OSEG (OVR,DATA)
+#endif
+
+ .globl __divulong_PARM_2
+ .globl __divslong_PARM_2
+
+ __divulong_PARM_2:
+ __divslong_PARM_2:
+ .ds 4
+
+ .area CSEG (CODE)
+
+ #define b0 (__divulong_PARM_2)
+ #define b1 (__divulong_PARM_2 + 1)
+ #define b2 (__divulong_PARM_2 + 2)
+ #define b3 (__divulong_PARM_2 + 3)
+
+ ; parameter a comes in a, b, dph, dpl
+ mov a3,a ; save parameter a3
+
+ mov count,#32
+ clr a
+ mov reste0,a
+ mov reste1,a
+ mov reste2,a
+ mov reste3,a
+
+ ; optimization loop in lp0 until the first bit is shifted into rest
+
+ lp0: mov a,a0 ; a <<= 1
+ add a,a0
+ mov a0,a
+ mov a,a1
+ rlc a
+ mov a1,a
+ mov a,a2
+ rlc a
+ mov a2,a
+ mov a,a3
+ rlc a
+ mov a3,a
+
+ jc in_lp
+ djnz count,lp0
+
+ sjmp exit
+
+ loop: mov a,a0 ; a <<= 1
+ add a,a0
+ mov a0,a
+ mov a,a1
+ rlc a
+ mov a1,a
+ mov a,a2
+ rlc a
+ mov a2,a
+ mov a,a3
+ rlc a
+ mov a3,a
+
+ in_lp: mov a,reste0 ; reste <<= 1
+ rlc a ; feed in carry
+ mov reste0,a
+ mov a,reste1
+ rlc a
+ mov reste1,a
+ mov a,reste2
+ rlc a
+ mov reste2,a
+ mov a,reste3
+ rlc a
+ mov reste3,a
+
+ mov a,reste0 ; reste - b
+ subb a,b0 ; carry is always clear here, because
+ ; reste <<= 1 never overflows
+ mov a,reste1
+ subb a,b1
+ mov a,reste2
+ subb a,b2
+ mov a,reste3
+ subb a,b3
+
+ jc minus ; reste >= b?
+
+ ; -> yes; reste -= b;
+ mov a,reste0
+ subb a,b0 ; carry is always clear here (jc)
+ mov reste0,a
+ mov a,reste1
+ subb a,b1
+ mov reste1,a
+ mov a,reste2
+ subb a,b2
+ mov reste2,a
+ mov a,reste3
+ subb a,b3
+ mov reste3,a
+
+ orl a0,#1
+
+ minus: djnz count,loop ; -> no
+
+ exit: mov a,a3 ; prepare the return value
+ ret
+
+ _endasm ;
+}
+
+#elif defined _DIVULONG_ASM_SMALL_AUTO
+
+static void
+_divlong_dummy (void) _naked
+{
+ _asm
+
+ .globl __divulong
+
+ __divulong:
+
+ #define count r2
+
+ #define a0 dpl
+ #define a1 dph
+ #define a2 b
+ #define a3 r3
+
+ #define reste0 r4
+ #define reste1 r5
+ #define reste2 r6
+ #define reste3 r7
+
+ .globl __divlong ; entry point for __divslong
+
+ #define b0 r1
+
+ ar0 = 0 ; BUG register set is not considered
+ ar1 = 1
+
+ ; parameter a comes in a, b, dph, dpl
+ mov a3,a ; save parameter a3
+
+ mov a,sp
+ add a,#-2-3 ; 2 bytes return address, 3 bytes param b
+ mov r0,a ; r0 points to b0
+
+ __divlong: ; entry point for __divslong
+
+ mov ar1,@r0 ; load b0
+ inc r0 ; r0 points to b1
+
+ mov count,#32
+ clr a
+ mov reste0,a
+ mov reste1,a
+ mov reste2,a
+ mov reste3,a
+
+ ; optimization loop in lp0 until the first bit is shifted into rest
+
+ lp0: mov a,a0 ; a <<= 1
+ add a,a0
+ mov a0,a
+ mov a,a1
+ rlc a
+ mov a1,a
+ mov a,a2
+ rlc a
+ mov a2,a
+ mov a,a3
+ rlc a
+ mov a3,a
+
+ jc in_lp
+ djnz count,lp0
+
+ sjmp exit
+
+ loop: mov a,a0 ; a <<= 1
+ add a,a0
+ mov a0,a
+ mov a,a1
+ rlc a
+ mov a1,a
+ mov a,a2
+ rlc a
+ mov a2,a
+ mov a,a3
+ rlc a
+ mov a3,a
+
+ in_lp: mov a,reste0 ; reste <<= 1
+ rlc a ; feed in carry
+ mov reste0,a
+ mov a,reste1
+ rlc a
+ mov reste1,a
+ mov a,reste2
+ rlc a
+ mov reste2,a
+ mov a,reste3
+ rlc a
+ mov reste3,a
+
+ mov a,reste0 ; reste - b
+ subb a,b0 ; carry is always clear here, because
+ ; reste <<= 1 never overflows
+ mov a,reste1
+ subb a,@r0 ; b1
+ mov a,reste2
+ inc r0
+ subb a,@r0 ; b2
+ mov a,reste3
+ inc r0
+ subb a,@r0 ; b3
+ dec r0
+ dec r0
+
+ jc minus ; reste >= b?
+
+ ; -> yes; reste -= b;
+ mov a,reste0
+ subb a,b0 ; carry is always clear here (jc)
+ mov reste0,a
+ mov a,reste1
+ subb a,@r0 ; b1
+ mov reste1,a
+ mov a,reste2
+ inc r0
+ subb a,@r0 ; b2
+ mov reste2,a
+ mov a,reste3
+ inc r0
+ subb a,@r0 ; b3
+ mov reste3,a
+ dec r0
+ dec r0
+
+ orl a0,#1
+
+ minus: djnz count,loop ; -> no
+
+ exit: mov a,a3 ; prepare the return value
+ ret
+
+ _endasm ;
+}
+
+#else // _DIVULONG_ASM
+
+#define MSB_SET(x) ((x >> (8*sizeof(x)-1)) & 1)
+
+unsigned long
+_divulong (unsigned long a, unsigned long b)
+{
+ unsigned long reste = 0L;
+ unsigned char count = 32;
+ #if defined(__SDCC_STACK_AUTO) || defined(__SDCC_z80) || defined(__SDCC_sm83)
+ char c;
+ #else
+ bit c;
+ #endif
+
+ do
+ {
+ // reste: a <- 0;
+ c = MSB_SET(a);
+ a <<= 1;
+ reste <<= 1;
+ if (c)
+ reste |= 1L;
+
+ if (reste >= b)
+ {
+ reste -= b;
+ // a <- (result = 1)
+ a |= 1L;
+ }
+ }
+ while (--count);
+ return a;
+}
+
+#endif // _DIVULONG_ASM
diff --git a/gbdk/gbdk-lib/libc/_modslong.c b/gbdk/gbdk-lib/libc/_modslong.c
new file mode 100644
index 00000000..ad75c0ad
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/_modslong.c
@@ -0,0 +1,35 @@
+/*-------------------------------------------------------------------------
+ _modslong.c - routine for modulus of 32 bit signed long
+
+ Copyright (C) 1999, Sandeep Dutta . sandeep.dutta@usa.net
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to the
+ Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+ As a special exception, if you link this library with other files,
+ some of which are compiled with SDCC, to produce an executable,
+ this library does not by itself cause the resulting executable to
+ be covered by the GNU General Public License. This exception does
+ not however invalidate any other reasons why the executable file
+ might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
+
+unsigned long _modulong (unsigned long a, unsigned long b);
+
+long _modslong (long a, long b) {
+ long r;
+ r = _modulong((a < 0 ? -a : a), (b < 0 ? -b : b));
+ return ( (a < 0) ^ (b < 0)) ? -r : r;
+}
diff --git a/gbdk/gbdk-lib/libc/_modulong.c b/gbdk/gbdk-lib/libc/_modulong.c
new file mode 100644
index 00000000..360e4d63
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/_modulong.c
@@ -0,0 +1,55 @@
+/*-------------------------------------------------------------------------
+ _modulong.c - routine for modulus of 32 bit unsigned long
+
+ Copyright (C) 1999, Sandeep Dutta . sandeep.dutta@usa.net
+ Bug fixes by Martijn van Balen, aed@iae.nl
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to the
+ Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+ As a special exception, if you link this library with other files,
+ some of which are compiled with SDCC, to produce an executable,
+ this library does not by itself cause the resulting executable to
+ be covered by the GNU General Public License. This exception does
+ not however invalidate any other reasons why the executable file
+ might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
+
+#define MSB_SET(x) ((x >> (8*sizeof(x)-1)) & 1)
+
+unsigned long _modulong (unsigned long a, unsigned long b)
+{
+ unsigned char count = 0;
+
+ while (!MSB_SET(b))
+ {
+ b <<= 1;
+ if (b > a)
+ {
+ b >>=1;
+ break;
+ }
+ count++;
+ }
+ do
+ {
+ if (a >= b)
+ a -= b;
+ b >>= 1;
+ }
+ while (count--);
+
+ return a;
+}
diff --git a/gbdk/gbdk-lib/libc/_mullong.c b/gbdk/gbdk-lib/libc/_mullong.c
new file mode 100644
index 00000000..41181587
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/_mullong.c
@@ -0,0 +1,91 @@
+/*-------------------------------------------------------------------------
+ _mullong.c - routine for multiplication of 32 bit (unsigned) long
+
+ Copyright (C) 1999, Sandeep Dutta . sandeep.dutta@usa.net
+ Copyright (C) 1999, Jean Louis VERN jlvern@writeme.com
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to the
+ Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+ As a special exception, if you link this library with other files,
+ some of which are compiled with SDCC, to produce an executable,
+ this library does not by itself cause the resulting executable to
+ be covered by the GNU General Public License. This exception does
+ not however invalidate any other reasons why the executable file
+ might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
+
+
+struct some_struct {
+ short a ;
+ char b;
+ long c ;};
+union bil {
+ struct {unsigned char b0,b1,b2,b3 ;} b;
+ struct {unsigned short lo,hi ;} i;
+ unsigned long l;
+ struct { unsigned char b0; unsigned short i12; unsigned char b3;} bi;
+} ;
+
+#define bcast(x) ((union bil *)&(x))
+
+/*
+ 3 2 1 0
+ X 3 2 1 0
+ ----------------------------
+ 0.3 0.2 0.1 0.0
+ 1.3 1.2 1.1 1.0
+ 2.3 2.2 2.1 2.0
+ 3.3 3.2 3.1 3.0
+ ----------------------------
+ |3.3|1.3|0.2|0.0| A
+ |2.3|0.3|0.1| B
+ |3.2|1.2|1.0| C
+ |2.2|1.1| D
+ |3.1|2.0| E
+ |2.1| F
+ |3.0| G
+ |-------> only this side 32 x 32 -> 32
+*/
+
+/* 32x32->32 multiplication to be used
+ if 16x16->16 is faster than three 8x8->16.
+ 2009, by M.Bodrato ( http://bodrato.it/ )
+
+ z80 and sm83 don't have any hardware multiplication.
+ r2k and r3k have 16x16 hardware multiplication.
+ */
+long _mullong (long a, long b)
+{
+ unsigned short i12;
+
+ bcast(a)->i.hi *= bcast(b)->i.lo;
+ bcast(a)->i.hi += bcast(b)->i.hi * bcast(a)->i.lo;
+
+ /* only (a->i.lo * b->i.lo) 16x16->32 to do. asm? */
+ bcast(a)->i.hi += bcast(a)->b.b1 * bcast(b)->b.b1;
+
+ i12 = bcast(b)->b.b0 * bcast(a)->b.b1;
+ bcast(b)->bi.i12 = bcast(a)->b.b0 * bcast(b)->b.b1;
+
+ /* add up the two partial result, store carry in b3 */
+ bcast(b)->b.b3 = ((bcast(b)->bi.i12 += i12) < i12);
+
+ bcast(a)->i.lo = bcast(a)->b.b0 * bcast(b)->b.b0;
+
+ bcast(b)->bi.b0 = 0;
+
+ return a + b;
+}
diff --git a/gbdk/gbdk-lib/libc/asm/Makefile.port b/gbdk/gbdk-lib/libc/asm/Makefile.port
new file mode 100644
index 00000000..355e2f96
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/asm/Makefile.port
@@ -0,0 +1,11 @@
+# Shared Makefile for all the ports.
+# Provides a way of building the lib with little brains.
+
+LIB_APPEND = 1
+
+all: port
+
+include $(TOPDIR)/libc/Makefile.rules
+
+port: $(LIB)
+
diff --git a/gbdk/gbdk-lib/libc/asm/sm83/Makefile b/gbdk/gbdk-lib/libc/asm/sm83/Makefile
new file mode 100644
index 00000000..3506a104
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/asm/sm83/Makefile
@@ -0,0 +1,22 @@
+# sm83 specific Makefile
+
+TOPDIR = ../../..
+
+THIS = sm83
+
+ASSRC = __sdcc_call_hl.s abs.s mul.s div.s shift.s crt0_rle.s \
+ itoa.s strlen.s reverse.s labs.s ltoa.s \
+ setjmp.s atomic_flag_test_and_set.s \
+ memcpy.s _memset.s _strcmp.s _strcpy.s _memcmp.s \
+ rand.s arand.s \
+ bcd.s
+
+CSRC = _memmove.c
+
+include $(TOPDIR)/Makefile.common
+
+AS = $(AS_SM83)
+
+include ../Makefile.port
+
+
diff --git a/gbdk/gbdk-lib/libc/asm/sm83/__sdcc_call_hl.s b/gbdk/gbdk-lib/libc/asm/sm83/__sdcc_call_hl.s
new file mode 100644
index 00000000..d8686b29
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/asm/sm83/__sdcc_call_hl.s
@@ -0,0 +1,38 @@
+;--------------------------------------------------------------------------
+; crtcall.s
+;
+; Copyright (C) 2011, Maarten Brock
+;
+; This library is free software; you can redistribute it and/or modify it
+; under the terms of the GNU General Public License as published by the
+; Free Software Foundation; either version 2, or (at your option) any
+; later version.
+;
+; This library is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this library; see the file COPYING. If not, write to the
+; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+; MA 02110-1301, USA.
+;
+; As a special exception, if you link this library with other files,
+; some of which are compiled with SDCC, to produce an executable,
+; this library does not by itself cause the resulting executable to
+; be covered by the GNU General Public License. This exception does
+; not however invalidate any other reasons why the executable file
+; might be covered by the GNU General Public License.
+;--------------------------------------------------------------------------
+
+ .module call_hl
+
+ .area _HOME
+
+ .globl ___sdcc_call_hl
+
+; The Z80 has the jp (hl) instruction, which is perfect for implementing function pointers.
+
+___sdcc_call_hl:
+ jp (hl)
diff --git a/gbdk/gbdk-lib/libc/asm/sm83/_memcmp.s b/gbdk/gbdk-lib/libc/asm/sm83/_memcmp.s
new file mode 100644
index 00000000..40c76fc1
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/asm/sm83/_memcmp.s
@@ -0,0 +1,45 @@
+ .module strcmp
+
+ .area _HOME
+
+; int memcmp(const void *buf1, const void *buf2, size_t count)
+_memcmp::
+ lda hl,7(sp)
+ ld a,(hl-)
+ ld b, a
+ ld a,(hl-)
+ ld c, a
+ ld a,(hl-)
+ ld d, a
+ ld a,(hl-)
+ ld e, a
+ ld a,(hl-)
+ ld l,(hl)
+ ld h,a
+
+ inc b
+ inc c
+ jr 3$
+
+1$:
+ ld a,(de)
+ sub (hl) ; s1[i]==s2[i]?
+ jr nz, 2$ ; -> Different
+
+ inc de
+ inc hl
+3$:
+ dec c
+ jr nz, 1$
+ dec b
+ jr nz, 1$
+
+ ld de, #0
+ ret
+
+2$:
+ ld de,#1
+ ret c
+
+ ld de,#-1
+ ret \ No newline at end of file
diff --git a/gbdk/gbdk-lib/libc/asm/sm83/_memmove.c b/gbdk/gbdk-lib/libc/asm/sm83/_memmove.c
new file mode 100644
index 00000000..f30be660
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/asm/sm83/_memmove.c
@@ -0,0 +1,54 @@
+/*-------------------------------------------------------------------------
+ _memmove.c - part of string library functions
+
+ Copyright (C) 1999, Sandeep Dutta . sandeep.dutta@usa.net
+ Adapted By - Erik Petrich . epetrich@users.sourceforge.net
+ from _memcpy.c which was originally
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to the
+ Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+ As a special exception, if you link this library with other files,
+ some of which are compiled with SDCC, to produce an executable,
+ this library does not by itself cause the resulting executable to
+ be covered by the GNU General Public License. This exception does
+ not however invalidate any other reasons why the executable file
+ might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
+#include <string.h>
+#include <stdint.h>
+
+void *memmove (void *dst, const void *src, size_t size)
+{
+ size_t c = size;
+ if (c == 0)
+ return dst;
+
+ char *d = dst;
+ const char *s = src;
+ if (s < d) {
+ d += c;
+ s += c;
+ do {
+ *--d = *--s;
+ } while (--c);
+ } else {
+ do {
+ *d++ = *s++;
+ } while (--c);
+ }
+
+ return dst;
+}
diff --git a/gbdk/gbdk-lib/libc/asm/sm83/_memset.s b/gbdk/gbdk-lib/libc/asm/sm83/_memset.s
new file mode 100644
index 00000000..9b9f4387
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/asm/sm83/_memset.s
@@ -0,0 +1,52 @@
+ .module memset
+
+ .area _HOME
+
+; void *memset (void *s, int c, size_t n)
+_memset::
+ lda hl,7(sp)
+ ld a,(hl-)
+ ld d, a
+ ld a,(hl-)
+ ld e, a
+ or d
+ jr z,6$
+
+ dec hl
+ ld a,(hl-)
+ push af
+ ld a,(hl-)
+ ld l,(hl)
+ ld h,a
+ pop af
+
+ srl d
+ rr e
+ jr nc,4$
+ ld (hl+),a
+4$:
+ srl d
+ rr e
+ jr nc,5$
+ ld (hl+),a
+ ld (hl+),a
+5$:
+ inc d
+ inc e
+ jr 2$
+1$:
+ ld (hl+),a
+ ld (hl+),a
+ ld (hl+),a
+ ld (hl+),a
+2$:
+ dec e
+ jr nz,1$
+ dec d
+ jr nz,1$
+6$:
+ lda hl,2(sp)
+ ld a,(hl+)
+ ld e,a
+ ld d,(hl)
+ ret
diff --git a/gbdk/gbdk-lib/libc/asm/sm83/_strcmp.s b/gbdk/gbdk-lib/libc/asm/sm83/_strcmp.s
new file mode 100644
index 00000000..5725b168
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/asm/sm83/_strcmp.s
@@ -0,0 +1,35 @@
+ .module strcmp
+
+ .area _HOME
+
+; int strcmp(const char *s1, const char *s2)
+_strcmp::
+ lda hl,2(sp)
+ ld a,(hl+)
+ ld e, a
+ ld a,(hl+)
+ ld d, a
+ ld a,(hl+)
+ ld h,(hl)
+ ld l,a
+1$:
+ ld a,(de)
+ sub (hl) ; s1[i]==s2[i]?
+ jr nz, 2$ ; -> Different
+ ;; A == 0
+ cp (hl) ; s1[i]==s2[i]==0?
+
+ inc de
+ inc hl
+ jr nz, 1$ ; ^ Didn't reach a null character. Loop.
+
+ ; Yes. return 0;
+ ld d, a ; Since a == 0 this is faster than a 16 bit immediate load.
+ ld e, a
+ ret
+2$:
+ ld de,#-1
+ ret c
+
+ ld de,#1
+ ret \ No newline at end of file
diff --git a/gbdk/gbdk-lib/libc/asm/sm83/_strcpy.s b/gbdk/gbdk-lib/libc/asm/sm83/_strcpy.s
new file mode 100644
index 00000000..748a0e5e
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/asm/sm83/_strcpy.s
@@ -0,0 +1,26 @@
+ .module strcpy
+
+ .area _HOME
+
+; char *strcpy(char *dest, const char *source)
+_strcpy::
+ lda hl,2(sp)
+ ld a,(hl+)
+ ld e, a
+ ld a,(hl+)
+ ld d, a
+ ld a,(hl+)
+ ld h,(hl)
+ ld l,a
+
+ push de
+1$:
+ ld a,(hl+)
+ ld (de),a
+ inc de
+ or a,a
+ jr nz,1$
+
+ pop de
+ ret
+ \ No newline at end of file
diff --git a/gbdk/gbdk-lib/libc/asm/sm83/abs.s b/gbdk/gbdk-lib/libc/asm/sm83/abs.s
new file mode 100644
index 00000000..da139bdf
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/asm/sm83/abs.s
@@ -0,0 +1,19 @@
+ .module abs
+
+ .area _HOME
+
+; int abs(int)
+_abs::
+ lda HL, 3(SP) ; 3
+ ld A,(HL-) ; 2 Load high byte.
+ ld D,A ; 1
+ ld E,(HL) ; 2 Load low byte
+ add A,A ; 1 Sign check.
+ ret nc ; 5/2 Return if positive.
+ xor A ; 1 A=0.
+ sub E ; 1 Calculate 0-(low byte).
+ ld E,A ; 1
+ ld A,#0 ; 2 A=0. Can't use xor A because carry flag needs to be preserved.
+ sbc D ; 1 Calculate 0-(high byte)-carry.
+ ld D,A ; 1
+ ret ; 4
diff --git a/gbdk/gbdk-lib/libc/asm/sm83/arand.s b/gbdk/gbdk-lib/libc/asm/sm83/arand.s
new file mode 100644
index 00000000..34dfd3d5
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/asm/sm83/arand.s
@@ -0,0 +1,116 @@
+;/***************************************************************************
+; * *
+; * Module : arand.s *
+; * *
+; * Purpose : A random number generator using the lagged additive method *
+; * *
+; * Version : 1, January 11 1998 *
+; * *
+; * Author : Luc Van den Borre ( Homepage : NOC.BASE.ORG ) *
+; * *
+; **************************************************************************/
+
+ .globl .initrand
+ .globl _rand
+
+ .area _DATA
+
+.randarr:
+ .ds 55
+.raxj:
+ .ds 0x01
+.raxk:
+ .ds 0x01
+
+ .area _CODE
+
+ ;; arand() operates on an array of 55 arbitrary values (here : bytes).
+ ;; It adds two values of the array together, replaces one of the values
+ ;; with the result, and returns the result.
+ ;; At start, the indices into the array refer to the 55th and 24th element.
+ ;; After each call, each index is decreased, and looped around if necessary.
+ ;; This kind of works, but the values produces are less good than those by
+ ;; rand(), mainly because it operates on bytes instead of words.
+ ;; Ref : D. E. Knuth, "The Art of Computer Programming" , Volume 2
+ ;;
+ ;; Exit conditions
+ ;; DE = Random number (byte!)
+ ;;
+ ;; Registers used:
+ ;; all
+ ;;
+_arand:: ; Banked
+ PUSH BC
+ LD D,#0
+ LD HL,#.randarr-1
+ LD A,(.raxj)
+ LD E,A
+ DEC A ; Decrease the pointer
+ JR NZ,1$
+ LD A,#55
+1$:
+ LD (.raxj),A
+ ADD HL,DE
+ LD B,(HL)
+
+ LD HL,#.randarr-1 ; Ooh...
+ LD A,(.raxk)
+ LD E,A
+ DEC A ; Decrease the pointer
+ JR NZ,2$
+ LD A,#55
+2$:
+ LD (.raxk),A
+ ADD HL,DE
+ LD A,(HL)
+
+ ADD B
+ LD (HL),A ; Store new value
+
+ POP BC
+
+ LD D,#0
+ LD E,A
+
+ RET
+
+ ;; _initarand calls the _rand function to fill the array with random values
+ ;; Note that this also sets the seed value of the _rand function first,
+ ;; like _initrand
+ ;;
+ ;; Exit conditions
+ ;; None
+ ;;
+ ;; Registers used:
+ ;; all
+ ;;
+_initarand:: ; Banked
+ LDA HL,2(SP)
+ CALL .initrand
+
+ PUSH BC
+ LD A,#55
+ LD HL,#.randarr
+1$:
+ DEC A
+ LD (.raxj),A
+ LD B,H
+ LD C,L
+ CALL _rand
+ LD H,B
+ LD L,C
+
+ LD A, E
+ LD (HL+),A
+
+ LD A,(.raxj)
+ CP #0
+ JR NZ,1$
+
+ LD A,#24 ; Now the array has been filled,set the pointers
+ LD (.raxj),A
+ LD A,#55
+ LD (.raxk),A
+
+ POP BC
+ RET
diff --git a/gbdk/gbdk-lib/libc/asm/sm83/atomic_flag_test_and_set.s b/gbdk/gbdk-lib/libc/asm/sm83/atomic_flag_test_and_set.s
new file mode 100644
index 00000000..f1a09726
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/asm/sm83/atomic_flag_test_and_set.s
@@ -0,0 +1,46 @@
+;--------------------------------------------------------------------------
+; atomic_flag_test_and_set.s
+;
+; Copyright (C) 2020, Philipp Klaus Krause
+;
+; This library is free software; you can redistribute it and/or modify it
+; under the terms of the GNU General Public License as published by the
+; Free Software Foundation; either version 2, or (at your option) any
+; later version.
+;
+; This library is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this library; see the file COPYING. If not, write to the
+; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+; MA 02110-1301, USA.
+;
+; As a special exception, if you link this library with other files,
+; some of which are compiled with SDCC, to produce an executable,
+; this library does not by itself cause the resulting executable to
+; be covered by the GNU General Public License. This exception does
+; not however invalidate any other reasons why the executable file
+; might be covered by the GNU General Public License.
+;--------------------------------------------------------------------------
+
+ .module atomic
+
+ .area _HOME
+
+ .globl _atomic_flag_test_and_set
+
+_atomic_flag_test_and_set:
+ pop de
+ pop hl
+ push hl
+ push de
+ xor a, a
+ srl (hl)
+ ccf
+ rla
+ ld e, a
+ ret
+
diff --git a/gbdk/gbdk-lib/libc/asm/sm83/bcd.s b/gbdk/gbdk-lib/libc/asm/sm83/bcd.s
new file mode 100644
index 00000000..238dd1b2
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/asm/sm83/bcd.s
@@ -0,0 +1,233 @@
+;--------------------------------------------------------------------------
+; bcd.s
+;
+; Copyright (C) 2020, Tony Pavlov
+;
+; This library is free software; you can redistribute it and/or modify it
+; under the terms of the GNU General Public License as published by the
+; Free Software Foundation; either version 2, or (at your option) any
+; later version.
+;
+; This library is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this library; see the file COPYING. If not, write to the
+; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+; MA 02110-1301, USA.
+;
+; As a special exception, if you link this library with other files,
+; some of which are compiled with SDCC, to produce an executable,
+; this library does not by itself cause the resulting executable to
+; be covered by the GNU General Public License. This exception does
+; not however invalidate any other reasons why the executable file
+; might be covered by the GNU General Public License.
+;--------------------------------------------------------------------------
+
+ .module bcd
+
+ .area _HOME
+
+; void uint2bcd(uint16_t i, BCD * value) __naked
+_uint2bcd::
+ lda HL, 2(SP)
+ ld A, (HL+) ; DE: uint
+ ld E, A
+ ld A, (HL+)
+ ld D, A
+ ld A, (HL+)
+ ld H, (HL)
+ ld L, A ; HL: dest
+
+ push BC
+
+ ; clear value
+ xor A
+ ld BC, #-4
+
+ ld (HL+), A
+ ld (HL+), A
+ ld (HL+), A
+ ld (HL+), A
+ add HL, BC
+
+ ld B, #16
+1$:
+ sla E
+ rl D
+
+ ld A, (HL)
+ adc A
+ daa
+ ld (HL+), A
+ ld A, (HL)
+ adc A
+ daa
+ ld (HL+), A
+ ld A, (HL)
+ adc A
+ daa
+ ld (HL-), A
+
+ dec HL
+
+ dec B
+ jr NZ, 1$
+
+ pop BC
+ ret
+
+;void bcd_add(BCD * sour, BCD * value) __naked
+_bcd_add::
+ lda HL, 5(SP)
+ ld D, (HL)
+ dec HL
+ ld E, (HL) ; DE: value
+ dec HL
+ ld A, (HL-)
+ ld L, (HL)
+ ld H, A ; HL: sour
+
+ or A ; clear C, HC
+
+ ld A,(DE)
+ add (HL)
+ daa
+ ld (HL+), A
+ inc DE
+
+ ld A,(DE)
+ adc (HL)
+ daa
+ ld (HL+), A
+ inc DE
+
+ ld A,(DE)
+ adc (HL)
+ daa
+ ld (HL+), A
+ inc DE
+
+ ld A,(DE)
+ adc (HL)
+ daa
+ ld (HL+), A
+
+ ret
+
+; void bcd_sub(BCD * sour, BCD * value) __naked
+_bcd_sub::
+ lda HL, 2(SP)
+ ld E, (HL)
+ inc HL
+ ld D, (HL) ; DE: sour
+ inc HL
+ ld A, (HL+)
+ ld H, (HL)
+ ld L, A ; HL: value
+
+ or A ; clear C, HC
+
+ ld A,(DE)
+ sub (HL)
+ daa
+ ld (DE), A
+ inc DE
+ inc HL
+
+ ld A,(DE)
+ sbc (HL)
+ daa
+ ld (DE), A
+ inc DE
+ inc HL
+
+ ld A,(DE)
+ sbc (HL)
+ daa
+ ld (DE), A
+ inc DE
+ inc HL
+
+ ld A,(DE)
+ sbc (HL)
+ daa
+ ld (DE), A
+
+ ret
+
+;uint8_t bcd2text(BCD * bcd, uint8_t tile_offset, uint8_t * buffer) __naked
+_bcd2text::
+ push BC
+
+ lda HL, 4(SP)
+ ld E, (HL)
+ inc HL
+ ld D, (HL) ; DE: bcd
+ inc HL
+ ld C, (HL) ; C: digit offset
+ inc HL
+ ld A, (HL+)
+ ld H, (HL)
+ ld L, A ; HL: buffer
+
+ inc DE
+ inc DE
+ inc DE
+
+ ld B, #0x0f
+
+ ld A, (DE)
+ swap A
+ and B
+ add C
+ ld (HL+), A
+ ld A, (DE)
+ and B
+ add C
+ ld (HL+), A
+ dec DE
+
+ ld A, (DE)
+ swap A
+ and B
+ add C
+ ld (HL+), A
+ ld A, (DE)
+ and B
+ add C
+ ld (HL+), A
+ dec DE
+
+ ld A, (DE)
+ swap A
+ and B
+ add C
+ ld (HL+), A
+ ld A, (DE)
+ and B
+ add C
+ ld (HL+), A
+ dec DE
+
+ ld A, (DE)
+ swap A
+ and B
+ add C
+ ld (HL+), A
+ ld A, (DE)
+ and B
+ add C
+ ld (HL+), A
+ dec DE
+
+ xor A
+ ld (HL+), A
+
+ ld D, A
+ ld E, #0x08
+
+ pop BC
+ ret
diff --git a/gbdk/gbdk-lib/libc/asm/sm83/crt0_rle.s b/gbdk/gbdk-lib/libc/asm/sm83/crt0_rle.s
new file mode 100644
index 00000000..e3bdabcb
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/asm/sm83/crt0_rle.s
@@ -0,0 +1,69 @@
+;--------------------------------------------------------------------------
+; __initrleblock.s
+;
+; Copyright (C) 2001, Michael Hope
+; Copyright (C) 2020, Sergey Belyashov
+;
+; This library is free software; you can redistribute it and/or modify it
+; under the terms of the GNU General Public License as published by the
+; Free Software Foundation; either version 2, or (at your option) any
+; later version.
+;
+; This library is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this library; see the file COPYING. If not, write to the
+; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+; MA 02110-1301, USA.
+;
+; As a special exception, if you link this library with other files,
+; some of which are compiled with SDCC, to produce an executable,
+; this library does not by itself cause the resulting executable to
+; be covered by the GNU General Public License. This exception does
+; not however invalidate any other reasons why the executable file
+; might be covered by the GNU General Public License.
+;--------------------------------------------------------------------------
+
+ .module rledecompress
+
+ .area _HOME
+
+ ;; Special RLE decoder used for initing global data
+ ;; input: DE - destination address
+__initrleblock::
+ ;; Pop the return address
+ pop hl
+1$:
+ ;; Fetch the run
+ ld c, (hl)
+ inc hl
+ ;; Negative means a run
+ bit 7, c
+ jr Z, 2$
+ ;; Expanding a run
+ ld a, (hl+)
+3$:
+ ld (de), a
+ inc de
+ inc c
+ jr NZ, 3$
+ jr 1$
+2$:
+ ;; Zero means end of a block
+ inc c
+ dec c
+ jr Z, 4$
+ ;; Expanding a block
+5$:
+ ld a, (hl+)
+ ld (de), a
+ inc de
+ dec c
+ jr NZ, 5$
+ jr 1$
+4$:
+ ;; Return back
+ jp (hl) \ No newline at end of file
diff --git a/gbdk/gbdk-lib/libc/asm/sm83/div.s b/gbdk/gbdk-lib/libc/asm/sm83/div.s
new file mode 100644
index 00000000..8e2df66a
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/asm/sm83/div.s
@@ -0,0 +1,339 @@
+;--------------------------------------------------------------------------
+; div.s
+;
+; Copyright (C) 2000, Michael Hope
+; Copyright (C) 2021, Sebastian 'basxto' Riedel (sdcc@basxto.de)
+; Copyright (c) 2021, Philipp Klaus Krause
+;
+; This library is free software; you can redistribute it and/or modify it
+; under the terms of the GNU General Public License as published by the
+; Free Software Foundation; either version 2, or (at your option) any
+; later version.
+;
+; This library is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this library; see the file COPYING. If not, write to the
+; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+; MA 02110-1301, USA.
+;
+; As a special exception, if you link this library with other files,
+; some of which are compiled with SDCC, to produce an executable,
+; this library does not by itself cause the resulting executable to
+; be covered by the GNU General Public License. This exception does
+; not however invalidate any other reasons why the executable file
+; might be covered by the GNU General Public License.
+;--------------------------------------------------------------------------
+
+ ;; Originally from GBDK by Pascal Felber.
+ .module divmod
+ .area _CODE
+.globl __divsuchar
+.globl __modsuchar
+.globl __divuschar
+.globl __moduschar
+.globl __divschar
+.globl __modschar
+.globl __divsint
+.globl __modsint
+.globl __divuchar
+.globl __moduchar
+.globl __divuint
+.globl __moduint
+
+__divsuchar:
+ ld c, a
+ ld b, #0
+
+ jp signexte
+
+__modsuchar:
+ ld c, a
+ ld b, #0
+
+ call signexte
+
+ ld c, e
+ ld b, d
+
+ ret
+
+__divuschar:
+ ld d, #0
+
+ ld c, a ; Sign extend
+ rlca
+ sbc a
+ ld b,a
+
+ jp .div16
+
+__moduschar:
+ ld e, a
+ ld d, #0
+
+ ld a,c ; Sign extend
+ rlca
+ sbc a
+ ld b,a
+
+ call .div16
+
+ ld c, e
+ ld b, d
+
+ ret
+
+__divschar:
+ ld c, a
+
+ call .div8
+
+ ret
+
+__modschar:
+ ld c, a
+
+ call .div8
+
+ ld c, e
+ ld b, d
+
+ ret
+
+__divsint:
+ ld a, e
+ ld e, c
+ ld c, a
+
+ ld a, d
+ ld d, b
+ ld b, a
+
+ jp .div16
+
+__modsint:
+ ld a, e
+ ld e, c
+ ld c, a
+
+ ld a, d
+ ld d, b
+ ld b, a
+
+ call .div16
+
+ ld c, e
+ ld b, d
+
+ ret
+
+ ;; Unsigned
+__divuchar:
+ ld c, a
+
+ call .divu8
+
+ ret
+
+__moduchar:
+ ld c, a
+
+ call .divu8
+
+ ld c, e
+ ld b, d
+
+ ret
+
+__divuint:
+ ld a, e
+ ld e, c
+ ld c, a
+
+ ld a, d
+ ld d, b
+ ld b, a
+
+ jp .divu16
+
+__moduint:
+ ld a, e
+ ld e, c
+ ld c, a
+
+ ld a, d
+ ld d, b
+ ld b, a
+
+ call .divu16
+
+ ld c, e
+ ld b, d
+
+ ret
+
+.div8::
+.mod8::
+ ld a,c ; Sign extend
+ rlca
+ sbc a
+ ld b,a
+signexte:
+ ld a, e ; Sign extend
+ rlca
+ sbc a
+ ld d, a
+
+ ; Fall through to .div16
+
+ ;; 16-bit division
+ ;;
+ ;; Entry conditions
+ ;; BC = dividend
+ ;; DE = divisor
+ ;;
+ ;; Exit conditions
+ ;; BC = quotient
+ ;; DE = remainder
+ ;; If divisor is non-zero, carry=0
+ ;; If divisor is 0, carry=1 and both quotient and remainder are 0
+ ;;
+ ;; Register used: AF,BC,DE,HL
+.div16::
+.mod16::
+ ;; Determine sign of quotient by xor-ing high bytes of dividend
+ ;; and divisor. Quotient is positive if signs are the same, negative
+ ;; if signs are different
+ ;; Remainder has same sign as dividend
+ ld a,b ; Get high byte of dividend
+ push af ; Save as sign of remainder
+ xor d ; Xor with high byte of divisor
+ push af ; Save sign of quotient
+
+ ;; Take absolute value of divisor
+ bit 7,d
+ jr Z,.chkde ; Jump if divisor is positive
+ sub a ; Substract divisor from 0
+ sub e
+ ld e,a
+ sbc a ; Propagate borrow (A=0xFF if borrow)
+ sub d
+ ld d,a
+ ;; Take absolute value of dividend
+.chkde:
+ bit 7,b
+ jr Z,.dodiv ; Jump if dividend is positive
+ sub a ; Substract dividend from 0
+ sub c
+ ld c,a
+ sbc a ; Propagate borrow (A=0xFF if borrow)
+ sub b
+ ld b,a
+ ;; Divide absolute values
+.dodiv:
+ call .divu16
+ jr C,.exit ; Exit if divide by zero
+ ;; Negate quotient if it is negative
+ pop af ; recover sign of quotient
+ and #0x80
+ jr Z,.dorem ; Jump if quotient is positive
+ sub a ; Substract quotient from 0
+ sub c
+ ld c,a
+ sbc a ; Propagate borrow (A=0xFF if borrow)
+ sub b
+ ld b,a
+.dorem:
+ ;; Negate remainder if it is negative
+ pop af ; recover sign of remainder
+ and #0x80
+ ret Z ; Return if remainder is positive
+ sub a ; Substract remainder from 0
+ sub e
+ ld e,a
+ sbc a ; Propagate remainder (A=0xFF if borrow)
+ sub d
+ ld d,a
+ ret
+.exit:
+ pop af
+ pop af
+ ret
+
+.divu8::
+.modu8::
+ ld b,#0x00
+ ld d,b
+ ; Fall through to divu16
+
+.divu16::
+.modu16::
+ ;; Check for division by zero
+ ld a,e
+ or d
+ jr NZ,.divide ; Branch if divisor is non-zero
+ ld bc,#0x00 ; Divide by zero error
+ ld d,b
+ ld e,c
+ scf ; Set carry, invalid result
+ ret
+.divide:
+ ld l,c ; L = low byte of dividend/quotient
+ ld h,b ; H = high byte of dividend/quotient
+ ld bc,#0x00 ; BC = remainder
+ or a ; Clear carry to start
+ ld a,#16 ; 16 bits in dividend
+.dvloop:
+ ;; Shift next bit of quotient into bit 0 of dividend
+ ;; Shift next MSB of dividend into LSB of remainder
+ ;; BC holds both dividend and quotient. While we shift a bit from
+ ;; MSB of dividend, we shift next bit of quotient in from carry
+ ;; HL holds remainder
+ ;; Do a 32-bit left shift, shifting carry to L, L to H,
+ ;; H to C, C to B
+ push af ; save number of bits remaining
+ rl l ; Carry (next bit of quotient) to bit 0
+ rl h ; Shift remaining bytes
+ rl c
+ rl b ; Clears carry since BC was 0
+ ;; If remainder is >= divisor, next bit of quotient is 1. This
+ ;; bit goes to carry
+ push bc ; Save current remainder
+ ld a,c ; Substract divisor from remainder
+ sbc e
+ ld c,a
+ ld a,b
+ sbc d
+ ld b,a
+ ccf ; Complement borrow so 1 indicates a
+ ; successful substraction (this is the
+ ; next bit of quotient)
+ jr C,.drop ; Jump if remainder is >= dividend
+ pop bc ; Otherwise, restore remainder
+ pop af ; recover # bits remaining, carry flag destroyed
+ dec a
+ or a ; restore (clear) the carry flag
+ jr NZ,.dvloop
+ jr .nodrop
+.drop:
+ pop af ; faster and smaller than 2x inc sp
+ pop af ; recover # bits remaining, carry flag destroyed
+ dec a
+ scf ; restore (set) the carry flag
+ jr NZ,.dvloop
+ jr .nodrop
+.nodrop:
+ ;; Shift last carry bit into quotient
+ ld d,b ; DE = remainder
+ ld e,c
+ rl l ; Carry to L
+ ld c,l ; C = low byte of quotient
+ rl h
+ ld b,h ; B = high byte of quotient
+ or a ; Clear carry, valid result
+ ret
+
diff --git a/gbdk/gbdk-lib/libc/asm/sm83/itoa.s b/gbdk/gbdk-lib/libc/asm/sm83/itoa.s
new file mode 100644
index 00000000..0e983441
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/asm/sm83/itoa.s
@@ -0,0 +1,190 @@
+;--------------------------------------------------------------------------
+; itoa.s
+;
+; Copyright (C) 2020, Tony Pavlov
+;
+; This library is free software; you can redistribute it and/or modify it
+; under the terms of the GNU General Public License as published by the
+; Free Software Foundation; either version 2, or (at your option) any
+; later version.
+;
+; This library is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this library; see the file COPYING. If not, write to the
+; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+; MA 02110-1301, USA.
+;
+; As a special exception, if you link this library with other files,
+; some of which are compiled with SDCC, to produce an executable,
+; this library does not by itself cause the resulting executable to
+; be covered by the GNU General Public License. This exception does
+; not however invalidate any other reasons why the executable file
+; might be covered by the GNU General Public License.
+;--------------------------------------------------------------------------
+
+ .module itoa
+
+ .area _HOME
+
+_uitoa::
+ push BC
+ lda HL, 4(SP)
+ ld A, (HL+)
+ ld E, A
+ ld A, (HL+)
+ ld D, A ; DE: uint
+ ld A, (HL+)
+ ld C, A
+ ld B, (HL) ; BC: dest
+ call .utoa
+ pop BC
+ ret
+
+_itoa::
+ push BC
+ lda HL, 4(SP)
+ ld A, (HL+)
+ ld E, A
+ ld A, (HL+)
+ ld D, A ; DE: int
+ ld A, (HL+)
+ ld C, A
+ ld B, (HL) ; BC: dest
+ call .itoa
+ pop BC
+ ret
+
+.itoa:: ; convert int into ascii
+ ld A, D
+ add A, A
+ jr NC, .utoa
+
+ rra ; DE = abs(DE)
+ cpl
+ ld D, A
+ ld A, E
+ cpl
+ ld E, A
+ inc DE
+
+ ld A, #'-'
+ ld (BC), A
+ inc BC
+
+ call .utoa
+ dec DE
+ ret
+
+.utoa:: ; convert unsigned int into ascii
+ add SP, #-3
+ lda HL, 2(SP)
+
+ xor A ; clear value
+ ld (HL-), A
+ ld (HL-), A
+ ld (HL), A
+
+ push BC
+ ld B, #8
+1$:
+ sla E
+ rl D
+
+ ld A, (HL)
+ adc A
+ daa
+ ld (HL+), A
+ ld A, (HL)
+ adc A
+ daa
+ ld (HL+), A
+ ld A, (HL)
+ adc A
+ daa
+ ld (HL-), A
+ dec HL
+
+ sla E
+ rl D
+
+ ld A, (HL)
+ adc A
+ daa
+ ld (HL+), A
+ ld A, (HL)
+ adc A
+ daa
+ ld (HL+), A
+ ld A, (HL)
+ adc A
+ daa
+ ld (HL-), A
+ dec HL
+
+ dec B
+ jr NZ, 1$
+
+ pop BC
+ push BC
+
+ ld DE, #'0'
+ lda HL, 4(SP)
+
+ ld A, (HL-)
+ and #0x0f
+ or A
+ jr Z, 3$
+ add A, E
+ ld D, #1 ; make D nonzero
+ ld (BC), A
+ inc BC
+3$:
+ ld A, (HL)
+ swap A
+ and #0x0f
+ add D
+ jr Z, 4$
+ sub D
+ add A, E
+ ld D, #1 ; make D nonzero
+ ld (BC), A
+ inc BC
+4$:
+ ld A, (HL-)
+ and #0x0f
+ add D
+ jr Z, 5$
+ sub D
+ add A, E
+ ld D, #1 ; make D nonzero
+ ld (BC), A
+ inc BC
+5$:
+ ld A, (HL)
+ swap A
+ and #0x0f
+ add D
+ jr Z, 6$
+ sub D
+ add A, E
+ ld (BC), A
+ inc BC
+6$:
+ ld A, (HL)
+ and #0x0f
+ add A, E
+ ld (BC), A
+ inc BC
+
+ xor A
+ ld (BC), A ; write trailing #0
+
+ pop DE
+
+ add sp, #3
+
+ ret
diff --git a/gbdk/gbdk-lib/libc/asm/sm83/labs.s b/gbdk/gbdk-lib/libc/asm/sm83/labs.s
new file mode 100644
index 00000000..390e925b
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/asm/sm83/labs.s
@@ -0,0 +1,70 @@
+;--------------------------------------------------------------------------
+; labs.s
+;
+; Copyright (C) 2020, Tony Pavlov
+;
+; This library is free software; you can redistribute it and/or modify it
+; under the terms of the GNU General Public License as published by the
+; Free Software Foundation; either version 2, or (at your option) any
+; later version.
+;
+; This library is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this library; see the file COPYING. If not, write to the
+; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+; MA 02110-1301, USA.
+;
+; As a special exception, if you link this library with other files,
+; some of which are compiled with SDCC, to produce an executable,
+; this library does not by itself cause the resulting executable to
+; be covered by the GNU General Public License. This exception does
+; not however invalidate any other reasons why the executable file
+; might be covered by the GNU General Public License.
+;--------------------------------------------------------------------------
+
+ .module labs
+
+ .area _HOME
+
+;long labs(long num)
+_labs::
+ lda HL, 2(SP)
+ ld A, (HL+)
+ ld E, A
+ ld A, (HL+)
+ ld D, A
+ ld A, (HL+)
+ ld H, (HL)
+ ld L, A ; DEHL = num
+
+.labs::
+ ld A, H
+ add A, A
+ ret NC
+
+1$:
+ ld A, E
+ cpl
+ add #1
+ ld E, A
+
+ ld A, D
+ cpl
+ adc #0
+ ld D, A
+
+ ld A, L
+ cpl
+ adc #0
+ ld L, A
+
+ ld A, H
+ cpl
+ adc #0
+ ld H, A
+
+ ret
diff --git a/gbdk/gbdk-lib/libc/asm/sm83/ltoa.s b/gbdk/gbdk-lib/libc/asm/sm83/ltoa.s
new file mode 100644
index 00000000..5a4da145
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/asm/sm83/ltoa.s
@@ -0,0 +1,222 @@
+;--------------------------------------------------------------------------
+; ltoa.s
+;
+; Copyright (C) 2020, Tony Pavlov
+;
+; This library is free software; you can redistribute it and/or modify it
+; under the terms of the GNU General Public License as published by the
+; Free Software Foundation; either version 2, or (at your option) any
+; later version.
+;
+; This library is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this library; see the file COPYING. If not, write to the
+; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+; MA 02110-1301, USA.
+;
+; As a special exception, if you link this library with other files,
+; some of which are compiled with SDCC, to produce an executable,
+; this library does not by itself cause the resulting executable to
+; be covered by the GNU General Public License. This exception does
+; not however invalidate any other reasons why the executable file
+; might be covered by the GNU General Public License.
+;--------------------------------------------------------------------------
+
+ .module ltoa
+
+ .area _HOME
+
+_ultoa::
+ push BC
+
+ lda HL, 8(SP)
+ ld A, (HL+)
+ ld C, A
+ ld B, (HL) ; BC: dest
+
+ lda HL, 4(SP)
+ ld E, L
+ ld D, H ; DE : ulong *
+
+ call .ultoa
+
+ pop BC
+ ret
+
+_ltoa::
+ push BC
+
+ lda HL, 8(SP)
+ ld A, (HL+)
+ ld C, A
+ ld B, (HL) ; BC: dest
+
+ lda HL, 4(SP)
+ ld E, L
+ ld D, H ; DE : ulong *
+
+ call .ltoa
+
+ pop BC
+ ret
+
+.ltoa::
+ push DE
+
+ ld A, #3
+ add E
+ ld E, A
+ adc D
+ sub E
+ ld D, A
+
+ ld A, (DE)
+ add A, A
+ pop DE
+ jr NC, .ultoa
+
+1$:
+ push DE
+ ld A, (DE)
+ cpl
+ add #1
+ ld (DE), A
+ inc DE
+
+ ld A, (DE)
+ cpl
+ adc #0
+ ld (DE), A
+ inc DE
+
+ ld A, (DE)
+ cpl
+ adc #0
+ ld (DE), A
+ inc DE
+
+ ld A, (DE)
+ cpl
+ adc #0
+ ld (DE), A
+
+ pop DE
+
+ ld A, #'-'
+ ld (BC), A
+ inc BC
+
+ call .ultoa
+ dec DE
+ ret
+
+.ultoa:: ; convert unsigned int into ascii
+ add SP, #-5
+ lda HL, 4(SP)
+
+ xor A ; clear value
+ ld (HL-), A
+ ld (HL-), A
+ ld (HL-), A
+ ld (HL-), A
+ ld (HL), A
+
+ push BC
+ ld B, #32
+1$:
+ ld H, D
+ ld L, E
+
+ sla (HL)
+ inc HL
+ rl (HL)
+ inc HL
+ rl (HL)
+ inc HL
+ rl (HL)
+
+ rra
+ lda HL, 2(SP)
+ rla
+
+ ld A, (HL)
+ adc A
+ daa
+ ld (HL+), A ; #0
+ ld A, (HL)
+ adc A
+ daa
+ ld (HL+), A ; #1
+ ld A, (HL)
+ adc A
+ daa
+ ld (HL+), A ; #2
+ ld A, (HL)
+ adc A
+ daa
+ ld (HL+), A ; #3
+ ld A, (HL)
+ adc A
+ daa
+ ld (HL), A ; #4
+
+ dec B
+ jr NZ, 1$
+
+ pop BC
+ push BC
+
+ ld DE, #((5 << 8) | '0')
+ lda HL, 6(SP)
+
+ scf
+ ccf
+
+3$:
+ rl D
+ ld A, (HL)
+ swap A
+ and #0x0f
+ bit 0, D
+ jr NZ, 6$
+ or A
+ jr Z, 4$
+6$:
+ add A, E
+ ld (BC), A
+ set 0, D
+ inc BC
+4$:
+ ld A, (HL-)
+ and #0x0f
+ bit 0, D
+ jr NZ, 7$
+ or A
+ jr Z, 5$
+7$:
+ add A, E
+ ld (BC), A
+ set 0, D
+ inc BC
+5$:
+ rr D
+ dec D
+ jr NZ, 3$
+ jr C, 8$
+
+ ld A, #'0' ; n == 0
+ ld (BC), A
+ inc BC
+8$:
+ xor A
+ ld (BC), A ; write trailing #0
+
+ pop DE
+
+ add sp, #5
+
+ ret
diff --git a/gbdk/gbdk-lib/libc/asm/sm83/memcpy.s b/gbdk/gbdk-lib/libc/asm/sm83/memcpy.s
new file mode 100644
index 00000000..83357b5c
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/asm/sm83/memcpy.s
@@ -0,0 +1,94 @@
+;--------------------------------------------------------------------------
+; memcpy.s
+;
+; Copies in groups of four. Algorithm is Duff's device.
+;
+; Copyright (c) 2021, Philipp Klaus Krause
+; Copyright (c) 2022, Sebastian 'basxto' Riedel <sdcc@basxto.de>
+;
+; This library is free software; you can redistribute it and/or modify it
+; under the terms of the GNU General Public License as published by the
+; Free Software Foundation; either version 2, or (at your option) any
+; later version.
+;
+; This library is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this library; see the file COPYING. If not, write to the
+; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+; MA 02110-1301, USA.
+;
+; As a special exception, if you link this library with other files,
+; some of which are compiled with SDCC, to produce an executable,
+; this library does not by itself cause the resulting executable to
+; be covered by the GNU General Public License. This exception does
+; not however invalidate any other reasons why the executable file
+; might be covered by the GNU General Public License.
+;--------------------------------------------------------------------------
+
+ .area _CODE
+
+ .globl _memcpy
+ .globl ___memcpy
+
+ ; gets called by memmove for (s >= d)
+ ; bigger than the old algorithm but faster for n>=5
+_memcpy::
+___memcpy::
+ ;dest in de
+ ;src in bc
+ ;n in sp+2,sp+3
+ push de
+ ldhl sp, #5
+ ld a, (hl-)
+ ld l, (hl)
+ ld h, b
+ ld b, a
+ ld a, l
+ ld l, c
+ srl b
+ rra
+ ld c, a
+ ;dest in de (backup in sp+0,sp+1)
+ ;src in hl
+ ;n/2 in bc
+ ;LSB of bc in carry
+ jr nc, skip_one
+ ld a, (hl+)
+ ld (de), a
+ inc de
+skip_one:
+ ;n/2 in bc
+ ;shift second LSB to carry
+ srl b
+ rr c
+ ;n/4 in bc
+ inc b
+ inc c
+ jr nc, test
+ jr copy_two
+.irp idx,copy_four,copy_two
+ idx:
+ .rept 2
+ ld a, (hl+)
+ ld (de), a
+ inc de
+ .endm
+.endm
+test:
+.irp idx,c,b
+ dec idx
+ jr nz, copy_four
+.endm
+
+end:
+ ;restore dest
+ pop bc
+ ;get return address
+ pop hl
+ ;throw away n
+ pop af
+ jp (hl) \ No newline at end of file
diff --git a/gbdk/gbdk-lib/libc/asm/sm83/mul.s b/gbdk/gbdk-lib/libc/asm/sm83/mul.s
new file mode 100644
index 00000000..4d451208
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/asm/sm83/mul.s
@@ -0,0 +1,158 @@
+;--------------------------------------------------------------------------
+; mul.s
+;
+; Copyright (C) 2000, Michael Hope
+; Copyright (C) 2021-2022, Sebastian 'basxto' Riedel (sdcc@basxto.de)
+; Copyright (c) 2021, Philipp Klaus Krause
+;
+; This library is free software; you can redistribute it and/or modify it
+; under the terms of the GNU General Public License as published by the
+; Free Software Foundation; either version 2, or (at your option) any
+; later version.
+;
+; This library is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this library; see the file COPYING. If not, write to the
+; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+; MA 02110-1301, USA.
+;
+; As a special exception, if you link this library with other files,
+; some of which are compiled with SDCC, to produce an executable,
+; this library does not by itself cause the resulting executable to
+; be covered by the GNU General Public License. This exception does
+; not however invalidate any other reasons why the executable file
+; might be covered by the GNU General Public License.
+;--------------------------------------------------------------------------
+
+ ;; Originally from GBDK by Pascal Felber.
+
+ .module mul
+ .area _CODE
+
+.globl __mulsuchar
+.globl __muluschar
+.globl __mulschar
+.globl __muluchar
+.globl __mulint
+
+; operands with different sign
+
+__mulsuchar:
+ ld c, a
+ jr signexte
+
+__muluschar:
+ ld c, e
+ ld e, a
+
+signexte:
+ ld a,e
+ rla
+ sbc a,a
+ ld d,a
+
+ xor a
+ jr .mul8
+
+__mulschar:
+ ; Sign-extend before going in.
+ ld c,a
+
+ rla
+ sbc a,a
+ ld b,a
+
+ ld a,e
+ rla
+ sbc a,a
+ ld d,a
+
+__mulint:
+ ;; 16-bit multiplication
+ ;;
+ ;; Entry conditions
+ ;; BC = multiplicand
+ ;; DE = multiplier
+ ;;
+ ;; Exit conditions
+ ;; BC = less significant word of product
+ ;;
+ ;; Register used: AF,BC,DE,HL
+.mul16:
+ ;; Let the smaller number loop
+ ld a,b
+ cp a,d
+ jr c, keep
+ ;; d <= b
+ ld a, e
+ ld e, c
+ ld c, a
+ ld a, d
+ ld d, b
+ ld b, a
+keep:
+ ;; Optimise for the case when this side has 8 bits of data or
+ ;; less. This is often the case with support address calls.
+ or a
+ jp Z, .mul8
+
+ ld l,#0
+ ld b,#16
+loop16:
+ ;; Taken from z88dk, which originally borrowed from the
+ ;; Spectrum rom.
+ add hl,hl
+ rl c
+ rla ;DLE 27/11/98
+ jr NC,skip16
+ add hl,de
+skip16:
+ dec b
+ jr NZ,loop16
+
+ ;; Return in bc
+ ld c,l
+ ld b,h
+
+ ret
+
+__muluchar:
+ ld c, a
+ xor a
+ ;; Clear the top
+ ld d, a
+
+ ;; Version that uses an 8bit multiplicand
+ ;;
+ ;; Entry conditions
+ ;; C = multiplicand
+ ;; DE = multiplier
+ ;; A = 0
+ ;;
+ ;; Exit conditions
+ ;; BC = less significant word of product
+ ;;
+ ;; Register used: AF,BC,DE,HL
+.mul8:
+ ld l,a
+ ld b,#8
+ ld a,c
+loop8:
+ add hl,hl
+ rla
+ jr NC,skip8
+ add hl,de
+skip8:
+ dec b
+ jr NZ,loop8
+
+ ;; Return in bc
+ ld c,l
+ ld b,h
+
+ ret
+
diff --git a/gbdk/gbdk-lib/libc/asm/sm83/rand.s b/gbdk/gbdk-lib/libc/asm/sm83/rand.s
new file mode 100644
index 00000000..da51378b
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/asm/sm83/rand.s
@@ -0,0 +1,117 @@
+;/***************************************************************************
+; * *
+; * Module : rand.s *
+; * *
+; * Purpose : A rand() generator using the linear congruential method *
+; * *
+; * Version : 1.01, January 7 1998 *
+; * Added _initrand to set seed without recompiling *
+; * 1, January 6 1998 *
+; * *
+; * Author : Luc Van den Borre ( Homepage : NOC.BASE.ORG ) *
+; * *
+; **************************************************************************/
+
+ ;; Why use an algorithm for generating random numbers?
+ ;;
+ ;; - Given a certain seed value, the same sequence of random numbers is generated
+ ;; every time. This is a good thing when debugging (reproducible). On the other
+ ;; hand, you've got 2^16 seed values, each of which will produce a sequence of
+ ;; numbers that stays different for any of the other sequences for 'an appreciable
+ ;; time.' (I can't say how long exactly.)
+ ;;
+ ;; - The linear congruential method is one of the 'best' random number generators
+ ;; around. However, this implementation uses a 16 bit accumulator, while at least
+ ;; 32 bits are needed for a generator that passes all the statistical tests.
+ ;; Still, I'm relatively confident that this is random enough for even the most
+ ;; demanding game.
+ ;;
+ ;; Compare this to getting random values from one of the hardware registers
+ ;; (not reproducible, might not have all values). An array might be the best bet
+ ;; if you don't need a lot of values (or have lots of memory spare),
+ ;; or if you want values to be within a certain range.
+ ;; And both would be faster than this. Also, this definitely isn't the fastest
+ ;; algorithm I know, and certainly for games less strict algorithms might be
+ ;; appropriate (shift and xor ?).
+ ;; It's your choice - but if you're doing Monte Carlo physics simulations on the
+ ;; GameBoy, this is a safe bet!
+
+ .area _DATA
+___rand_seed::
+.randlo: ; Storage for last random number (or seed)
+ .ds 0x01
+.randhi:
+ .ds 0x01
+
+ .area _HOME
+
+ ;; Random number generator using the linear congruential method
+ ;; X(n+1) = (a*X(n)+c) mod m
+ ;; with a = 17, m = 16 and c = $5c93 (arbitrarily)
+ ;; The seed value is also chosen arbitrarily as $a27e
+ ;; Ref : D. E. Knuth, "The Art of Computer Programming" , Volume 2
+ ;;
+ ;; Exit conditions
+ ;; DE = Random number [0,2^16-1]
+ ;;
+ ;; Registers used:
+ ;; A, HL (need not be saved) and DE (return register)
+ ;;
+
+_rand:: ; Banked
+_randw:: ; Banked
+ LD A,(.randlo)
+ LD L,A
+ LD E,A ; Save randlo
+ LD A,(.randhi)
+ LD D,A ; Save randhi
+
+ SLA L ; * 16
+ RLA
+ SLA L
+ RLA
+ SLA L
+ RLA
+ SLA L
+ RLA
+ LD H,A ; Save randhi*16
+
+ LD A,E ; Old randlo
+ ADD A,L ; Add randlo*16
+ LD L,A ; Save randlo*17
+
+ LD A,H ; randhi*16
+ ADC A,D ; Add old randhi
+ LD H,A ; Save randhi*17
+
+ LD A,L ; randlo*17
+ ADD A,#0x93
+ LD (.randlo),A
+ LD D,A ; Return register
+ LD A,H ; randhi*17
+ ADC A,#0x5c
+ LD (.randhi),A
+ LD E,A ; Return register
+
+ ;; Note D is the low byte,E the high byte. This is intentional because
+ ;; the high byte can be slightly 'more random' than the low byte, and I presume
+ ;; most will cast the return value to a uint8_t. As if someone will use this, tha!
+ RET
+
+ ;; This sets the seed value. Call it whenever you like
+ ;;
+ ;; Exit conditions
+ ;; None
+ ;;
+ ;; Registers used:
+ ;; A, HL (need not be saved) and DE (return register)
+ ;;
+
+_initrand::
+ LDA HL,2(SP)
+.initrand::
+ LD A,(HL+)
+ LD (.randlo),A
+ LD A,(HL)
+ LD (.randhi),A
+ RET
diff --git a/gbdk/gbdk-lib/libc/asm/sm83/reverse.s b/gbdk/gbdk-lib/libc/asm/sm83/reverse.s
new file mode 100644
index 00000000..37e4a280
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/asm/sm83/reverse.s
@@ -0,0 +1,84 @@
+;--------------------------------------------------------------------------
+; reverse.s
+;
+; Copyright (C) 2020, Tony Pavlov
+;
+; This library is free software; you can redistribute it and/or modify it
+; under the terms of the GNU General Public License as published by the
+; Free Software Foundation; either version 2, or (at your option) any
+; later version.
+;
+; This library is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this library; see the file COPYING. If not, write to the
+; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+; MA 02110-1301, USA.
+;
+; As a special exception, if you link this library with other files,
+; some of which are compiled with SDCC, to produce an executable,
+; this library does not by itself cause the resulting executable to
+; be covered by the GNU General Public License. This exception does
+; not however invalidate any other reasons why the executable file
+; might be covered by the GNU General Public License.
+;--------------------------------------------------------------------------
+
+ .module reverse
+
+ .area _HOME
+
+_reverse::
+ lda HL, 2(SP)
+ ld A, (HL+)
+ ld H, (HL)
+ ld L, A ; HL: s
+
+ push BC
+ ld B, H
+ ld C, L ; BC: s
+
+ ld DE, #0
+1$: ld A, (HL+)
+ or A
+ jr Z, 2$
+ inc DE
+ jr 1$
+
+2$:
+ srl D
+ rr E
+
+ ld A, E
+ or D
+ jr Z, 3$
+
+ dec HL
+ dec HL
+
+ inc D
+ inc E
+ jr 5$
+4$:
+ ld A, (HL)
+ push AF
+ ld A, (BC)
+ ld (HL-), A
+ pop AF
+ ld (BC), A
+ inc BC
+5$:
+ dec E
+ jr NZ, 4$
+ dec D
+ jr NZ, 4$
+
+3$:
+ pop BC
+ lda HL, 2(SP)
+ ld E, (HL)
+ inc HL
+ ld D, (HL)
+ ret
diff --git a/gbdk/gbdk-lib/libc/asm/sm83/setjmp.s b/gbdk/gbdk-lib/libc/asm/sm83/setjmp.s
new file mode 100644
index 00000000..a17538e7
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/asm/sm83/setjmp.s
@@ -0,0 +1,105 @@
+;--------------------------------------------------------------------------
+; setjmp.s
+;
+; Copyright (C) 2011-2014, Philipp Klaus Krause
+;
+; This library is free software; you can redistribute it and/or modify it
+; under the terms of the GNU General Public License as published by the
+; Free Software Foundation; either version 2, or (at your option) any
+; later version.
+;
+; This library is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this library; see the file COPYING. If not, write to the
+; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+; MA 02110-1301, USA.
+;
+; As a special exception, if you link this library with other files,
+; some of which are compiled with SDCC, to produce an executable,
+; this library does not by itself cause the resulting executable to
+; be covered by the GNU General Public License. This exception does
+; not however invalidate any other reasons why the executable file
+; might be covered by the GNU General Public License.
+;--------------------------------------------------------------------------
+
+ .module longjmp
+
+ .area _HOME
+
+ .globl ___setjmp
+
+___setjmp:
+ pop bc
+ pop de
+ push de
+ push bc
+
+ ; Store stack pointer.
+ ldhl sp, #0
+ push de
+ push hl
+ pop de
+ pop hl
+ ld (hl), e
+ inc hl
+ ld (hl), d
+ inc hl
+
+ ; Store return address.
+ ld (hl), c
+ inc hl
+ ld (hl), b
+
+ ; Return 0.
+ xor a, a
+ ld e, a
+ ld d, a
+ ret
+
+.globl _longjmp
+
+_longjmp:
+ pop af
+ pop hl
+ pop de
+
+ ; Ensure that return value is non-zero.
+ ld a, e
+ or a, d
+ jr NZ, 0001$
+ inc de
+0001$:
+
+ ; Get stack pointer.
+ ld c, (hl)
+ inc hl
+ ld b, (hl)
+ inc hl
+
+ ; Adjust stack pointer.
+ push hl
+ push bc
+ pop hl
+ pop bc
+ ld sp, hl
+ push bc
+ pop hl
+
+ ; Get return address.
+ ld c, (hl)
+ inc hl
+ ld b, (hl)
+
+ ; Set return address.
+ pop af
+ push bc
+
+ ; Return value is in de.
+
+ ; Jump.
+ ret
+
diff --git a/gbdk/gbdk-lib/libc/asm/sm83/shift.s b/gbdk/gbdk-lib/libc/asm/sm83/shift.s
new file mode 100644
index 00000000..d7b6d55a
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/asm/sm83/shift.s
@@ -0,0 +1,89 @@
+ .module shift
+
+ .area _HOME
+
+ ;;
+__rrulong_rrx_s::
+ ld hl,#2
+ add hl,sp
+
+ ld a,(hl+)
+ ld e, a
+ ld a,(hl+)
+ ld d, a
+ ld a,(hl+)
+ ld c, a
+ ld a,(hl+)
+ ld b, a
+ ld a,(hl)
+
+ ld l,c
+ ld h,b
+1$:
+ or a,a
+ ret z
+
+ rr h
+ rr l
+ rr d
+ rr e
+
+ dec a
+ jp 1$
+
+__rrslong_rrx_s::
+ ld hl,#2
+ add hl,sp
+
+ ld a,(hl+)
+ ld e, a
+ ld a,(hl+)
+ ld d, a
+ ld a,(hl+)
+ ld c, a
+ ld a,(hl+)
+ ld b, a
+ ld a,(hl)
+
+ ld l,c
+ ld h,b
+1$:
+ or a,a
+ ret z
+
+ sra h
+ rr l
+ rr d
+ rr e
+
+ dec a
+ jp 1$
+
+__rlslong_rrx_s::
+__rlulong_rrx_s::
+ ld hl,#2
+ add hl,sp
+
+ ld a,(hl+)
+ ld e, a
+ ld a,(hl+)
+ ld d, a
+ ld a,(hl+)
+ ld c, a
+ ld a,(hl+)
+ ld b, a
+ ld a,(hl)
+
+ ld l,c
+ ld h,b
+1$:
+ or a,a
+ ret z
+
+ rl e
+ rl d
+ rl l
+ rl h
+
+ dec a
+ jp 1$
diff --git a/gbdk/gbdk-lib/libc/asm/sm83/strlen.s b/gbdk/gbdk-lib/libc/asm/sm83/strlen.s
new file mode 100644
index 00000000..61fa9572
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/asm/sm83/strlen.s
@@ -0,0 +1,44 @@
+;--------------------------------------------------------------------------
+; strlen.s
+;
+; Copyright (C) 2020, Tony Pavlov
+;
+; This library is free software; you can redistribute it and/or modify it
+; under the terms of the GNU General Public License as published by the
+; Free Software Foundation; either version 2, or (at your option) any
+; later version.
+;
+; This library is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this library; see the file COPYING. If not, write to the
+; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+; MA 02110-1301, USA.
+;
+; As a special exception, if you link this library with other files,
+; some of which are compiled with SDCC, to produce an executable,
+; this library does not by itself cause the resulting executable to
+; be covered by the GNU General Public License. This exception does
+; not however invalidate any other reasons why the executable file
+; might be covered by the GNU General Public License.
+;--------------------------------------------------------------------------
+
+ .module strlen
+
+ .area _HOME
+
+_strlen::
+ lda HL, 2(SP)
+ ld A, (HL+)
+ ld H, (HL)
+ ld L, A
+.strlen::
+ ld DE, #0
+1$: ld A, (HL+)
+ or A
+ ret Z
+ inc DE
+ jr 1$
diff --git a/gbdk/gbdk-lib/libc/asm/z80/Makefile b/gbdk/gbdk-lib/libc/asm/z80/Makefile
new file mode 100644
index 00000000..4fd41fc6
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/asm/z80/Makefile
@@ -0,0 +1,27 @@
+# z80 specific Makefile
+
+TOPDIR = ../../..
+
+THIS = z80
+
+ASSRC = __strreverse.s strcpy.s strlen.s \
+ divmixed.s divsigned.s divunsigned.s \
+ modsigned.s modunsigned.s modmixed.s \
+ mul.s mulchar.s \
+ __itoa.s __ltoa.s \
+ __uitobcd.s __ultobcd.s \
+ memcpy.s memmove.s memset.s memcmp.s \
+ setjmp.s \
+ abs.s \
+ rand.s arand.s \
+ __sdcc_call_hl.s __sdcc_call_iy.s \
+ atomic_flag_test_and_set.s __sdcc_critical.s \
+ crtenter.s
+
+include $(TOPDIR)/Makefile.common
+
+AS = $(AS_Z80)
+
+include ../Makefile.port
+
+
diff --git a/gbdk/gbdk-lib/libc/asm/z80/__itoa.s b/gbdk/gbdk-lib/libc/asm/z80/__itoa.s
new file mode 100644
index 00000000..a22cb1af
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/asm/z80/__itoa.s
@@ -0,0 +1,231 @@
+;--------------------------------------------------------------------------
+; __itoa.s
+;
+; Copyright (C) 2020, Sergey Belyashov
+;
+; This library is free software; you can redistribute it and/or modify it
+; under the terms of the GNU General Public License as published by the
+; Free Software Foundation; either version 2, or (at your option) any
+; later version.
+;
+; This library is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this library; see the file COPYING. If not, write to the
+; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+; MA 02110-1301, USA.
+;
+; As a special exception, if you link this library with other files,
+; some of which are compiled with SDCC, to produce an executable,
+; this library does not by itself cause the resulting executable to
+; be covered by the GNU General Public License. This exception does
+; not however invalidate any other reasons why the executable file
+; might be covered by the GNU General Public License.
+;--------------------------------------------------------------------------
+
+ .area _CODE
+
+ .globl _itoa
+ .globl _uitoa
+;
+;void __itoa(int value, char *string, unsigned char radix);
+;
+_itoa::
+ push ix
+ ld ix, #0
+ add ix, sp
+;
+; 4(ix) - value
+; 6(ix) - string
+; 8(ix) - radix
+;
+ ld e, 4 (ix)
+ ld d, 5 (ix)
+ bit 7, d
+ jr Z, ___uitoa_de
+;positive/negative numbers are supported only for radix=10
+ ld a, 8 (ix)
+ cp a, #10
+ jr NZ, ___uitoa_de
+;add minus sign to result and inverse value
+ ld hl, #0
+ or a, a
+ sbc hl, de
+ ex de, hl
+ ld l, 6 (ix)
+ ld h, 7 (ix)
+ ld (hl), #0x2D ;minus symbol
+ inc hl
+ ld 6 (ix), l
+ ld 7 (ix), h
+ jr ___uitoa_dehl
+;
+;void __uitoa(unsigned int value, char *string, unsigned char radix);
+;
+_uitoa::
+ push ix
+ ld ix, #0
+ add ix, sp
+;
+; 4(ix) - value
+; 6(ix) - string
+; 8(ix) - radix
+;
+ ld e, 4 (ix)
+ ld d, 5 (ix)
+;
+___uitoa_de:
+ ld l, 6 (ix)
+ ld h, 7 (ix)
+;
+___uitoa_dehl:
+ ld a, e
+ or a, d
+ jr NZ, 100$
+;
+ ld (hl), #0x30
+ inc hl
+ jp 190$
+100$:
+ ld a, 8 (ix)
+ cp a, #10 ;most popular radix
+ jr NZ, 110$
+;
+;-------- decimal convertion
+; this algorithm up to 2 times faster than generic
+;
+ ld c, l
+ ld b, h
+ ld hl, #-4
+ add hl, sp
+ ld sp, hl
+ push bc
+ push hl
+ push de
+ call ___uitobcd
+ ld hl, #4
+ add hl, sp
+ ld sp, hl
+ pop de ;DE - pointer to string
+ inc hl
+ inc hl ;HL - pointer to BCD value
+ ld b, #3 ;number of bytes in BCD value
+ ld a, #0x30 ;ASCII code of '0'
+103$:
+ rrd
+ ld (de), a
+ inc de
+ rrd
+ ld (de), a
+ inc de
+ inc hl
+ djnz 103$
+;
+; pop af
+; pop af
+;skip trailing zeroes
+ ld b, #5 ;real BCD number is at most 5 digits
+ dec de ;so always skip last zero
+105$:
+ dec de
+ ld a, (de)
+ cp a, #0x30
+ jr NZ, 107$ ;break loop if non-zero found
+ djnz 105$
+107$:
+ inc de ;always point to symbol next to last significant
+ ex de, hl
+ jr 190$
+;
+;---------------------------
+;
+110$:
+ cp a, #2
+ jr C, 190$ ;radix is less than 2
+;
+ ld c, a
+ dec c
+ and a, c
+ jr NZ, 150$
+;
+;-------- radix is power of 2
+;
+; DE - value, HL - pointer to string, C - mask
+120$:
+ ld a, e
+ ld b, c
+125$:
+ srl d
+ rr e
+ srl b
+ jr NZ, 125$
+;
+ and a, c
+ add a, #0x30
+ cp a, #0x3A ;convert to 0...9A...Z
+ jr C, 130$
+ add a, #7
+130$:
+ ld (hl), a
+ inc hl
+ ld a, e
+ or a, d
+ jr NZ, 120$
+ jr 190$
+;
+;---------------------------
+;
+;-------- custom radix (generic algorithm)
+;
+150$:
+ ex de, hl
+160$:
+ ld c, 8 (ix)
+ call ___divu16_8
+ add a, #0x30
+ cp a, #0x3A
+ jr C, 165$
+ add a, #7
+165$:
+ ld (de), a
+ inc de
+ ld a, l
+ or h
+ jr NZ, 160$
+ ex de, hl
+; jr 190$
+;
+;---------------------------
+;
+;-------- finish string and reverse order
+190$:
+ ld (hl), #0
+ ld e, 6 (ix)
+ ld d, 7 (ix)
+ call ___strreverse_reg
+ ld sp, ix
+ pop ix
+ ret
+;
+;
+;in: HL - divident, C - divisor
+;out: HL - quotient, A - remainder
+___divu16_8:
+ xor a, a
+ ld b, #16
+100$:
+ add hl, hl
+ rla
+ jr c, 110$
+ cp a, c
+ jr c, 120$
+110$:
+ sub a, c
+ inc l
+120$:
+ djnz 100$
+ ret
+
diff --git a/gbdk/gbdk-lib/libc/asm/z80/__ltoa.s b/gbdk/gbdk-lib/libc/asm/z80/__ltoa.s
new file mode 100644
index 00000000..8b7ea11c
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/asm/z80/__ltoa.s
@@ -0,0 +1,254 @@
+;--------------------------------------------------------------------------
+; __ltoa.s
+;
+; Copyright (C) 2020, Sergey Belyashov
+;
+; This library is free software; you can redistribute it and/or modify it
+; under the terms of the GNU General Public License as published by the
+; Free Software Foundation; either version 2, or (at your option) any
+; later version.
+;
+; This library is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this library; see the file COPYING. If not, write to the
+; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+; MA 02110-1301, USA.
+;
+; As a special exception, if you link this library with other files,
+; some of which are compiled with SDCC, to produce an executable,
+; this library does not by itself cause the resulting executable to
+; be covered by the GNU General Public License. This exception does
+; not however invalidate any other reasons why the executable file
+; might be covered by the GNU General Public License.
+;--------------------------------------------------------------------------
+
+ .area _CODE
+
+ .globl _ltoa
+ .globl _ultoa
+;
+;void __itoa(long value, char *string, unsigned char radix);
+;
+_ltoa::
+ push ix
+ ld ix, #0
+ add ix, sp
+;
+; 4(ix) - value
+; 8(ix) - string
+; 10(ix) - radix
+;
+ ld e, 4 (ix)
+ ld d, 5 (ix)
+ bit 7, 7 (ix)
+ jr Z, ___ultoa_de
+;positive/negative numbers are supported only for radix=10
+ ld a, 10 (ix)
+ cp a, #10
+ jr NZ, ___ultoa_de
+;add minus sign to result and inverse value
+ ld hl, #0
+ or a, a
+ sbc hl, de
+ ex de, hl
+ ld hl, #0
+ ld c, 6 (ix)
+ ld b, 7 (ix)
+ sbc hl, bc
+ ld 6 (ix), l
+ ld 7 (ix), h
+ ld l, 8 (ix)
+ ld h, 9 (ix)
+ ld (hl), #0x2D ;minus symbol
+ inc hl
+ ld 8 (ix), l
+ ld 9 (ix), h
+ jr ___ultoa_dehl
+;
+;void __uitoa(unsigned int value, char *string, unsigned char radix);
+;
+_ultoa::
+ push ix
+ ld ix, #0
+ add ix, sp
+;
+; 4(ix) - value
+; 8(ix) - string
+; 10(ix) - radix
+;
+ ld e, 4 (ix)
+ ld d, 5 (ix)
+;
+___ultoa_de:
+ ld l, 8 (ix)
+ ld h, 9 (ix)
+;
+___ultoa_dehl:
+ ld a, e
+ or a, d
+ or a, 6 (ix)
+ or a, 7 (ix)
+ jr NZ, 100$
+;
+ ld (hl), #0x30
+ inc hl
+ jp 190$
+100$:
+ ld a, 10 (ix)
+ cp a, #10 ;most popular radix
+ jr NZ, 110$
+;
+;-------- decimal convertion
+;this algorithm is 20% faster than generic one
+;
+ ld c, l
+ ld b, h
+ ld hl, #-5
+ add hl, sp
+ ld sp, hl
+ push bc
+ push hl
+ ld c, 6 (ix)
+ ld b, 7 (ix)
+ push bc
+ push de
+ call ___ultobcd
+ ld hl, #6
+ add hl, sp
+ ld sp, hl
+ pop de ;DE - pointer to string
+ inc hl
+ inc hl ;HL - pointer to BCD value
+ ld b, #5 ;number of bytes in BCD value
+ ld a, #0x30 ;ASCII code of '0'
+103$:
+ rrd
+ ld (de), a
+ inc de
+ rrd
+ ld (de), a
+ inc de
+ inc hl
+ djnz 103$
+;
+; ld sp, hl
+;skip trailing zeroes
+ ld b, #10 ;real decimal number is at most 10 digits
+105$:
+ dec de
+ ld a, (de)
+ cp a, #0x30
+ jr NZ, 107$ ;break loop if non-zero found
+ djnz 105$
+107$:
+ inc de ;always point to symbol next to last significant
+ ex de, hl
+ jr 190$
+;
+;---------------------------
+;
+110$:
+ cp a, #2
+ jr C, 190$ ;radix is less than 2
+;
+ ld c, a
+ dec c
+ and a, c
+ jr NZ, 150$
+;
+;-------- radix is power of 2
+;
+; DE - lower 16 bits of value, HL - pointer to string, C - mask
+120$:
+ ld a, e
+ ld b, c
+125$:
+ srl 7 (ix)
+ rr 6 (ix)
+ rr d
+ rr e
+ srl b
+ jr NZ, 125$
+;
+ and a, c
+ add a, #0x30
+ cp a, #0x3A ;convert to 0...9A...Z
+ jr C, 130$
+ add a, #7
+130$:
+ ld (hl), a
+ inc hl
+ ld a, e
+ or a, d
+ or a, 6 (ix)
+ or a, 7 (ix)
+ jr NZ, 120$
+ jr 190$
+;
+;---------------------------
+;
+;-------- custom radix (generic algorithm)
+;
+150$:
+ ex de, hl
+ ld c, e
+ ld b, d
+ ld e, 6 (ix)
+ ld d, 7 (ix)
+160$:
+ push bc
+ ld c, 10 (ix)
+ call ___divu32_8
+ pop bc
+ add a, #0x30
+ cp a, #0x3A
+ jr C, 165$
+ add a, #7
+165$:
+ ld (bc), a
+ inc bc
+ ld a, l
+ or a, h
+ or a, e
+ or a, d
+ jr NZ, 160$
+ ld l, c
+ ld h, b
+; jr 190$
+;
+;---------------------------
+;
+;-------- finish string and reverse order
+190$:
+ ld (hl), #0
+ ld e, 8 (ix)
+ ld d, 9 (ix)
+ call ___strreverse_reg
+ ld sp, ix
+ pop ix
+ ret
+;
+;in: DEHL - divident, C - divisor
+;out: DEHL - quotient, A - remainder
+___divu32_8:
+ xor a, a
+ ld b, #32
+100$:
+ add hl, hl
+ rl e
+ rl d
+ rla
+ jr c, 110$
+ cp a, c
+ jr c, 120$
+110$:
+ sub a, c
+ inc l
+120$:
+ djnz 100$
+ ret
+
diff --git a/gbdk/gbdk-lib/libc/asm/z80/__sdcc_call_hl.s b/gbdk/gbdk-lib/libc/asm/z80/__sdcc_call_hl.s
new file mode 100644
index 00000000..9086c7b8
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/asm/z80/__sdcc_call_hl.s
@@ -0,0 +1,37 @@
+;--------------------------------------------------------------------------
+; crtcall.s
+;
+; Copyright (C) 2011, Maarten Brock
+;
+; This library is free software; you can redistribute it and/or modify it
+; under the terms of the GNU General Public License as published by the
+; Free Software Foundation; either version 2, or (at your option) any
+; later version.
+;
+; This library is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this library; see the file COPYING. If not, write to the
+; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+; MA 02110-1301, USA.
+;
+; As a special exception, if you link this library with other files,
+; some of which are compiled with SDCC, to produce an executable,
+; this library does not by itself cause the resulting executable to
+; be covered by the GNU General Public License. This exception does
+; not however invalidate any other reasons why the executable file
+; might be covered by the GNU General Public License.
+;--------------------------------------------------------------------------
+
+ .area _CODE
+
+ .globl ___sdcc_call_hl
+
+; The Z80 has the jp (hl) instruction, which is perfect for implementing function pointers.
+
+___sdcc_call_hl:
+ jp (hl)
+
diff --git a/gbdk/gbdk-lib/libc/asm/z80/__sdcc_call_iy.s b/gbdk/gbdk-lib/libc/asm/z80/__sdcc_call_iy.s
new file mode 100644
index 00000000..8941745d
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/asm/z80/__sdcc_call_iy.s
@@ -0,0 +1,37 @@
+;--------------------------------------------------------------------------
+; crtcall.s
+;
+; Copyright (C) 2011, Maarten Brock, 2015 Philipp Klaus Krause
+;
+; This library is free software; you can redistribute it and/or modify it
+; under the terms of the GNU General Public License as published by the
+; Free Software Foundation; either version 2, or (at your option) any
+; later version.
+;
+; This library is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this library; see the file COPYING. If not, write to the
+; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+; MA 02110-1301, USA.
+;
+; As a special exception, if you link this library with other files,
+; some of which are compiled with SDCC, to produce an executable,
+; this library does not by itself cause the resulting executable to
+; be covered by the GNU General Public License. This exception does
+; not however invalidate any other reasons why the executable file
+; might be covered by the GNU General Public License.
+;--------------------------------------------------------------------------
+
+ .area _CODE
+
+ .globl ___sdcc_call_iy
+
+; The Z80 has the jp (iy) instruction, which is perfect for implementing function pointers.
+
+___sdcc_call_iy:
+ jp (iy)
+
diff --git a/gbdk/gbdk-lib/libc/asm/z80/__sdcc_critical.s b/gbdk/gbdk-lib/libc/asm/z80/__sdcc_critical.s
new file mode 100644
index 00000000..ead5e02c
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/asm/z80/__sdcc_critical.s
@@ -0,0 +1,54 @@
+;--------------------------------------------------------------------------
+; __sdcc_critical.s
+;
+; Copyright (C) 2020, Sergey Belyashov
+;
+; This library is free software; you can redistribute it and/or modify it
+; under the terms of the GNU General Public License as published by the
+; Free Software Foundation; either version 2, or (at your option) any
+; later version.
+;
+; This library is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this library; see the file COPYING. If not, write to the
+; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+; MA 02110-1301, USA.
+;
+; As a special exception, if you link this library with other files,
+; some of which are compiled with SDCC, to produce an executable,
+; this library does not by itself cause the resulting executable to
+; be covered by the GNU General Public License. This exception does
+; not however invalidate any other reasons why the executable file
+; might be covered by the GNU General Public License.
+;--------------------------------------------------------------------------
+
+ .area _CODE
+
+ .globl ___sdcc_critical_enter
+;
+; NMOS Z80 compatible
+; this function cannot be placed at 0x0000...0x00ff addresses
+;
+___sdcc_critical_enter::
+ xor a, a
+ push af
+ pop af
+ ld a, i
+ di
+ ret pe ;enabled interrupts
+ dec sp
+ dec sp
+ pop af
+ or a, a ;A = 0 if interrupts disabled
+ jr NZ, 00100$
+;inetrrupts disabled
+ sub a, a ;force P/V = 0
+ ret
+;interrupts enabled
+00100$:
+ xor a, a ;force P/V = 1
+ ret
diff --git a/gbdk/gbdk-lib/libc/asm/z80/__strreverse.s b/gbdk/gbdk-lib/libc/asm/z80/__strreverse.s
new file mode 100644
index 00000000..8372c5d5
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/asm/z80/__strreverse.s
@@ -0,0 +1,63 @@
+;--------------------------------------------------------------------------
+; __strreverse.s
+;
+; Copyright (C) 2020, Sergey Belyashov
+;
+; This library is free software; you can redistribute it and/or modify it
+; under the terms of the GNU General Public License as published by the
+; Free Software Foundation; either version 2, or (at your option) any
+; later version.
+;
+; This library is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this library; see the file COPYING. If not, write to the
+; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+; MA 02110-1301, USA.
+;
+; As a special exception, if you link this library with other files,
+; some of which are compiled with SDCC, to produce an executable,
+; this library does not by itself cause the resulting executable to
+; be covered by the GNU General Public License. This exception does
+; not however invalidate any other reasons why the executable file
+; might be covered by the GNU General Public License.
+;--------------------------------------------------------------------------
+
+ .area _CODE
+
+ .globl ___strreverse
+ .globl ___strreverse_reg
+;
+;char * __reverse(char *beg, char *end);
+;
+___strreverse::
+ pop bc
+ pop de
+ pop hl
+ push hl
+ push de
+ push bc
+
+;in: HL - pointer to end of string (null symbol), DE - pointer to start of string
+;
+___strreverse_reg::
+ push de
+ jr 110$
+100$:
+ add hl, de
+ ld a, (de)
+ ld c, (hl)
+ ld (hl), a
+ ld a, c
+ ld (de), a
+ inc de
+110$:
+ dec hl
+ or a, a
+ sbc hl, de
+ jr NC, 100$
+ pop hl
+ ret
diff --git a/gbdk/gbdk-lib/libc/asm/z80/__uitobcd.s b/gbdk/gbdk-lib/libc/asm/z80/__uitobcd.s
new file mode 100644
index 00000000..52db719e
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/asm/z80/__uitobcd.s
@@ -0,0 +1,87 @@
+;--------------------------------------------------------------------------
+; __uitobcd.s
+;
+; Copyright (C) 2020, Sergey Belyashov
+;
+; This library is free software; you can redistribute it and/or modify it
+; under the terms of the GNU General Public License as published by the
+; Free Software Foundation; either version 2, or (at your option) any
+; later version.
+;
+; This library is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this library; see the file COPYING. If not, write to the
+; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+; MA 02110-1301, USA.
+;
+; As a special exception, if you link this library with other files,
+; some of which are compiled with SDCC, to produce an executable,
+; this library does not by itself cause the resulting executable to
+; be covered by the GNU General Public License. This exception does
+; not however invalidate any other reasons why the executable file
+; might be covered by the GNU General Public License.
+;--------------------------------------------------------------------------
+
+ .area _CODE
+
+ .globl ___uitobcd
+;
+; void __uitobcd (unsigned int v, unsigned char bcd[3])
+; __uitobcd converts v to BCD representation to the bcd.
+; bcd[] will contain BCD value.
+;
+___uitobcd:
+ push ix
+ ld ix, #0
+ add ix, sp
+;
+ ld bc, #0x1000
+ ld d, c
+ ld e, c
+ ld l, 4 (ix)
+ ld h, 5 (ix)
+;
+;--- begin speed optimization
+;
+ ld a, h
+ or a, a
+ jr NZ, 100$
+;
+ ld h, l
+ srl b
+;
+;--- end speed optimization
+;
+; HL - binary value
+; CDE - future BCD value
+; B - bits count (16)
+100$:
+ add hl, hl
+ ld a, e
+ adc a, a
+ daa
+ ld e, a
+ ld a, d
+ adc a, a
+ daa
+ ld d, a
+ ld a, c
+ adc a, a
+ daa
+ ld c, a
+ djnz 100$
+;
+ ld l, 6 (ix)
+ ld h, 7 (ix)
+ ld (hl), e
+ inc hl
+ ld (hl), d
+ inc hl
+ ld (hl), c
+;
+ pop ix
+ ret
diff --git a/gbdk/gbdk-lib/libc/asm/z80/__ultobcd.s b/gbdk/gbdk-lib/libc/asm/z80/__ultobcd.s
new file mode 100644
index 00000000..8d4cf33c
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/asm/z80/__ultobcd.s
@@ -0,0 +1,122 @@
+;--------------------------------------------------------------------------
+; __ultobcd.s
+;
+; Copyright (C) 2020, Sergey Belyashov
+;
+; This library is free software; you can redistribute it and/or modify it
+; under the terms of the GNU General Public License as published by the
+; Free Software Foundation; either version 2, or (at your option) any
+; later version.
+;
+; This library is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this library; see the file COPYING. If not, write to the
+; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+; MA 02110-1301, USA.
+;
+; As a special exception, if you link this library with other files,
+; some of which are compiled with SDCC, to produce an executable,
+; this library does not by itself cause the resulting executable to
+; be covered by the GNU General Public License. This exception does
+; not however invalidate any other reasons why the executable file
+; might be covered by the GNU General Public License.
+;--------------------------------------------------------------------------
+
+ .area _CODE
+
+ .globl ___ultobcd
+;
+; void __ultobcd (unsigned long v, unsigned char bcd[5])
+; __ultobcd converts v to BCD representation to the bcd.
+; bcd[] will contain BCD value.
+;
+___ultobcd:
+ push ix
+ ld ix, #0
+ add ix, sp
+ ld bc, #0x2000
+;
+;--- begin speed optimization
+;
+ ld l, 4 (ix)
+ ld h, 5 (ix)
+ ld e, 6 (ix)
+ ld d, 7 (ix)
+ ld a, e
+ or a, d
+ jr NZ, 101$
+;high 2 bytes are zero
+ ld b, #0x10
+ ex de, hl
+101$:
+ ld a, d
+ or a, a
+ jr NZ, 102$
+;high byte is zero
+ ld d, e
+ ld e, h
+ ld h, l
+ ld a, #-8
+ add a, b
+ ld b, a
+102$:
+ ld 4 (ix), l
+ ld 5 (ix), h
+ ld 6 (ix), e
+ ld 7 (ix), d
+;
+;--- end speed optimization
+;
+ ld hl, #0x0000
+ ld e, l
+ ld d, h
+; (ix+0)..(ix+3) - binary value
+; CDEHL - future BCD value
+; B - bits count (32)
+103$:
+ sla 4 (ix)
+ rl 5 (ix)
+ rl 6 (ix)
+ rl 7 (ix)
+ ld a, l
+ adc a, a
+ daa
+ ld l, a
+ ld a, h
+ adc a, a
+ daa
+ ld h, a
+ ld a, e
+ adc a, a
+ daa
+ ld e, a
+ ld a, d
+ adc a, a
+ daa
+ ld d, a
+ ld a, c
+ adc a, a
+ daa
+ ld c, a
+ djnz 103$
+;
+ ld b, l
+ ld a, h
+ ld l, 8 (ix)
+ ld h, 9 (ix)
+ ld (hl), b
+ inc hl
+ ld (hl), a
+ inc hl
+ ld (hl), e
+ inc hl
+ ld (hl), d
+ inc hl
+ ld (hl), c
+;
+ pop ix
+ ret
diff --git a/gbdk/gbdk-lib/libc/asm/z80/abs.s b/gbdk/gbdk-lib/libc/asm/z80/abs.s
new file mode 100644
index 00000000..2aaa5412
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/asm/z80/abs.s
@@ -0,0 +1,61 @@
+;--------------------------------------------------------------------------
+; abs.s
+;
+; Copyright (C) 2010, Philipp Klaus Krause
+;
+; This library is free software; you can redistribute it and/or modify it
+; under the terms of the GNU General Public License as published by the
+; Free Software Foundation; either version 2, or (at your option) any
+; later version.
+;
+; This library is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this library; see the file COPYING. If not, write to the
+; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+; MA 02110-1301, USA.
+;
+; As a special exception, if you link this library with other files,
+; some of which are compiled with SDCC, to produce an executable,
+; this library does not by itself cause the resulting executable to
+; be covered by the GNU General Public License. This exception does
+; not however invalidate any other reasons why the executable file
+; might be covered by the GNU General Public License.
+;--------------------------------------------------------------------------
+
+ .area _CODE
+
+ .globl _abs
+
+; 12B; 86T for nonnegative arguments, 78T for negative.
+_abs:
+ pop hl
+ pop de
+ push de
+ push hl
+ xor a, a
+ ld l, a
+ ld h, a
+ sbc hl, de
+ ret P
+ ex de, hl
+ ret
+
+; 14B; 59T for nonegative arguments, 94T for negative:
+;_abs:
+; pop de
+; pop hl
+; push hl
+; push de
+; bit 7, h
+; ret Z
+; xor a, a
+; ld e, a
+; ld d, a
+; ex de, hl
+; sbc hl, de
+; ret
+
diff --git a/gbdk/gbdk-lib/libc/asm/z80/arand.s b/gbdk/gbdk-lib/libc/asm/z80/arand.s
new file mode 100644
index 00000000..a798cc3a
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/asm/z80/arand.s
@@ -0,0 +1,78 @@
+ .module Random
+
+ .globl .initrand
+ .globl _rand
+
+ .area _DATA
+
+.randarr:
+ .ds 55
+.raxj:
+ .ds 0x01
+.raxk:
+ .ds 0x01
+
+ .area _CODE
+
+_arand:: ; Banked
+ PUSH BC
+ LD D, #0
+ LD HL, #(.randarr - 1)
+ LD A, (.raxj)
+ LD E, A
+ DEC A ; Decrease the pointer
+ JR NZ, 1$
+ LD A, #55
+1$:
+ LD (.raxj), A
+ ADD HL, DE
+ LD B, (HL)
+
+ LD HL, #(.randarr - 1) ; Ooh...
+ LD A, (.raxk)
+ LD E, A
+ DEC A ; Decrease the pointer
+ JR NZ, 2$
+ LD A, #55
+2$:
+ LD (.raxk), A
+ ADD HL, DE
+ LD A, (HL)
+
+ ADD B
+ LD (HL), A ; Store new value
+
+ POP BC
+
+ LD H, #0
+ LD L, A
+
+ RET
+
+_initarand:: ; Banked
+ CALL .initrand
+
+ LD A, #55
+ LD HL, #.randarr
+1$:
+ DEC A
+ LD (.raxj), A
+ LD B, H
+ LD C, L
+ CALL _rand
+ LD H, B
+ LD L, C
+
+ LD (HL), E
+ INC HL
+
+ LD A, (.raxj)
+ CP #0
+ JP NZ, 1$
+
+ LD A, #24 ; Now the array has been filled,set the pointers
+ LD (.raxj), A
+ LD A, #55
+ LD (.raxk), A
+
+ RET
diff --git a/gbdk/gbdk-lib/libc/asm/z80/atomic_flag_test_and_set.s b/gbdk/gbdk-lib/libc/asm/z80/atomic_flag_test_and_set.s
new file mode 100644
index 00000000..074b5360
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/asm/z80/atomic_flag_test_and_set.s
@@ -0,0 +1,44 @@
+;--------------------------------------------------------------------------
+; atomic_flag_test_and_set.s
+;
+; Copyright (C) 2020, Philipp Klaus Krause
+;
+; This library is free software; you can redistribute it and/or modify it
+; under the terms of the GNU General Public License as published by the
+; Free Software Foundation; either version 2, or (at your option) any
+; later version.
+;
+; This library is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this library; see the file COPYING. If not, write to the
+; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+; MA 02110-1301, USA.
+;
+; As a special exception, if you link this library with other files,
+; some of which are compiled with SDCC, to produce an executable,
+; this library does not by itself cause the resulting executable to
+; be covered by the GNU General Public License. This exception does
+; not however invalidate any other reasons why the executable file
+; might be covered by the GNU General Public License.
+;--------------------------------------------------------------------------
+
+ .area _CODE
+
+ .globl _atomic_flag_test_and_set
+
+_atomic_flag_test_and_set:
+ pop de
+ pop hl
+ push hl
+ push de
+ xor a, a
+ srl (hl)
+ ccf
+ rla
+ ld l, a
+ ret
+
diff --git a/gbdk/gbdk-lib/libc/asm/z80/crtenter.s b/gbdk/gbdk-lib/libc/asm/z80/crtenter.s
new file mode 100644
index 00000000..0be714a8
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/asm/z80/crtenter.s
@@ -0,0 +1,41 @@
+;--------------------------------------------------------------------------
+; crtenter.s
+;
+; Copyright (C) 2015, Alan Cox, Philipp Klaus Krause
+;
+; This library is free software; you can redistribute it and/or modify it
+; under the terms of the GNU General Public License as published by the
+; Free Software Foundation; either version 2, or (at your option) any
+; later version.
+;
+; This library is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this library; see the file COPYING. If not, write to the
+; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+; MA 02110-1301, USA.
+;
+; As a special exception, if you link this library with other files,
+; some of which are compiled with SDCC, to produce an executable,
+; this library does not by itself cause the resulting executable to
+; be covered by the GNU General Public License. This exception does
+; not however invalidate any other reasons why the executable file
+; might be covered by the GNU General Public License.
+;--------------------------------------------------------------------------
+
+ .area _CODE
+
+ .globl ___sdcc_enter_ix
+
+; Factor out some start of function code to reduce code size
+
+___sdcc_enter_ix:
+ pop hl ; return address
+ push ix ; save frame pointer
+ ld ix, #0
+ add ix, sp ; set ix to the stack frame
+ jp (hl) ; and return
+
diff --git a/gbdk/gbdk-lib/libc/asm/z80/divmixed.s b/gbdk/gbdk-lib/libc/asm/z80/divmixed.s
new file mode 100644
index 00000000..8c60fc21
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/asm/z80/divmixed.s
@@ -0,0 +1,49 @@
+;--------------------------------------------------------------------------
+; divmixed.s
+;
+; Copyright (C) 2010-2021, Philipp Klaus Krause
+;
+; This library is free software; you can redistribute it and/or modify it
+; under the terms of the GNU General Public License as published by the
+; Free Software Foundation; either version 2, or (at your option) any
+; later version.
+;
+; This library is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this library; see the file COPYING. If not, write to the
+; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+; MA 02110-1301, USA.
+;
+; As a special exception, if you link this library with other files,
+; some of which are compiled with SDCC, to produce an executable,
+; this library does not by itself cause the resulting executable to
+; be covered by the GNU General Public License. This exception does
+; not however invalidate any other reasons why the executable file
+; might be covered by the GNU General Public License.
+;--------------------------------------------------------------------------
+
+.globl __divsuchar
+.globl __divuschar
+
+__divsuchar:
+ ld e, l
+ ld l, a
+ ld h, #0
+
+ jp __div_signexte
+
+__divuschar:
+ ld e, l
+ ld d, #0
+ ld l, a
+
+ rlca ; Sign extend
+ sbc a, a
+ ld h, a
+
+ jp __div16
+
diff --git a/gbdk/gbdk-lib/libc/asm/z80/divsigned.s b/gbdk/gbdk-lib/libc/asm/z80/divsigned.s
new file mode 100644
index 00000000..7f1949d4
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/asm/z80/divsigned.s
@@ -0,0 +1,124 @@
+;--------------------------------------------------------------------------
+; divsigned.s
+;
+; Copyright (C) 2000-2021, Michael Hope, Philipp Klaus Krause
+;
+; This library is free software; you can redistribute it and/or modify it
+; under the terms of the GNU General Public License as published by the
+; Free Software Foundation; either version 2, or (at your option) any
+; later version.
+;
+; This library is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this library; see the file COPYING. If not, write to the
+; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+; MA 02110-1301, USA.
+;
+; As a special exception, if you link this library with other files,
+; some of which are compiled with SDCC, to produce an executable,
+; this library does not by itself cause the resulting executable to
+; be covered by the GNU General Public License. This exception does
+; not however invalidate any other reasons why the executable file
+; might be covered by the GNU General Public License.
+;--------------------------------------------------------------------------
+
+.area _CODE
+
+.globl __divsint
+.globl __divschar
+
+__divschar:
+ ld e, l
+ ld l, a
+
+__div8::
+ ld a, l ; Sign extend
+ rlca
+ sbc a,a
+ ld h, a
+__div_signexte::
+ ld a, e ; Sign extend
+ rlca
+ sbc a, a
+ ld d, a
+ ; Fall through to __div16
+
+ ;; signed 16-bit division
+ ;;
+ ;; Entry conditions
+ ;; HL = dividend
+ ;; DE = divisor
+ ;;
+ ;; Exit conditions
+ ;; DE = quotient
+ ;; HL = remainder
+ ;;
+ ;; Register used: AF,B,DE,HL
+__divsint:
+__div16::
+ ;; Determine sign of quotient by xor-ing high bytes of dividend
+ ;; and divisor. Quotient is positive if signs are the same, negative
+ ;; if signs are different
+ ;; Remainder has same sign as dividend
+ ld a, h ; Get high byte of dividend
+ xor a, d ; Xor with high byte of divisor
+ rla ; Sign of quotient goes into the carry
+ ld a, h ; Get high byte of dividend
+ push af ; Save sign of both quotient and reminder
+
+ ; Take absolute value of dividend
+ rla
+ jr NC, .chkde ; Jump if dividend is positive
+ sub a, a ; Substract dividend from 0
+ sub a, l
+ ld l, a
+ sbc a, a ; Propagate borrow (A=0xFF if borrow)
+ sub a, h
+ ld h, a
+
+ ; Take absolute value of divisor
+.chkde:
+ bit 7, d
+ jr Z, .dodiv ; Jump if divisor is positive
+ sub a, a ; Subtract divisor from 0
+ sub a, e
+ ld e, a
+ sbc a, a ; Propagate borrow (A=0xFF if borrow)
+ sub a, d
+ ld d, a
+
+ ; Divide absolute values
+.dodiv:
+ call __divu16
+
+.fix_quotient:
+ ; Negate quotient if it is negative
+ pop af ; recover sign of quotient
+ ret NC ; Jump if quotient is positive
+ ld b, a
+ sub a, a ; Subtract quotient from 0
+ sub a, e
+ ld e, a
+ sbc a, a ; Propagate borrow (A=0xFF if borrow)
+ sub a, d
+ ld d, a
+ ld a, b
+ ret
+
+__get_remainder::
+ ; Negate remainder if it is negative.
+ rla
+ ex de, hl
+ ret NC ; Return if remainder is positive
+ sub a, a ; Subtract quotient from 0
+ sub a, e
+ ld e, a
+ sbc a, a ; Propagate borrow (A=0xFF if borrow)
+ sub a, d
+ ld d, a
+ ret
+
diff --git a/gbdk/gbdk-lib/libc/asm/z80/divunsigned.s b/gbdk/gbdk-lib/libc/asm/z80/divunsigned.s
new file mode 100644
index 00000000..92e46fcc
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/asm/z80/divunsigned.s
@@ -0,0 +1,131 @@
+;--------------------------------------------------------------------------
+; divunsigned.s
+;
+; Copyright (C) 2000-2021, Michael Hope, Philipp Klaus Krause, Marco Bodrato
+;
+; This library is free software; you can redistribute it and/or modify it
+; under the terms of the GNU General Public License as published by the
+; Free Software Foundation; either version 2, or (at your option) any
+; later version.
+;
+; This library is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this library; see the file COPYING. If not, write to the
+; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+; MA 02110-1301, USA.
+;
+; As a special exception, if you link this library with other files,
+; some of which are compiled with SDCC, to produce an executable,
+; this library does not by itself cause the resulting executable to
+; be covered by the GNU General Public License. This exception does
+; not however invalidate any other reasons why the executable file
+; might be covered by the GNU General Public License.
+;--------------------------------------------------------------------------
+
+ ;; Originally from GBDK by Pascal Felber.
+
+.area _CODE
+
+.globl __divuint
+.globl __divuchar
+
+
+__divuchar:
+ ld e, l
+ ld l, a
+
+ ;; Fall through
+__divu8::
+ ld h,#0x00
+ ld d,h
+ ; Fall through to __divu16
+
+ ;; unsigned 16-bit division
+ ;;
+ ;; Entry conditions
+ ;; HL = dividend
+ ;; DE = divisor
+ ;;
+ ;; Exit conditions
+ ;; DE = quotient
+ ;; HL = remainder
+ ;; carry = 0
+ ;; If divisor is 0, quotient is set to "infinity", i.e HL = 0xFFFF.
+ ;;
+ ;; Register used: AF,B,DE,HL
+__divuint:
+__divu16::
+ ;; Two algorithms: one assumes divisor <2^7, the second
+ ;; assumes divisor >=2^7; choose the applicable one.
+ ld a,e
+ and a,#0x80
+ or a,d
+ jr NZ,.morethan7bits
+ ;; Both algorithms "rotate" 24 bits (H,L,A) but roles change.
+
+ ;; unsigned 16/7-bit division
+.atmost7bits:
+ ld b,#16 ; bits in dividend and possible quotient
+ ;; Carry cleared by AND/OR, this "0" bit will pass trough HL.[*]
+ adc hl,hl
+.dvloop7:
+ ;; HL holds both dividend and quotient. While we shift a bit from
+ ;; MSB of dividend, we shift next bit of quotient in from carry.
+ ;; A holds remainder.
+ rla
+
+ ;; If remainder is >= divisor, next bit of quotient is 1. We try
+ ;; to compute the difference.
+ sub a,e
+ jr NC,.nodrop7 ; Jump if remainder is >= dividend
+ add a,e ; Otherwise, restore remainder
+ ;; The add above sets the carry, because sbc a,e did set it.
+.nodrop7:
+ ccf ; Complement borrow so 1 indicates a
+ ; successful substraction (this is the
+ ; next bit of quotient)
+ adc hl,hl
+ djnz .dvloop7
+ ;; Carry now contains the same value it contained before
+ ;; entering .dvloop7[*]: "0" = valid result.
+ ld e,a ; DE = remainder, HL = quotient
+ ex de, hl
+ ret
+
+.morethan7bits:
+ ld b,#9 ; at most 9 bits in quotient.
+ ld a,l ; precompute the first 7 shifts, by
+ ld l,h ; doing 8
+ ld h,#0
+ rr l ; undoing 1
+.dvloop:
+ ;; Shift next bit of quotient into bit 0 of dividend
+ ;; Shift next MSB of dividend into LSB of remainder
+ ;; A holds both dividend and quotient. While we shift a bit from
+ ;; MSB of dividend, we shift next bit of quotient in from carry
+ ;; HL holds remainder
+ adc hl,hl ; HL < 2^(7+9), no carry, ever.
+
+ ;; If remainder is >= divisor, next bit of quotient is 1. We try
+ ;; to compute the difference.
+ sbc hl,de
+ jr NC,.nodrop ; Jump if remainder is >= dividend
+ add hl,de ; Otherwise, restore remainder
+ ;; The add above sets the carry, because sbc hl,de did set it.
+.nodrop:
+ ccf ; Complement borrow so 1 indicates a
+ ; successful substraction (this is the
+ ; next bit of quotient)
+ rla
+ djnz .dvloop
+ ;; Take care of the ninth quotient bit! after the loop B=0.
+ rl b ; BA = quotient
+ ;; Carry now contains "0" = valid result.
+ ld d,b
+ ld e,a ; DE = quotient, HL = remainder
+ ret
+
diff --git a/gbdk/gbdk-lib/libc/asm/z80/memcmp.s b/gbdk/gbdk-lib/libc/asm/z80/memcmp.s
new file mode 100644
index 00000000..7497e86d
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/asm/z80/memcmp.s
@@ -0,0 +1,38 @@
+ .module strcmp
+
+ .area _HOME
+
+; int memcmp(const void *buf1, const void *buf2, size_t count)
+_memcmp::
+ pop hl
+ pop de
+ pop bc
+ ex (sp), hl
+ ex de, hl
+
+ inc d
+ inc e
+ jr 3$
+
+1$:
+ ld a,(bc)
+ sub (hl) ; s1[i]==s2[i]?
+ jr nz, 2$ ; -> Different
+
+ inc bc
+ inc hl
+3$:
+ dec e
+ jr nz, 1$
+ dec d
+ jr nz, 1$
+
+ ld hl, #0
+ ret
+
+2$:
+ ld hl,#1
+ ret c
+
+ ld hl,#-1
+ ret \ No newline at end of file
diff --git a/gbdk/gbdk-lib/libc/asm/z80/memcpy.s b/gbdk/gbdk-lib/libc/asm/z80/memcpy.s
new file mode 100644
index 00000000..5945e3a5
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/asm/z80/memcpy.s
@@ -0,0 +1,49 @@
+;--------------------------------------------------------------------------
+; memcpy.s
+;
+; Copyright (C) 2020, Sergey Belyashov
+; Copyright (c) 2021, Philipp Klaus Krause
+;
+; This library is free software; you can redistribute it and/or modify it
+; under the terms of the GNU General Public License as published by the
+; Free Software Foundation; either version 2, or (at your option) any
+; later version.
+;
+; This library is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this library; see the file COPYING. If not, write to the
+; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+; MA 02110-1301, USA.
+;
+; As a special exception, if you link this library with other files,
+; some of which are compiled with SDCC, to produce an executable,
+; this library does not by itself cause the resulting executable to
+; be covered by the GNU General Public License. This exception does
+; not however invalidate any other reasons why the executable file
+; might be covered by the GNU General Public License.
+;--------------------------------------------------------------------------
+
+ .area _CODE
+
+ .globl _memcpy
+ .globl ___memcpy
+
+; The Z80 has the ldir instruction, which is perfect for implementing memcpy().
+_memcpy:
+___memcpy:
+ ex de, hl
+ pop iy
+ pop bc
+ ld a, c
+ or a, b
+ jr Z, end
+ push de
+ ldir
+ pop de
+end:
+ jp (iy)
+
diff --git a/gbdk/gbdk-lib/libc/asm/z80/memmove.s b/gbdk/gbdk-lib/libc/asm/z80/memmove.s
new file mode 100644
index 00000000..0e03e958
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/asm/z80/memmove.s
@@ -0,0 +1,65 @@
+;--------------------------------------------------------------------------
+; memmove.s
+;
+; Copyright (C) 2008-2009, Philipp Klaus Krause, Marco Bodrato
+;
+; This library is free software; you can redistribute it and/or modify it
+; under the terms of the GNU General Public License as published by the
+; Free Software Foundation; either version 2, or (at your option) any
+; later version.
+;
+; This library is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this library; see the file COPYING. If not, write to the
+; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+; MA 02110-1301, USA.
+;
+; As a special exception, if you link this library with other files,
+; some of which are compiled with SDCC, to produce an executable,
+; this library does not by itself cause the resulting executable to
+; be covered by the GNU General Public License. This exception does
+; not however invalidate any other reasons why the executable file
+; might be covered by the GNU General Public License.
+;--------------------------------------------------------------------------
+
+ .area _CODE
+
+ .globl _memmove
+
+; The Z80 has the ldir and lddr instructions, which are perfect for implementing memmove().
+
+_memmove:
+ pop af
+ pop hl
+ pop de
+ pop bc
+ push bc
+ push de
+ push hl
+ push af
+ ld a, c
+ or a, b
+ ret Z
+ push hl
+ sbc hl, de ; or above cleared carry.
+ add hl, de ; same carry as the line before
+ jr C, memmove_up
+memmove_down:
+ dec bc
+ add hl, bc
+ ex de, hl
+ add hl, bc
+ inc bc
+ lddr
+ pop hl
+ ret
+memmove_up:
+ ex de, hl
+ ldir
+ pop hl
+ ret
+
diff --git a/gbdk/gbdk-lib/libc/asm/z80/memset.s b/gbdk/gbdk-lib/libc/asm/z80/memset.s
new file mode 100644
index 00000000..ce48480b
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/asm/z80/memset.s
@@ -0,0 +1,30 @@
+ .area _CODE
+
+;; void *memset (void *s, int c, size_t n) __z88dk_callee;
+_memset::
+ pop af
+ pop hl
+ pop de
+ pop bc
+ push af
+
+ ld a, b
+ or c
+ ret z
+
+ ld (hl), e
+ dec bc
+
+ ld a, b
+ or c
+ ret z
+
+ push hl
+ ld d, h
+ ld e, l
+ inc de
+
+ ldir
+ pop hl
+ ret
+
diff --git a/gbdk/gbdk-lib/libc/asm/z80/modmixed.s b/gbdk/gbdk-lib/libc/asm/z80/modmixed.s
new file mode 100644
index 00000000..f940662a
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/asm/z80/modmixed.s
@@ -0,0 +1,53 @@
+;--------------------------------------------------------------------------
+; modmixed.s
+;
+; Copyright (C) 2010-2021, Philipp Klaus Krause
+;
+; This library is free software; you can redistribute it and/or modify it
+; under the terms of the GNU General Public License as published by the
+; Free Software Foundation; either version 2, or (at your option) any
+; later version.
+;
+; This library is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this library; see the file COPYING. If not, write to the
+; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+; MA 02110-1301, USA.
+;
+; As a special exception, if you link this library with other files,
+; some of which are compiled with SDCC, to produce an executable,
+; this library does not by itself cause the resulting executable to
+; be covered by the GNU General Public License. This exception does
+; not however invalidate any other reasons why the executable file
+; might be covered by the GNU General Public License.
+;--------------------------------------------------------------------------
+
+.globl __modsuchar
+.globl __moduschar
+
+__modsuchar:
+ ld e, l
+ ld l, a
+ ld h, #0
+
+ call __div_signexte
+
+ jp __get_remainder
+
+__moduschar:
+ ld e, l
+ ld d, #0
+ ld l, a
+
+ rlca ; Sign extend
+ sbc a, a
+ ld h, a
+
+ call __div16
+
+ jp __get_remainder
+
diff --git a/gbdk/gbdk-lib/libc/asm/z80/modsigned.s b/gbdk/gbdk-lib/libc/asm/z80/modsigned.s
new file mode 100644
index 00000000..70c0a076
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/asm/z80/modsigned.s
@@ -0,0 +1,46 @@
+;--------------------------------------------------------------------------
+; modsigned.s
+;
+; Copyright (C) 2009-2021, Philipp Klaus Krause
+;
+; This library is free software; you can redistribute it and/or modify it
+; under the terms of the GNU General Public License as published by the
+; Free Software Foundation; either version 2, or (at your option) any
+; later version.
+;
+; This library is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this library; see the file COPYING. If not, write to the
+; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+; MA 02110-1301, USA.
+;
+; As a special exception, if you link this library with other files,
+; some of which are compiled with SDCC, to produce an executable,
+; this library does not by itself cause the resulting executable to
+; be covered by the GNU General Public License. This exception does
+; not however invalidate any other reasons why the executable file
+; might be covered by the GNU General Public License.
+;--------------------------------------------------------------------------
+
+.area _CODE
+
+.globl __modschar
+.globl __modsint
+
+__modschar:
+ ld e, l
+ ld l, a
+
+ call __div8
+
+ jp __get_remainder
+
+__modsint:
+ call __div16
+
+ jp __get_remainder
+
diff --git a/gbdk/gbdk-lib/libc/asm/z80/modunsigned.s b/gbdk/gbdk-lib/libc/asm/z80/modunsigned.s
new file mode 100644
index 00000000..83a984a6
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/asm/z80/modunsigned.s
@@ -0,0 +1,46 @@
+;--------------------------------------------------------------------------
+; modunsigned.s
+;
+; Copyright (C) 2009-2010, Philipp Klaus Krause
+;
+; This library is free software; you can redistribute it and/or modify it
+; under the terms of the GNU General Public License as published by the
+; Free Software Foundation; either version 2, or (at your option) any
+; later version.
+;
+; This library is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this library; see the file COPYING. If not, write to the
+; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+; MA 02110-1301, USA.
+;
+; As a special exception, if you link this library with other files,
+; some of which are compiled with SDCC, to produce an executable,
+; this library does not by itself cause the resulting executable to
+; be covered by the GNU General Public License. This exception does
+; not however invalidate any other reasons why the executable file
+; might be covered by the GNU General Public License.
+;--------------------------------------------------------------------------
+
+.area _CODE
+
+.globl __moduchar
+.globl __moduint
+
+__moduchar:
+ ld e, l
+ ld l, a
+
+ call __divu8
+ ex de, hl
+ ret
+
+__moduint:
+ call __divu16
+ ex de, hl
+ ret
+
diff --git a/gbdk/gbdk-lib/libc/asm/z80/mul.s b/gbdk/gbdk-lib/libc/asm/z80/mul.s
new file mode 100644
index 00000000..a5895d3c
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/asm/z80/mul.s
@@ -0,0 +1,72 @@
+;--------------------------------------------------------------------------
+; mul.s
+;
+; Copyright (C) 2000, Michael Hope
+; Copyright (C) 2021, Philipp Klaus Krause
+;
+; This library is free software; you can redistribute it and/or modify it
+; under the terms of the GNU General Public License as published by the
+; Free Software Foundation; either version 2, or (at your option) any
+; later version.
+;
+; This library is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this library; see the file COPYING. If not, write to the
+; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+; MA 02110-1301, USA.
+;
+; As a special exception, if you link this library with other files,
+; some of which are compiled with SDCC, to produce an executable,
+; this library does not by itself cause the resulting executable to
+; be covered by the GNU General Public License. This exception does
+; not however invalidate any other reasons why the executable file
+; might be covered by the GNU General Public License.
+;--------------------------------------------------------------------------
+
+.area _CODE
+
+.globl __mulint
+
+__mulint:
+ ld c, l
+ ld b, h
+
+ ;; 16-bit multiplication
+ ;;
+ ;; Entry conditions
+ ;; bc = multiplicand
+ ;; de = multiplier
+ ;;
+ ;; Exit conditions
+ ;; de = less significant word of product
+ ;;
+ ;; Register used: AF,BC,DE,HL
+__mul16::
+ xor a,a
+ ld l,a
+ or a,b
+ ld b,#16
+
+ ;; Optimise for the case when this side has 8 bits of data or
+ ;; less. This is often the case with support address calls.
+ jr NZ,2$
+ ld b,#8
+ ld a,c
+1$:
+ ;; Taken from z88dk, which originally borrowed from the
+ ;; Spectrum rom.
+ add hl,hl
+2$:
+ rl c
+ rla ;DLE 27/11/98
+ jr NC,3$
+ add hl,de
+3$:
+ djnz 1$
+ ex de, hl
+ ret
+
diff --git a/gbdk/gbdk-lib/libc/asm/z80/mulchar.s b/gbdk/gbdk-lib/libc/asm/z80/mulchar.s
new file mode 100644
index 00000000..9398dc93
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/asm/z80/mulchar.s
@@ -0,0 +1,68 @@
+;--------------------------------------------------------------------------
+; mulchar.s
+;
+; Copyright (c) 2017-2021, Philipp Klaus Krause
+;
+; This library is free software; you can redistribute it and/or modify it
+; under the terms of the GNU General Public License as published by the
+; Free Software Foundation; either version 2, or (at your option) any
+; later version.
+;
+; This library is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this library; see the file COPYING. If not, write to the
+; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+; MA 02110-1301, USA.
+;
+; As a special exception, if you link this library with other files,
+; some of which are compiled with SDCC, to produce an executable,
+; this library does not by itself cause the resulting executable to
+; be covered by the GNU General Public License. This exception does
+; not however invalidate any other reasons why the executable file
+; might be covered by the GNU General Public License.
+;--------------------------------------------------------------------------
+
+.area _CODE
+
+; unsigned char x unsigned char multiplication is done by code generation.
+
+.globl __mulsuchar
+.globl __muluschar
+.globl __mulschar
+
+; operands have different sign
+
+__muluschar:
+ ld e, a
+ ld c, l
+ ld b, #0
+
+ jr signexte
+
+__mulsuchar:
+ ld c, a
+ ld b, #0
+ ld e, l
+
+ jr signexte
+
+__mulschar:
+ ld e, l
+ ld c, a
+
+ ;; Need to sign extend before going in.
+ rla
+ sbc a, a
+ ld b, a
+signexte:
+ ld a, e
+ rla
+ sbc a, a
+ ld d, a
+
+ jp __mul16
+
diff --git a/gbdk/gbdk-lib/libc/asm/z80/rand.s b/gbdk/gbdk-lib/libc/asm/z80/rand.s
new file mode 100644
index 00000000..1edbcf27
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/asm/z80/rand.s
@@ -0,0 +1,52 @@
+ .module Random
+
+ .area _DATA
+
+___rand_seed::
+.randval:
+ .ds 0x02
+
+ .area _CODE
+
+_rand::
+_randw::
+
+ LD HL, (.randval)
+ EX DE, HL
+ LD L, E
+ LD A, D
+
+ SLA L ; * 16
+ RLA
+ SLA L
+ RLA
+ SLA L
+ RLA
+ SLA L
+ RLA
+ LD H, A ; Save randhi*16
+
+ LD A, E ; Old randlo
+ ADD A, L ; Add randlo*16
+ LD L, A ; Save randlo*17
+
+ LD A, H ; randhi*16
+ ADC A, D ; Add old randhi
+ LD H, A ; Save randhi*17
+
+ LD A, L ; randlo*17
+ ADD A, #0x93
+ LD L, A
+ LD A, H ; randhi*17
+ ADC A, #0x5c
+ LD H, A
+ LD (.randval), HL
+ LD H, L
+ LD L, A
+
+ RET
+
+_initrand:: ; Non banked
+.initrand::
+ LD (.randval), HL
+ RET
diff --git a/gbdk/gbdk-lib/libc/asm/z80/setjmp.s b/gbdk/gbdk-lib/libc/asm/z80/setjmp.s
new file mode 100644
index 00000000..3cc2bfb6
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/asm/z80/setjmp.s
@@ -0,0 +1,95 @@
+;--------------------------------------------------------------------------
+; setjmp.s
+;
+; Copyright (C) 2011-2014, Philipp Klaus Krause
+;
+; This library is free software; you can redistribute it and/or modify it
+; under the terms of the GNU General Public License as published by the
+; Free Software Foundation; either version 2, or (at your option) any
+; later version.
+;
+; This library is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this library; see the file COPYING. If not, write to the
+; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+; MA 02110-1301, USA.
+;
+; As a special exception, if you link this library with other files,
+; some of which are compiled with SDCC, to produce an executable,
+; this library does not by itself cause the resulting executable to
+; be covered by the GNU General Public License. This exception does
+; not however invalidate any other reasons why the executable file
+; might be covered by the GNU General Public License.
+;--------------------------------------------------------------------------
+
+ .area _CODE
+
+ .globl ___setjmp
+
+___setjmp:
+ pop hl
+ pop iy
+ push af
+ push hl
+
+ ; Store return address.
+ ld 0(iy), l
+ ld 1(iy), h
+
+ ; Store stack pointer.
+ xor a, a
+ ld l, a
+ ld h, a
+ add hl, sp
+ ld 2(iy), l
+ ld 3(iy), h
+
+ ; Store frame pointer.
+ push ix
+ pop hl
+ ld 4(iy), l
+ ld 5(iy), h
+
+ ; Return 0.
+ ld l, a
+ ld h, a
+ ret
+
+.globl _longjmp
+
+_longjmp:
+ pop af
+ pop iy
+ pop de
+
+ ; Ensure that return value is non-zero.
+ ld a, e
+ or a, d
+ jr NZ, jump
+ inc de
+jump:
+
+ ; Restore frame pointer.
+ ld l, 4(iy)
+ ld h, 5(iy)
+ push hl
+ pop ix
+
+ ; Adjust stack pointer.
+ ld l, 2(iy)
+ ld h, 3(iy)
+ ld sp, hl
+ pop hl
+
+ ; Move return value into hl.
+ ex de, hl
+
+ ; Jump.
+ ld c, 0(iy)
+ ld b, 1(iy)
+ push bc
+ ret
diff --git a/gbdk/gbdk-lib/libc/asm/z80/strcpy.s b/gbdk/gbdk-lib/libc/asm/z80/strcpy.s
new file mode 100644
index 00000000..933f41b0
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/asm/z80/strcpy.s
@@ -0,0 +1,48 @@
+;--------------------------------------------------------------------------
+; strcpy.s
+;
+; Copyright (C) 2012, Philipp Klaus Krause
+;
+; This library is free software; you can redistribute it and/or modify it
+; under the terms of the GNU General Public License as published by the
+; Free Software Foundation; either version 2, or (at your option) any
+; later version.
+;
+; This library is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this library; see the file COPYING. If not, write to the
+; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+; MA 02110-1301, USA.
+;
+; As a special exception, if you link this library with other files,
+; some of which are compiled with SDCC, to produce an executable,
+; this library does not by itself cause the resulting executable to
+; be covered by the GNU General Public License. This exception does
+; not however invalidate any other reasons why the executable file
+; might be covered by the GNU General Public License.
+;--------------------------------------------------------------------------
+
+ .area _CODE
+
+ .globl _strcpy
+
+_strcpy:
+ pop bc
+ pop de
+ pop hl
+ push hl
+ push de
+ push bc
+ push de
+ xor a, a
+loop:
+ cp a, (hl)
+ ldi
+ jr NZ, loop
+ pop hl
+ ret
+
diff --git a/gbdk/gbdk-lib/libc/asm/z80/strlen.s b/gbdk/gbdk-lib/libc/asm/z80/strlen.s
new file mode 100644
index 00000000..64f37da5
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/asm/z80/strlen.s
@@ -0,0 +1,47 @@
+;--------------------------------------------------------------------------
+; strlen.s
+;
+; Copyright (C) 2008-2009, Philipp Klaus Krause
+;
+; This library is free software; you can redistribute it and/or modify it
+; under the terms of the GNU General Public License as published by the
+; Free Software Foundation; either version 2, or (at your option) any
+; later version.
+;
+; This library is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this library; see the file COPYING. If not, write to the
+; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+; MA 02110-1301, USA.
+;
+; As a special exception, if you link this library with other files,
+; some of which are compiled with SDCC, to produce an executable,
+; this library does not by itself cause the resulting executable to
+; be covered by the GNU General Public License. This exception does
+; not however invalidate any other reasons why the executable file
+; might be covered by the GNU General Public License.
+;--------------------------------------------------------------------------
+
+ .area _CODE
+
+ .globl _strlen
+
+; The Z80 has the cpir instruction, which is perfect for implementing strlen().
+
+_strlen:
+ pop bc
+ pop hl
+ push hl
+ push bc
+ xor a, a
+ ld b, a
+ ld c, a
+ cpir
+ ld hl, #-1
+ sbc hl, bc ; C flag still cleared from xor above.
+ ret
+
diff --git a/gbdk/gbdk-lib/libc/atoi.c b/gbdk/gbdk-lib/libc/atoi.c
new file mode 100644
index 00000000..a363baac
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/atoi.c
@@ -0,0 +1,31 @@
+#include <stdint.h>
+#include <stdlib.h>
+#include <types.h>
+#include <ctype.h>
+
+inline bool _isdigit(char c) {
+ return ((uint8_t)((uint8_t)c - '0') < 10u) ? true : false;
+}
+
+int atoi(const char *s) NONBANKED
+{
+ bool sign = false;
+ int n;
+
+ const uint8_t * pc = (const uint8_t *)s;
+
+ for(; ((*pc == ' ') || (*pc == '\t') || (*pc == '\n')); ++pc);
+
+ switch(*pc) {
+ case '-':
+ sign = true;
+ /* and fall through */
+ case '+':
+ ++pc;
+ break;
+ }
+
+ for(n = 0; _isdigit(*pc); ++pc) n = 10 * n + (*pc - '0');
+
+ return (sign == 0 ? n : -n);
+}
diff --git a/gbdk/gbdk-lib/libc/atol.c b/gbdk/gbdk-lib/libc/atol.c
new file mode 100644
index 00000000..16114378
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/atol.c
@@ -0,0 +1,28 @@
+#include <stdint.h>
+#include <stdbool.h>
+
+inline bool _isdigit(char c) {
+ return ((uint8_t)((uint8_t)c - '0') < 10u) ? true : false;
+}
+
+long atol(const char *s) {
+ bool sign = false;
+ long n;
+
+ const uint8_t * pc = (const uint8_t *)s;
+
+ for(; ((*pc == ' ') || (*pc == '\t') || (*pc == '\n')); ++pc);
+
+ switch(*pc) {
+ case '-':
+ sign = true;
+ /* and fall through */
+ case '+':
+ ++pc;
+ break;
+ }
+
+ for(n = 0; _isdigit(*pc); ++pc) n = 10 * n + (*pc - '0');
+
+ return (sign == 0 ? n : -n);
+}
diff --git a/gbdk/gbdk-lib/libc/atomic_flag_clear.c b/gbdk/gbdk-lib/libc/atomic_flag_clear.c
new file mode 100644
index 00000000..4fc820c3
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/atomic_flag_clear.c
@@ -0,0 +1,41 @@
+/*-------------------------------------------------------------------------
+ atomic_flag_clear.c
+
+ Philipp Klaus Krause, pkk@spth.de 2020
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to the
+ Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+ As a special exception, if you link this library with other files,
+ some of which are compiled with SDCC, to produce an executable,
+ this library does not by itself cause the resulting executable to
+ be covered by the GNU General Public License. This exception does
+ not however invalidate any other reasons why the executable file
+ might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
+
+#include <stdatomic.h>
+
+void atomic_flag_clear(volatile atomic_flag *object)
+{
+#if defined(__SDCC_z80) || defined(__SDCC_z180) || defined(__SDCC_ez80_z80) || defined(__SDCC_sm83) || defined(__SDCC_r2k) || defined(__SDCC_r3ka) || defined(__SDCC_stm8) || defined(__SDCC_hc08) || defined(__SDCC_s08)
+ object->flag = 1;
+#elif defined(__SDCC_mcs51)
+ object->flag = 0;
+#else
+#error Support for atomic_flag not implemented
+#endif
+}
+
diff --git a/gbdk/gbdk-lib/libc/bsearch.c b/gbdk/gbdk-lib/libc/bsearch.c
new file mode 100644
index 00000000..3529796d
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/bsearch.c
@@ -0,0 +1,51 @@
+/*---------------------------------------------------------------------
+ bsearch() - search a sorted array
+
+ Copyright (C) 2018, Philipp Klaus Krause . pkk@spth.de
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to the
+ Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+ As a special exception, if you link this library with other files,
+ some of which are compiled with SDCC, to produce an executable,
+ this library does not by itself cause the resulting executable to
+ be covered by the GNU General Public License. This exception does
+ not however invalidate any other reasons why the executable file
+ might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
+
+#include <stdlib.h>
+
+void *bsearch(const void *key, const void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *) __reentrant)
+{
+ for(const char *left = base; nmemb;)
+ {
+ const char *middle = left + nmemb / 2 * size;
+ int c = (*compar)(key, middle);
+
+ if(c < 0)
+ nmemb = nmemb / 2;
+ else if(c > 0)
+ {
+ left = middle + size;
+ nmemb = (nmemb - 1) / 2;
+ }
+ else
+ return(middle);
+ }
+
+ return(0);
+}
+
diff --git a/gbdk/gbdk-lib/libc/calloc.c b/gbdk/gbdk-lib/libc/calloc.c
new file mode 100644
index 00000000..a5cab07c
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/calloc.c
@@ -0,0 +1,62 @@
+/*-------------------------------------------------------------------------
+ calloc.c - allocate memory.
+
+ Copyright (C) 2015, Philipp Klaus Krause, pkk@spth.de
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to the
+ Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+ As a special exception, if you link this library with other files,
+ some of which are compiled with SDCC, to produce an executable,
+ this library does not by itself cause the resulting executable to
+ be covered by the GNU General Public License. This exception does
+ not however invalidate any other reasons why the executable file
+ might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdint.h>
+
+#if defined(__SDCC_mcs51) || defined(__SDCC_ds390) || defined(__SDCC_ds400)
+#define HEAPSPACE __xdata
+#elif defined(__SDCC_pdk13) || defined(__SDCC_pdk14) || defined(__SDCC_pdk15)
+#define HEAPSPACE __near
+#else
+#define HEAPSPACE
+#endif
+
+#if defined(__SDCC_mcs51) || defined(__SDCC_ds390) || defined(__SDCC_ds400)
+void HEAPSPACE *calloc (size_t nmemb, size_t size)
+#else
+void *calloc (size_t nmemb, size_t size)
+#endif
+{
+ void HEAPSPACE *ptr;
+
+ unsigned long msize = (unsigned long)nmemb * (unsigned long)size;
+
+ _Static_assert(sizeof(unsigned long) >= sizeof(size_t) * 2,
+ "size_t too large wrt. unsigned long for overflow check");
+
+ if (msize > SIZE_MAX)
+ return(0);
+
+ if (ptr = malloc(msize))
+ memset(ptr, 0, msize);
+
+ return(ptr);
+}
+
diff --git a/gbdk/gbdk-lib/libc/free.c b/gbdk/gbdk-lib/libc/free.c
new file mode 100644
index 00000000..bf1fdcd2
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/free.c
@@ -0,0 +1,80 @@
+/*-------------------------------------------------------------------------
+ free.c - deallocate memory.
+
+ Copyright (C) 2015, Philipp Klaus Krause, pkk@spth.de
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to the
+ Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+ As a special exception, if you link this library with other files,
+ some of which are compiled with SDCC, to produce an executable,
+ this library does not by itself cause the resulting executable to
+ be covered by the GNU General Public License. This exception does
+ not however invalidate any other reasons why the executable file
+ might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
+
+#include <stdlib.h>
+#include <stddef.h>
+
+#if defined(__SDCC_mcs51) || defined(__SDCC_ds390) || defined(__SDCC_ds400)
+#define HEAPSPACE __xdata
+#elif defined(__SDCC_pdk13) || defined(__SDCC_pdk14) || defined(__SDCC_pdk15)
+#define HEAPSPACE __near
+#else
+#define HEAPSPACE
+#endif
+
+typedef struct header HEAPSPACE header_t;
+
+struct header
+{
+ header_t *next;
+ header_t *next_free;
+};
+
+extern header_t *HEAPSPACE __sdcc_heap_free;
+
+void free(void *ptr)
+{
+ header_t *h, *next_free, *prev_free;
+ header_t *HEAPSPACE *f;
+
+ if(!ptr)
+ return;
+
+ prev_free = 0;
+ for(h = __sdcc_heap_free, f = &__sdcc_heap_free; h && h < ptr; prev_free = h, f = &(h->next_free), h = h->next_free); // Find adjacent blocks in free list
+ next_free = h;
+
+ h = (void HEAPSPACE *)((char HEAPSPACE *)(ptr) - offsetof(struct header, next_free));
+
+ // Insert into free list.
+ h->next_free = next_free;
+ *f = h;
+
+ if(next_free == h->next) // Merge with next block
+ {
+ h->next_free = h->next->next_free;
+ h->next = h->next->next;
+ }
+
+ if (prev_free && prev_free->next == h) // Merge with previous block
+ {
+ prev_free->next = h->next;
+ prev_free->next_free = h->next_free;
+ }
+}
+
diff --git a/gbdk/gbdk-lib/libc/isalpha.c b/gbdk/gbdk-lib/libc/isalpha.c
new file mode 100644
index 00000000..04ab5f3a
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/isalpha.c
@@ -0,0 +1,7 @@
+#include <ctype.h>
+#include <stdbool.h>
+#include <stdint.h>
+
+bool isalpha(char c) {
+ return ((((uint8_t)((uint8_t)c - 'a') < ('z' - 'a' + 1))) || ((uint8_t)((uint8_t)c - 'A') < ('Z' - 'A' + 1))) ? true : false;
+}
diff --git a/gbdk/gbdk-lib/libc/isdigit.c b/gbdk/gbdk-lib/libc/isdigit.c
new file mode 100644
index 00000000..73e9ef61
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/isdigit.c
@@ -0,0 +1,7 @@
+#include <ctype.h>
+#include <stdbool.h>
+#include <stdint.h>
+
+bool isdigit(char c) {
+ return ((uint8_t)((uint8_t)c - '0') < 10u) ? true : false;
+}
diff --git a/gbdk/gbdk-lib/libc/islower.c b/gbdk/gbdk-lib/libc/islower.c
new file mode 100644
index 00000000..a3165f9f
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/islower.c
@@ -0,0 +1,7 @@
+#include <ctype.h>
+#include <stdbool.h>
+#include <stdint.h>
+
+bool islower(char c) {
+ return ((uint8_t)((uint8_t)c - 'a') < ('z' - 'a' + 1)) ? true : false;
+}
diff --git a/gbdk/gbdk-lib/libc/isspace.c b/gbdk/gbdk-lib/libc/isspace.c
new file mode 100644
index 00000000..cbb0dce2
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/isspace.c
@@ -0,0 +1,7 @@
+#include <ctype.h>
+#include <stdbool.h>
+#include <stdint.h>
+
+bool isspace(char c) {
+ return (((uint8_t)c == ' ') || ((uint8_t)c == '\t') || ((uint8_t)c == '\n')) ? true : false;
+}
diff --git a/gbdk/gbdk-lib/libc/isupper.c b/gbdk/gbdk-lib/libc/isupper.c
new file mode 100644
index 00000000..75fe33bf
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/isupper.c
@@ -0,0 +1,7 @@
+#include <ctype.h>
+#include <stdbool.h>
+#include <stdint.h>
+
+bool isupper(char c) {
+ return ((uint8_t)((uint8_t)c - 'A') < ('Z' - 'A' + 1)) ? true : false;
+}
diff --git a/gbdk/gbdk-lib/libc/malloc.c b/gbdk/gbdk-lib/libc/malloc.c
new file mode 100644
index 00000000..965e47dd
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/malloc.c
@@ -0,0 +1,114 @@
+/*-------------------------------------------------------------------------
+ malloc.c - allocate memory.
+
+ Copyright (C) 2015, Philipp Klaus Krause, pkk@spth.de
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to the
+ Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+ As a special exception, if you link this library with other files,
+ some of which are compiled with SDCC, to produce an executable,
+ this library does not by itself cause the resulting executable to
+ be covered by the GNU General Public License. This exception does
+ not however invalidate any other reasons why the executable file
+ might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
+
+#include <stdlib.h>
+#include <stddef.h>
+
+#if defined(__SDCC_mcs51) || defined(__SDCC_ds390) || defined(__SDCC_ds400)
+#define HEAPSPACE __xdata
+#elif defined(__SDCC_pdk13) || defined(__SDCC_pdk14) || defined(__SDCC_pdk15)
+#define HEAPSPACE __near
+#else
+#define HEAPSPACE
+#endif
+
+typedef struct header HEAPSPACE header_t;
+
+struct header
+{
+ header_t *next; // Next block. Linked list of all blocks, terminated by pointer to end of heap (or to the byte beyond the end of the heap).
+ header_t *next_free; // Next free block. Used in free blocks only. Overlaps with user data in non-free blocks. Linked list of free blocks, 0-terminated.
+};
+
+header_t *HEAPSPACE __sdcc_heap_free; // First free block, 0 if no free blocks.
+
+extern header_t __sdcc_heap;
+#define HEAP_START &__sdcc_heap
+
+#if defined(__SDCC_mcs51) || defined(__SDCC_ds390) || defined(__SDCC_ds400) || defined(__SDCC_hc08) || defined(__SDCC_s08)
+
+extern const unsigned int __sdcc_heap_size;
+#define HEAP_END (struct header HEAPSPACE *)((char HEAPSPACE *)&__sdcc_heap + (__sdcc_heap_size - 1)) // -1 To be sure that HEAP_END is bigger than HEAP_START.
+
+#else
+
+extern header_t __sdcc_heap_end; // Just beyond the end of the heap. Must be higher in memory than _sdcc_heap_start.
+#define HEAP_END &__sdcc_heap_end
+
+#endif
+
+void __sdcc_heap_init(void)
+{
+ __sdcc_heap_free = HEAP_START;
+ __sdcc_heap_free->next = HEAP_END;
+ __sdcc_heap_free->next_free = 0;
+}
+
+#if defined(__SDCC_mcs51) || defined(__SDCC_ds390) || defined(__SDCC_ds400)
+void HEAPSPACE *malloc(size_t size)
+#else
+void *malloc(size_t size)
+#endif
+{
+ header_t *h;
+ header_t *HEAPSPACE *f;
+
+#if defined(__SDCC_mcs51) || defined(__SDCC_ds390) || defined(__SDCC_ds400) || defined(__SDCC_hc08) || defined(__SDCC_s08)
+ if(!__sdcc_heap_free)
+ __sdcc_heap_init();
+#endif
+
+ if(!size || size + offsetof(struct header, next_free) < size)
+ return(0);
+ size += offsetof(struct header, next_free);
+ if(size < sizeof(struct header)) // Requiring a minimum size makes it easier to implement free(), and avoid memory leaks.
+ size = sizeof(struct header);
+
+ for(h = __sdcc_heap_free, f = &__sdcc_heap_free; h; f = &(h->next_free), h = h->next_free)
+ {
+ size_t blocksize = (char HEAPSPACE *)(h->next) - (char HEAPSPACE *)h;
+ if(blocksize >= size) // Found free block of sufficient size.
+ {
+ if(blocksize >= size + sizeof(struct header)) // It is worth creating a new free block
+ {
+ header_t *const newheader = (header_t *const)((char HEAPSPACE *)h + size);
+ newheader->next = h->next;
+ newheader->next_free = h->next_free;
+ *f = newheader;
+ h->next = newheader;
+ }
+ else
+ *f = h->next_free;
+
+ return(&(h->next_free));
+ }
+ }
+
+ return(0);
+}
+
diff --git a/gbdk/gbdk-lib/libc/printf.c b/gbdk/gbdk-lib/libc/printf.c
new file mode 100644
index 00000000..73382cb4
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/printf.c
@@ -0,0 +1,11 @@
+#include <stdio.h>
+#include <stdarg.h>
+
+void __printf(const char *format, void *emitter, char **pData, va_list va);
+
+void printf(const char *format, ...) OLDCALL {
+ va_list va;
+ va_start(va, format);
+
+ __printf(format, (void *)putchar, NULL, va);
+}
diff --git a/gbdk/gbdk-lib/libc/puts.c b/gbdk/gbdk-lib/libc/puts.c
new file mode 100644
index 00000000..1a661338
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/puts.c
@@ -0,0 +1,12 @@
+#include <stdio.h>
+
+extern const char *__crlf;
+
+void puts(const char *s) NONBANKED
+{
+ while (*s)
+ putchar(*s++);
+
+ for (s = __crlf; (*s); )
+ putchar(*s++);
+}
diff --git a/gbdk/gbdk-lib/libc/qsort.c b/gbdk/gbdk-lib/libc/qsort.c
new file mode 100644
index 00000000..b4ac1f87
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/qsort.c
@@ -0,0 +1,61 @@
+/*---------------------------------------------------------------------
+ qsort() - sort an array
+
+ Copyright (C) 2018, Philipp Klaus Krause . krauseph@informatik.uni-freiburg.de
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to the
+ Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+ As a special exception, if you link this library with other files,
+ some of which are compiled with SDCC, to produce an executable,
+ this library does not by itself cause the resulting executable to
+ be covered by the GNU General Public License. This exception does
+ not however invalidate any other reasons why the executable file
+ might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
+
+#include <stdlib.h>
+
+// Despite the name, this is an insertion sort, since it tends to be smaller in code size.
+
+static void swap(void *restrict dst, void *restrict src, size_t n)
+{
+ unsigned char *restrict d = dst;
+ unsigned char *restrict s = src;
+
+ while(n--)
+ {
+ unsigned char tmp = *d;
+ *d = *s;
+ *s = tmp;
+ d++;
+ s++;
+ }
+}
+
+void qsort(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *) __reentrant)
+{
+ unsigned char *b = base;
+
+ if(nmemb <= 1)
+ return;
+
+ for(unsigned char *i = base; i < b + nmemb * size; i += size)
+ {
+ for(unsigned char *j = i; (j > b) && (*compar)(j, j - size) < 0; j -= size)
+ swap(j, j - size, size);
+ }
+}
+
diff --git a/gbdk/gbdk-lib/libc/realloc.c b/gbdk/gbdk-lib/libc/realloc.c
new file mode 100644
index 00000000..41fa4944
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/realloc.c
@@ -0,0 +1,139 @@
+/*-------------------------------------------------------------------------
+ realloc.c - allocate memory.
+
+ Always behaves according to C90 (i.e. does not take advantage of
+ undefined behaviour introduced in C2X or implementation-defined
+ behaviour introduced in C17.
+
+ Copyright (C) 2015-2020, Philipp Klaus Krause, pkk@spth.de
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; see the file COPYING. If not, write to the
+ Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+ As a special exception, if you link this library with other files,
+ some of which are compiled with SDCC, to produce an executable,
+ this library does not by itself cause the resulting executable to
+ be covered by the GNU General Public License. This exception does
+ not however invalidate any other reasons why the executable file
+ might be covered by the GNU General Public License.
+-------------------------------------------------------------------------*/
+
+#include <stdlib.h>
+#include <stddef.h>
+#include <string.h>
+
+#if defined(__SDCC_mcs51) || defined(__SDCC_ds390) || defined(__SDCC_ds400)
+#define HEAPSPACE __xdata
+#elif defined(__SDCC_pdk13) || defined(__SDCC_pdk14) || defined(__SDCC_pdk15)
+#define HEAPSPACE __near
+#else
+#define HEAPSPACE
+#endif
+
+typedef struct header HEAPSPACE header_t;
+
+struct header
+{
+ header_t *next;
+ header_t *next_free;
+};
+
+extern header_t *HEAPSPACE __sdcc_heap_free;
+
+void __sdcc_heap_init(void);
+
+#if defined(__SDCC_mcs51) || defined(__SDCC_ds390) || defined(__SDCC_ds400)
+void HEAPSPACE *realloc(void *ptr, size_t size)
+#else
+void *realloc(void *ptr, size_t size)
+#endif
+{
+ void HEAPSPACE *ret;
+ header_t *h, *next_free, *prev_free;
+ header_t *HEAPSPACE *f, *HEAPSPACE *pf;
+ size_t blocksize, oldblocksize, maxblocksize;
+
+#if defined(__SDCC_mcs51) || defined(__SDCC_ds390) || defined(__SDCC_ds400) || defined(__SDCC_hc08) || defined(__SDCC_s08)
+ if(!__sdcc_heap_free)
+ __sdcc_heap_init();
+#endif
+
+ if(!ptr)
+ return(malloc(size));
+
+ if(!size)
+ {
+ free(ptr);
+ return(0);
+ }
+
+ prev_free = 0, pf = 0;
+ for(h = __sdcc_heap_free, f = &__sdcc_heap_free; h && h < ptr; prev_free = h, pf = f, f = &(h->next_free), h = h->next_free); // Find adjacent blocks in free list
+ next_free = h;
+
+ if(size + offsetof(struct header, next_free) < size) // Handle overflow
+ return(0);
+ blocksize = size + offsetof(struct header, next_free);
+ if(blocksize < sizeof(struct header)) // Requiring a minimum size makes it easier to implement free(), and avoid memory leaks.
+ blocksize = sizeof(struct header);
+
+ h = (void HEAPSPACE *)((char HEAPSPACE *)(ptr) - offsetof(struct header, next_free));
+ oldblocksize = (char HEAPSPACE *)(h->next) - (char HEAPSPACE *)h;
+
+ maxblocksize = oldblocksize;
+ if(prev_free && prev_free->next == h) // Can merge with previous block
+ maxblocksize += (char HEAPSPACE *)h - (char HEAPSPACE *)prev_free;
+ if(next_free == h->next) // Can merge with next block
+ maxblocksize += (char HEAPSPACE *)(next_free->next) - (char HEAPSPACE *)next_free;
+
+ if(blocksize <= maxblocksize) // Can resize in place.
+ {
+ if(prev_free && prev_free->next == h) // Always move into previous block to defragment
+ {
+ memmove(prev_free, h, blocksize <= oldblocksize ? blocksize : oldblocksize);
+ h = prev_free;
+ *pf = next_free;
+ f = pf;
+ }
+
+ if(next_free && next_free == h->next) // Merge with following block
+ {
+ h->next = next_free->next;
+ *f = next_free->next_free;
+ }
+
+ if(maxblocksize >= blocksize + sizeof(struct header)) // Create new block from free space
+ {
+ header_t *const newheader = (header_t *const)((char HEAPSPACE *)h + blocksize);
+ newheader->next = h->next;
+ newheader->next_free = *f;
+ *f = newheader;
+ h->next = newheader;
+ }
+
+ return(&(h->next_free));
+ }
+
+ if(ret = malloc(size))
+ {
+ size_t oldsize = oldblocksize - offsetof(struct header, next_free);
+ memcpy(ret, ptr, size <= oldsize ? size : oldsize);
+ free(ptr);
+ return(ret);
+ }
+
+ return(0);
+}
+
diff --git a/gbdk/gbdk-lib/libc/rules-asxxxx.mk b/gbdk/gbdk-lib/libc/rules-asxxxx.mk
new file mode 100644
index 00000000..eaebb9a2
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/rules-asxxxx.mk
@@ -0,0 +1,18 @@
+$(LIB): pre $(OBJ)
+ for file in $(filter-out %/crt0.o,$(OBJ)) ; do \
+ $(SDAR) -ru $(LIB) $${file} ; \
+ done
+
+pre: set-model build-dir
+
+$(BUILD)/%.o: ../%.c
+ $(CC) $(CFLAGS) -c -o $@ $<
+
+$(BUILD)/%.o: %.c
+ $(CC) $(CFLAGS) -c -o $@ $<
+
+$(BUILD)/%.o: ../%.s
+ $(AS) -plosgff $@ $<
+
+$(BUILD)/%.o: %.s
+ $(AS) -plosgff $@ $<
diff --git a/gbdk/gbdk-lib/libc/scanf.c b/gbdk/gbdk-lib/libc/scanf.c
new file mode 100644
index 00000000..d1b5317b
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/scanf.c
@@ -0,0 +1,153 @@
+#include <stdint.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <ctype.h>
+
+static unsigned char scan_skip(char *s, unsigned char i)
+{
+oncemore:
+ while(isspace(s[i]))
+ i++;
+ if(s[i] == 0) {
+ gets(s);
+ i = 0;
+ goto oncemore;
+ }
+ return i;
+}
+
+static unsigned char scan_int(char *s, unsigned char i, unsigned char base, char *nb)
+{
+ char n = 0;
+ unsigned char j, sign = 0;
+
+ switch(s[i])
+ {
+ case '-':
+ sign++;
+ /* and fall through */
+ case '+':
+ ++i;
+ break;
+ }
+ while(1) {
+ if(isdigit(s[i]))
+ j = s[i] - '0';
+ else if(isalpha(s[i]))
+ j = toupper(s[i]) - 'A' + 10;
+ else
+ break;
+ if(j >= base)
+ break;
+ n = base * n + j;
+ i++;
+ }
+ *nb = (sign == 0 ? n : -n);
+ return i;
+}
+
+static unsigned char scan_long(char *s, unsigned char i, unsigned char base, int *nb)
+{
+ int n = 0;
+ unsigned char j, sign = 0;
+
+ switch(s[i])
+ {
+ case '-':
+ sign++;
+ /* and fall through */
+ case '+':
+ ++i;
+ break;
+ }
+ while(1) {
+ if(isdigit(s[i]))
+ j = s[i] - '0';
+ else if(isalpha(s[i]))
+ j = toupper(s[i]) - 'A' + 10;
+ else
+ break;
+ if(j >= base)
+ break;
+ n = base * n + j;
+ i++;
+ }
+ *nb = (sign == 0 ? n : -n);
+ return i;
+}
+
+char scanf(char *fmt, ...)
+{
+ va_list ap;
+ char s[64];
+ unsigned char i = 0;
+ char nb = 0;
+
+ gets(s);
+ va_start(ap, fmt);
+ for(; *fmt; fmt++) {
+ if(isspace(*fmt))
+ continue;
+ i = scan_skip(s, i);
+ if(*fmt == '%') {
+ switch(*++fmt) {
+ case 'c':
+ /* char */
+ *va_arg(ap, char *) = s[i++];
+ break;
+ case 'd':
+ /* decimal int */
+ case 'u':
+ /* unsigned int */
+ i = scan_int(s, i, 10, va_arg(ap, char *));
+ break;
+ case 'o':
+ /* octal int */
+ i = scan_int(s, i, 8, va_arg(ap, char *));
+ break;
+ case 'x':
+ /* hexadecimal int */
+ i = scan_int(s, i, 16, va_arg(ap, char *));
+ break;
+ case 's':
+ /* string */
+ {
+ char j = 0;
+ char *d = va_arg(ap, char *);
+ while((d[j++] = s[i++]) != 0)
+ ;
+ }
+ break;
+ case 'l':
+ /* long */
+ switch(*++fmt) {
+ case 'd':
+ /* decimal long */
+ case 'u':
+ /* unsigned long */
+ i = scan_long(s, i, 10, va_arg(ap, int *));
+ break;
+ case 'o':
+ /* octal long */
+ i = scan_long(s, i, 8, va_arg(ap, int *));
+ break;
+ case 'x':
+ /* hexadecimal long */
+ i = scan_long(s, i, 16, va_arg(ap, int *));
+ break;
+ }
+ break;
+ default:
+ if(s[i] != *fmt)
+ return -1;
+ break;
+ }
+ nb++;
+ } else
+ if(s[i] != *fmt)
+ return -1;
+ }
+ va_end(ap);
+
+ return nb;
+}
diff --git a/gbdk/gbdk-lib/libc/sprintf.c b/gbdk/gbdk-lib/libc/sprintf.c
new file mode 100644
index 00000000..c8e23acd
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/sprintf.c
@@ -0,0 +1,112 @@
+#include <types.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <stdint.h>
+
+typedef void (*emitter_t)(char, char **) OLDCALL;
+
+static const char _hex[] = "0123456789ABCDEF";
+
+inline void _printhex(uint16_t u, emitter_t emitter, char ** pData)
+{
+ (*emitter)(_hex[(uint8_t)(u >> 8) >> 4], pData);
+ (*emitter)(_hex[(uint8_t)(u >> 8) & 0x0fu], pData);
+ (*emitter)(_hex[((uint8_t)u >> 4) & 0x0fu], pData);
+ (*emitter)(_hex[(uint8_t)u & 0x0fu], pData);
+}
+
+inline void _printhexbyte(uint8_t u, emitter_t emitter, char ** pData)
+{
+ (*emitter)(_hex[u >> 4], pData);
+ (*emitter)(_hex[u & 0x0fu], pData);
+}
+
+static void _printbuf(char * buf, emitter_t emitter, char ** pData) {
+ for (char *s = buf; *s; s++) (*emitter)(*s, pData);
+}
+
+void __printf(const char *format, emitter_t emitter, char **pData, va_list va)
+{
+ char buf[16];
+ while ((uint8_t)(*format)) {
+ if ((uint8_t)(*format) == '%') {
+ format++;
+
+ // 0 Padding is not supported, ignore
+ if ((uint8_t)(*format) == '0') format++;
+
+ // Width Specifier is not supported, ignore 1 digit worth
+ if ((uint8_t)((uint8_t)(*format) - '1') < 9u) format++;
+
+ switch ((uint8_t)(*format)) {
+ case 'h': {
+ switch ((uint8_t)(*++format)) {
+ case 'X' :
+ case 'x' : {
+ _printhexbyte(va_arg(va, char), emitter, pData);
+ break;
+ }
+ case 'u':
+ {
+ uitoa((unsigned char)va_arg(va, char), buf, 10);
+ _printbuf(buf, emitter, pData);
+ break;
+ }
+ case 'd':
+ {
+ itoa((signed char)va_arg(va, char), buf, 10);
+ _printbuf(buf, emitter, pData);
+ break;
+ }
+ }
+ break;
+ }
+ case 'c': {
+ char c = va_arg(va, char);
+ (*emitter)(c, pData);
+ break;
+ }
+ case 'u':
+ {
+ uitoa(va_arg(va, int), buf, 10);
+ _printbuf(buf, emitter, pData);
+ break;
+ }
+ case 'd':
+ {
+ itoa(va_arg(va, int), buf, 10);
+ _printbuf(buf, emitter, pData);
+ break;
+ }
+ case 'X':
+ case 'x':
+ {
+ _printhex(va_arg(va, int), emitter, pData);
+ break;
+ }
+ case 's':
+ {
+ _printbuf(va_arg(va, char *), emitter, pData);
+ break;
+ }
+ }
+ } else {
+ (*emitter)(*format, pData);
+ }
+ format++;
+ }
+}
+
+static void _sprintf_emitter(char c, char ** pData) OLDCALL {
+ **pData = c;
+ (*pData)++;
+}
+
+void sprintf(char *into, const char *format, ...) OLDCALL {
+ va_list va;
+ va_start(va, format);
+
+ __printf(format, _sprintf_emitter, &into, va);
+ _sprintf_emitter('\0', &into);
+}
diff --git a/gbdk/gbdk-lib/libc/strcat.c b/gbdk/gbdk-lib/libc/strcat.c
new file mode 100644
index 00000000..a2088b07
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/strcat.c
@@ -0,0 +1,14 @@
+#include <string.h>
+
+/*
+ * Concatenate s2 on the end of s1. s1 must be large enough.
+ * Return s1.
+ */
+
+char *strcat(char *s1, const char *s2) {
+ char *os1 = s1;
+ while (*s1++) ;
+ --s1;
+ while (*s1++ = *s2++) ;
+ return os1;
+}
diff --git a/gbdk/gbdk-lib/libc/string.c b/gbdk/gbdk-lib/libc/string.c
new file mode 100644
index 00000000..c1f8198a
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/string.c
@@ -0,0 +1,36 @@
+/** Dumb strings hack.
+*/
+#include <string.h>
+#include <gbdk/gbdk-lib.h>
+
+#if USE_C_STRCPY
+char *strcpy(char *dest, const char *source) NONBANKED
+{
+ char *d = dest;
+ const char *s = source;
+ while (*d = *s) d++, s++;
+ return dest;
+}
+#endif
+
+#if USE_C_MEMCPY
+void *memcpy(void *dest, const void *source, size_t count) NONBANKED
+{
+ char *d = dest;
+ const char *s = source;
+ while (count--) {
+ *d = *s;
+ d++;
+ s++;
+ }
+ return dest;
+}
+#endif
+
+#if USE_C_STRCMP
+int strcmp(const char *s1, const char *s2) {
+ char ret = 0;
+ while (!(ret = *s1 - *s2) && *s2) ++s1, ++s2;
+ return (ret < 0) ? -1 : ((ret > 0) ? 1 : 0);
+}
+#endif
diff --git a/gbdk/gbdk-lib/libc/strncat.c b/gbdk/gbdk-lib/libc/strncat.c
new file mode 100644
index 00000000..6bfdb30e
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/strncat.c
@@ -0,0 +1,21 @@
+#include <string.h>
+
+/*
+ * Concatenate s2 on the end of s1. s1 must be large enough.
+ * At most n characters are moved.
+ * Return s1.
+ */
+
+char *strncat(char *s1, const char *s2, int n) {
+ char *os1 = s1;
+ while (*s1++) ;
+ --s1;
+ while (*s1++ = *s2++) {
+ if (n == 0) {
+ *--s1 = '\0';
+ break;
+ }
+ n--;
+ }
+ return os1;
+}
diff --git a/gbdk/gbdk-lib/libc/strncmp.c b/gbdk/gbdk-lib/libc/strncmp.c
new file mode 100644
index 00000000..1f0eaa43
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/strncmp.c
@@ -0,0 +1,16 @@
+#include <string.h>
+
+/*
+ * Compare strings (at most n bytes):
+ * s1>s2: >0
+ * s1==s2: 0
+ * s1<s2: <0
+ */
+
+int strncmp(const char *s1, const char *s2, int n) {
+ while ((n > 0) && (*s1 == *s2++)) {
+ if (*s1++ == '\0') return 0;
+ n--;
+ }
+ return (n == 0 ? 0 : *s1 - *--s2);
+}
diff --git a/gbdk/gbdk-lib/libc/strncpy.c b/gbdk/gbdk-lib/libc/strncpy.c
new file mode 100644
index 00000000..6d6428a1
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/strncpy.c
@@ -0,0 +1,18 @@
+#include <string.h>
+
+/*
+ * Copy s2 to s1, truncating or null-padding to always copy n bytes.
+ * Return s1.
+ */
+
+char *strncpy(char *s1, const char *s2, int n) {
+ int i;
+ char *os1 = s1;
+ for (i = 0; i < n; i++) {
+ if ((*s1++ = *s2++) == '\0') {
+ while (++i < n) *s1++ = '\0';
+ return os1;
+ }
+ }
+ return os1;
+}
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/___sdcc_bcall.s b/gbdk/gbdk-lib/libc/targets/sm83/___sdcc_bcall.s
new file mode 100644
index 00000000..a6aa2ff3
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/___sdcc_bcall.s
@@ -0,0 +1,27 @@
+ .include "global.s"
+
+ .area _HOME
+
+___sdcc_bcall::
+banked_call:: ; Performs a long call.
+ pop hl ; Get the return address
+ ldh a,(__current_bank)
+ push af ; Push the current bank onto the stack
+ ld a,(hl+) ; Fetch the call address
+ ld e, a
+ ld a,(hl+)
+ ld d, a
+ ld a,(hl+) ; ...and page
+ inc hl ; Yes this should be here
+ push hl ; Push the real return address
+ ldh (__current_bank),a
+ ld (.MBC_ROM_PAGE),a ; Perform the switch
+ ld l,e
+ ld h,d
+ rst 0x20
+banked_ret::
+ pop hl ; Get the return address
+ pop af ; Pop the old bank
+ ldh (__current_bank),a
+ ld (.MBC_ROM_PAGE),a
+ jp (hl)
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/___sdcc_bcall_ehl.s b/gbdk/gbdk-lib/libc/targets/sm83/___sdcc_bcall_ehl.s
new file mode 100644
index 00000000..e67ebce0
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/___sdcc_bcall_ehl.s
@@ -0,0 +1,15 @@
+ .include "global.s"
+
+ .area _HOME
+
+___sdcc_bcall_ehl:: ; Performs a long call.
+ ldh a,(__current_bank)
+ push af ; Push the current bank onto the stack
+ ld a, e
+ ldh (__current_bank),a
+ ld (.MBC_ROM_PAGE),a ; Perform the switch
+ rst 0x20
+ pop af ; Pop the old bank
+ ldh (__current_bank),a
+ ld (.MBC_ROM_PAGE),a
+ ret \ No newline at end of file
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/ap/Makefile b/gbdk/gbdk-lib/libc/targets/sm83/ap/Makefile
new file mode 100644
index 00000000..f8201547
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/ap/Makefile
@@ -0,0 +1,47 @@
+# GB specific Makefile
+
+TOPDIR = ../../../..
+
+THIS = ap
+PORT = sm83
+
+CSRC = crlf.c digits.c gprint.c gprintf.c gprintln.c gprintn.c
+
+ASSRC = cgb.s cgb_palettes.s cgb_compat.s \
+ cpy_data.s \
+ drawing.s drawing_isr.s color.s \
+ f_ibm_full.s f_ibm_sh.s f_italic.s f_min.s f_spect.s \
+ get_bk_t.s get_data.s get_tile.s \
+ get_wi_t.s get_xy_t.s \
+ get_addr.s \
+ hiramcpy.s init_tt.s input.s \
+ pad.s \
+ serial.s set_bk_t.s set_tile.s \
+ set_data.s set_prop.s set_spr.s set_wi_t.s set_xy_t.s \
+ set_1bit_data.s \
+ sgb.s font.s font_color.s delay.s \
+ emu_debug.s emu_debug_printf.s \
+ nowait.s far_ptr.s \
+ lcd.s joy.s tim.s tim_nested.s tim_common.s \
+ crash_handler.s \
+ ___sdcc_bcall_ehl.s ___sdcc_bcall.s \
+ mv_spr.s \
+ pad_ex.s \
+ mode.s clock.s \
+ get_t.s set_t.s init_vram.s \
+ fill_rect.s fill_rect_bk.s fill_rect_wi.s \
+ metasprites.s metasprites_flip.s metasprites_hide.s metasprites_hide_spr.s \
+ set_tile_submap.s set_win_tile_submap.s \
+ gb_decompress.s gb_decompress_tiles.s \
+ rle_decompress.s \
+ heap.s \
+ sfr.s \
+ crt0.s
+
+CRT0 = crt0.s
+
+include $(TOPDIR)/Makefile.common
+
+AS = $(AS_SM83)
+
+include ../../../Makefile.platform
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/ap/crash_handler.s b/gbdk/gbdk-lib/libc/targets/sm83/ap/crash_handler.s
new file mode 100644
index 00000000..ec08a7f8
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/ap/crash_handler.s
@@ -0,0 +1,481 @@
+; Crash handler support
+; Original code by ISSOtm
+; Adapted by Toxa from gb-starter-kit: https://github.com/ISSOtm/gb-starter-kit
+
+ .include "global.s"
+
+ .globl _font_ibm
+
+ SCRN_X = 160 ; Width of screen in pixels
+ SCRN_Y = 144 ; Height of screen in pixels
+ SCRN_X_B = 20 ; Width of screen in bytes
+ SCRN_Y_B = 18 ; Height of screen in bytes
+
+ SCRN_VX = 256 ; Virtual width of screen in pixels
+ SCRN_VY = 256 ; Virtual height of screen in pixels
+ SCRN_VX_B = 32 ; Virtual width of screen in bytes
+ SCRN_VY_B = 32 ; Virtual height of screen in bytes
+
+
+ .area _CRASH_HEADER(ABS)
+
+ .org 0x00
+ nop
+ nop
+ rst 0x38
+
+ .org 0x38
+ di
+ jp ___HandleCrash
+
+
+ .area _HOME
+
+___HandleCrash::
+
+ ; We will use VRAM as scratch, since we are going to overwrite it for
+ ; screen output anyways. The thing is, we need to turn the LCD off
+ ; *without* affecting flags... fun task, eh?
+
+ ; Note: it's assumed that this was jumped to with IME off.
+ ; Don't call this directly, use `rst Crash`.
+
+ ld (wCrashA), a ; We need to have at least one working register, so...
+ ldh a, (.IE) ; We're also going to overwrite this
+ ld (wCrashIE), a
+ ldh a, (.LCDC)
+ ld (wCrashLCDC), a
+ ld a, #LCDCF_ON ; LCDCF_ON Make sure the LCD is turned on to avoid waiting infinitely
+ ldh (.LCDC), a
+ ld a, #IEF_VBLANK ; IEF_VBLANK
+ ld (.IE), a
+ ld a, #0 ; `xor a` would overwrite flags
+ ld (.IF), a ; No point in backing up that register, it's always changing
+ halt ; With interrupts disabled, this will exit when `IE & IF != 0`
+ nop ; Handle hardware bug if it becomes true *before* starting to execute the instruction (1-cycle window)
+
+ ; We're now in VBlank! So we can now use VRAM as scratch for some cycles
+ ld a, #0
+ ldh (.LCDC), a ; Turn off LCD so VRAM can always be safely accessed
+ ; Save regs
+ ld (vCrashSP), sp
+ ld sp, #vCrashSP
+ push hl
+ push de
+ push bc
+ ld a, (wCrashA)
+ push af
+
+ ; We need to have all the data in bank 0, but we can't guarantee we were there
+ ldh a, (.VBK)
+ ld e, a
+ bit #0, a
+ jr z, .bank0
+ ; Oh noes. We need to copy the data across banks!
+ ld hl, #vCrashAF
+ ld c, #(5 * 2)
+.copyAcross:
+ ld b, (hl)
+ xor a
+ ldh (.VBK), a
+ ld (hl), b
+ inc l ; inc hl
+ inc a ; ld a, 1
+ ldh (.VBK), a
+ dec c
+ jr nz, .copyAcross
+.bank0:
+ xor a
+ ldh (.NR52), a ; Kill sound for this screen
+
+ ldh (.VBK), a
+ ld a, e
+ ld (vCrashVBK), a ; copy vCrashVBK across banks
+
+ ld a, #1
+ ldh (.VBK), a
+ ld hl, #vCrashDumpScreen
+ ld b, #SCRN_Y_B
+.writeAttrRow:
+ xor a
+ ld c, #(SCRN_X_B + 1)
+ rst #0x28 ; .MemsetSmall
+ ld a, l
+ add a, #(SCRN_VX_B - SCRN_X_B - 1)
+ ld l, a
+ dec b
+ jr nz, .writeAttrRow
+ xor a
+ ldh (.VBK), a
+
+ ; Load palettes
+ ld a, #0x03
+ ldh (.BGP), a
+ ld a, #0x80
+ ldh (.BCPS), a
+ xor a
+ ld c, #.BCPD
+ ldh (c), a
+ ldh (c), a
+ dec a ; ld a, $FF
+ ldh (c), a
+ ldh (c), a
+ ldh (c), a
+ ldh (c), a
+ ldh (c), a
+ ldh (c), a
+
+ ld a, #(SCRN_VY - SCRN_Y)
+ ldh (.SCY), a
+ ld a, #(SCRN_VX - SCRN_X - 4)
+ ldh (.SCX), a
+
+ call loadfont
+
+ ; Copy the registers to the dump viewers
+ ld hl, #vDumpHL
+ ld de, #vCrashHL
+ ld c, #4
+ rst #0x30 ; .MemcpySmall
+
+ ; We're now going to draw the screen, top to bottom
+ ld hl, #vCrashDumpScreen
+
+ ; First 3 lines of text
+ ld de, #.header
+ ld b, #3
+.writeHeaderLine:
+ ld a, #0x20 ; " "
+ ld (hl+), a
+ ld c, #19
+ rst #0x30 ; .MemcpySmall
+ ld a, #0x20 ; " "
+ ld (hl+), a
+ ld a, l
+ add a, #(SCRN_VX_B - SCRN_X_B - 1)
+ ld l, a
+ dec b
+ jr nz, .writeHeaderLine
+
+ ; Blank line
+ ld a, #0x20 ; " "
+ ld c, #(SCRN_X_B + 1)
+ rst #0x28 ; .MemsetSmall
+
+ ; AF and console model
+ ld l, #<vCrashDumpScreenRow4
+ ld c, #4
+ rst #0x30 ; .MemcpySmall
+ pop bc
+ call .printHexBC
+ ld c, #8
+ rst #0x30 ; .MemcpySmall
+ ld a, (__cpu)
+ call .printHexA
+ ld a, #0x20 ; " "
+ ld (hl+), a
+ ld (hl+), a
+ ld (hl+), a
+
+ ; BC and DE
+ ld l, #<vCrashDumpScreenRow5
+ ld c, #4
+ rst #0x30 ; .MemcpySmall
+ pop bc
+ call .printHexBC
+ ld c, #6
+ rst #0x30 ; .MemcpySmall
+ pop bc
+ call .printHexBC
+ ld a, #0x20
+ ld (hl+), a
+ ld (hl+), a
+ ld (hl+), a
+
+ ; Now, the two memory dumps
+.writeDump:
+ ld a, l
+ add a, #(SCRN_VX_B - SCRN_X_B - 1)
+ ld l, a
+ ld c, #4
+ rst #0x30 ; .MemcpySmall
+ pop bc
+ push bc
+ call .printHexBC
+ ld de, #.viewStr
+ ld c, #7
+ rst #0x30 ; .MemcpySmall
+ pop de
+ call .printDump
+ ld de, #.spStr
+ bit #7, l
+ jr z, .writeDump
+
+ ld de, #.hwRegsStrs
+ ld l, #<vCrashDumpScreenRow14
+ ld c, #6
+ rst #0x30 ; .MemcpySmall
+ ld a, (wCrashLCDC)
+ call .printHexA
+ ld c, #4
+ rst #0x30 ; .MemcpySmall
+ ldh a, (.KEY1)
+ call .printHexA
+ ld c, #4
+ rst #0x30 ; .MemcpySmall
+ ld a, (wCrashIE)
+ call .printHexA
+ ld (hl), #0x20 ; " "
+
+ ld l, #<vCrashDumpScreenRow15
+ ld c, #7
+ rst #0x30 ; .MemcpySmall
+.writeBank:
+ ld a, #0x20 ; " "
+ ld (hl+), a
+ ld a, (de)
+ inc de
+ ld (hl+), a
+ cp #0x20 ; " "
+ jr z, .banksDone
+ ld a, (de)
+ inc de
+ ld c, a
+ ld a, (de)
+ inc de
+ ld b, a
+ ld a, (bc)
+ call .printHexA
+ jr .writeBank
+.banksDone:
+
+ ; Start displaying
+ ld a, #(LCDCF_ON | LCDCF_BG9C00 | LCDCF_BGON)
+ ldh (.LCDC), a
+
+.loop:
+ ; The code never lags, and IE is equal to IEF_VBLANK
+ xor a
+ ldh (.IF), a
+ halt
+
+ jr .loop
+
+.printHexBC:
+ call .printHexB
+ ld a, c
+.printHexA:
+ ld b, a
+.printHexB:
+ ld a, b
+ and #0xF0
+ swap a
+ add a, #0x30
+ cp #0x3a
+ jr c, 1$
+ add a, #(0x41 - 0x3a)
+1$: ld (hl+), a
+ ld a, b
+ and #0x0F
+ add a, #0x30
+ cp #0x3a
+ jr c, 2$
+ add a, #(0x41 - 0x3a)
+2$: ld (hl+), a
+ ret
+
+.printDump:
+ ld b, d
+ ld c, e
+ call .printHexBC
+ ld a, #0x20 ; " "
+ ld (hl+), a
+ ld (hl+), a
+ ld a, e
+ sub #8
+ ld e, a
+ ld a, d
+ sbc #0
+ ld d, a
+.writeDumpLine:
+ ld a, l
+ add a, #(SCRN_VX_B - SCRN_X_B - 1)
+ ld l, a
+ ld a, #0x20 ; " "
+ ld (hl+), a
+.writeDumpWord:
+ ld a, (de)
+ inc de
+ call .printHexA
+ ld a, (de)
+ inc de
+ call .printHexA
+ ld a, #0x20 ; " "
+ ld (hl+), a
+ bit 4, l
+ jr nz, .writeDumpWord
+ ld a, l
+ and #0x7F
+ jr nz, .writeDumpLine
+ ret
+
+loadfont:
+ xor a
+ cpl
+ ld hl, #0x9000
+ ld c, #16
+ rst #0x28 ; .MemsetSmall
+ ld hl, #(0x9000 + ' ' * 16)
+ ld c, #16
+ rst #0x28 ; .MemsetSmall
+
+ ld de, #(_font_ibm + 2 + '0') ; recode table
+ ld hl, #(0x9000 + '0' * 16) ; destination
+ push hl
+ ld c, #(16 * 3)
+1$:
+ ld a, (de)
+ inc de
+ push de
+
+ swap a
+ ld l, a
+ and #0x0f
+ ld h, a
+ ld a, l
+ and #0xf0
+ srl h
+ rra
+ ld l, a
+ ld de, #(_font_ibm + 2 + 128)
+ add hl, de
+
+ ld d, h
+ ld e, l
+
+ ldhl sp, #2
+ ld a, (hl+)
+ ld h, (hl)
+ ld l, a
+
+ ld b, #8
+2$:
+ ld a, (de)
+ cpl
+ inc de
+ ld (hl+), a
+ ld (hl+), a
+
+ dec b
+ jr nz, 2$
+
+ ld d, h
+ ld a, l
+ ldhl sp, #2
+ ld (hl+), a
+ ld (hl), d
+
+ pop de
+
+ dec c
+ jr nz, 1$
+
+ add sp, #2
+ ret
+
+.header:
+ ; 0123456789ABCDEFGHI 19 chars
+ .ascii "KERNEL PANIC PLEASE"
+ .ascii "SEND A CLEAR PIC OF"
+ .ascii "THIS SCREEN TO DEVS"
+ .ascii " AF:"
+ .ascii " MODEL:"
+ .ascii " BC:"
+ .ascii " DE:"
+ .ascii " HL:"
+.viewStr:
+ .ascii " VIEW:"
+.spStr:
+ .ascii " SP:"
+.hwRegsStrs:
+ .ascii " LCDC:"
+ .ascii " K1:"
+ .ascii " IE:"
+ .ascii " BANK:"
+ .ascii "R"
+ .dw __current_bank
+ .ascii "V"
+ .dw vCrashVBK
+ .ascii "W"
+ .db .SVBK, 0xff
+ .ascii " "
+
+
+ .area _DATA
+
+wCrashA:
+ .ds 1 ; We need at least one working register, and A allows accessing memory
+wCrashIE:
+ .ds 1
+wCrashLCDC:
+ .ds 1
+
+
+ .area _CRASH_SCRATCH(ABS)
+
+ .org 0x9C00
+
+ ; Put the crash dump screen at the bottom-right of the 9C00 tilemap, since that tends to be unused space
+ .ds SCRN_VX_B * (SCRN_VY_B - SCRN_Y_B - 2) ; 2 rows reserved as scratch space
+
+ .ds SCRN_X_B ; Try not to overwrite the window area
+ .ds 2 * 1 ; Free stack entries (we spill into the above by 1 entry, though :/)
+ ; These are the initial values of the registers
+ ; They are popped off the stack when printed, freeing up stack space
+
+vCrashAF:
+ .ds 2
+vCrashBC:
+ .ds 2
+vCrashDE:
+ .ds 2
+vCrashHL:
+ .ds 2
+vCrashSP:
+ .ds 2
+
+ .ds SCRN_X_B
+vHeldKeys:
+ .ds 1 ; Keys held on previous frame
+vUnlockCounter:
+ .ds 1 ; How many frames until dumps are "unlocked"
+vWhichDump:
+ .ds 1
+vDumpHL:
+ .ds 2
+vDumpSP:
+ .ds 2
+vCrashVBK:
+ .ds 1
+ .ds 4 ; Unused
+
+ .ds SCRN_VX_B - SCRN_X_B - 1
+vCrashDumpScreen:
+vCrashDumpScreenRow0 = vCrashDumpScreen + 1 * SCRN_VX_B
+vCrashDumpScreenRow1 = vCrashDumpScreen + 2 * SCRN_VX_B
+vCrashDumpScreenRow2 = vCrashDumpScreen + 3 * SCRN_VX_B
+vCrashDumpScreenRow3 = vCrashDumpScreen + 4 * SCRN_VX_B
+vCrashDumpScreenRow4 = vCrashDumpScreen + 5 * SCRN_VX_B
+vCrashDumpScreenRow5 = vCrashDumpScreen + 6 * SCRN_VX_B
+vCrashDumpScreenRow6 = vCrashDumpScreen + 7 * SCRN_VX_B
+vCrashDumpScreenRow7 = vCrashDumpScreen + 8 * SCRN_VX_B
+vCrashDumpScreenRow8 = vCrashDumpScreen + 9 * SCRN_VX_B
+vCrashDumpScreenRow9 = vCrashDumpScreen + 10 * SCRN_VX_B
+vCrashDumpScreenRow10 = vCrashDumpScreen + 11 * SCRN_VX_B
+vCrashDumpScreenRow11 = vCrashDumpScreen + 12 * SCRN_VX_B
+vCrashDumpScreenRow12 = vCrashDumpScreen + 13 * SCRN_VX_B
+vCrashDumpScreenRow13 = vCrashDumpScreen + 14 * SCRN_VX_B
+vCrashDumpScreenRow14 = vCrashDumpScreen + 15 * SCRN_VX_B
+vCrashDumpScreenRow15 = vCrashDumpScreen + 16 * SCRN_VX_B
+vCrashDumpScreenRow16 = vCrashDumpScreen + 17 * SCRN_VX_B
+vCrashDumpScreenRow17 = vCrashDumpScreen + 18 * SCRN_VX_B
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/ap/crt0.s b/gbdk/gbdk-lib/libc/targets/sm83/ap/crt0.s
new file mode 100644
index 00000000..4553105d
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/ap/crt0.s
@@ -0,0 +1,529 @@
+ .include "global.s"
+
+ ;; ****************************************
+ ;; Beginning of module
+ ;; BANKED: checked
+ .title "Runtime"
+ .module Runtime
+ .area _HEADER (ABS)
+
+ ;; RST vectors
+; .org 0x00 ; Trap, utilized by crash_handler.h
+
+; .org 0x08 ; --profile handler utilized by emu_debug.h
+
+; .org 0x10 ; empty
+
+; .org 0x18 ; empty
+
+ .org 0x20 ; RST 0x20 == call HL
+.call_hl::
+ JP (HL)
+
+ .org 0x28 ; zero up to 256 bytes in C pointed by HL
+.MemsetSmall::
+ LD (HL+),A
+ DEC C
+ JR NZ,.MemsetSmall
+ ret
+
+ .org 0x30 ; copy up to 256 bytes in C from DE to HL
+.MemcpySmall::
+ LD A, (DE)
+ LD (HL+), A
+ INC DE
+ DEC C
+ JR NZ,.MemcpySmall
+ RET
+
+; .org 0x38 ; crash handler utilized by crash_handler.h
+
+ ;; Hardware interrupt vectors
+ .org 0x40 ; VBL
+.int_VBL:
+ PUSH AF
+ PUSH HL
+ LD HL,#.int_0x40
+ JP .int
+
+; .org 0x48 ; LCD
+
+; .org 0x50 ; TIM
+
+; .org 0x58 ; SIO
+
+; .org 0x60 ; JOY
+
+; .org 0x70
+ ;; space for drawing.s bit table
+
+ .org 0x80
+.int::
+ PUSH BC
+ PUSH DE
+1$:
+ LD A,(HL+)
+ OR (HL)
+ JR Z,.int_tail
+ PUSH HL
+ LD A,(HL-)
+ LD L,(HL)
+ LD H,A
+ RST 0x20 ; .call_hl
+ POP HL
+ INC HL
+ JR 1$
+_wait_int_handler::
+ ADD SP,#4
+.int_tail:
+ POP DE
+ POP BC
+ POP HL
+
+ ;; we return at least at the beginning of mode 2
+ WAIT_STAT
+
+ POP AF
+ RETI
+
+ ;; VBlank default interrupt routine
+__standard_VBL_handler::
+.std_vbl:
+ LD HL,#.sys_time
+ INC (HL)
+ JR NZ,2$
+ INC HL
+ INC (HL)
+2$:
+ CALL .refresh_OAM
+
+ LD A, #1
+ LDH (.vbl_done),A
+ RET
+
+_refresh_OAM::
+ WAIT_STAT
+ LD A, #>_shadow_OAM
+ JP .refresh_OAM + (.refresh_OAM_DMA - .start_refresh_OAM)
+
+.clear_WRAM:
+ PUSH DE
+ XOR A
+ LD BC, #l__DATA
+ LD HL, #s__DATA
+ CALL .memset_simple
+
+ LD A, #>_shadow_OAM
+ LDH (__shadow_OAM_base), A
+ LD H, A
+ XOR A
+ LD L, A
+ LD C, #(40 << 2) ; 40 entries 4 bytes each
+ RST 0x28
+ POP DE
+ RET
+
+ ;; GameBoy Header
+
+ ;; DO NOT CHANGE...
+ .org 0x100
+.header:
+ JR .code_start
+
+ ;; Nintendo logo
+ .org 0x104
+ .byte 0x01,0x10,0xCE,0xEF,0x00,0x00,0x44,0xAA
+ .byte 0x00,0x74,0x00,0x18,0x11,0x95,0x00,0x34
+ .byte 0x00,0x1A,0x00,0xD5,0x00,0x22,0x00,0x69
+ .byte 0x6F,0xF6,0xF7,0x73,0x09,0x90,0xE1,0x10
+ .byte 0x44,0x40,0x9A,0x90,0xD5,0xD0,0x44,0x30
+ .byte 0xA9,0x21,0x5D,0x48,0x22,0xE0,0xF8,0x60
+
+ ;; Title of the game
+ .org 0x134
+ .asciz "Title"
+
+ .org 0x144
+ .byte 0,0,0
+
+ ;; Cartridge type is ROM only
+ .org 0x147
+ .byte 0
+
+ ;; ROM size is 32kB
+ .org 0x148
+ .byte 0
+
+ ;; RAM size is 0kB
+ .org 0x149
+ .byte 0
+
+ ;; Maker ID
+ .org 0x14A
+ .byte 0x00,0x00
+
+ ;; Version number
+ .org 0x14C
+ .byte 0x01
+
+ ;; Complement check
+ .org 0x14D
+ .byte 0x00
+
+ ;; Checksum
+ .org 0x14E
+ .byte 0x00,0x00
+
+ ;; ****************************************
+ .org 0x150
+
+ ;; soft reset: falldown to .code_start
+.reset::
+_reset::
+ LD A, (__is_GBA)
+ LD B, A
+ LD A, (__cpu)
+
+ ;; Initialization code
+.code_start::
+ DI ; Disable interrupts
+ LD D, A ; Store CPU type in D
+ LD E, B
+ ;; Initialize the stack
+ LD SP, #.STACK
+
+ CALL .clear_WRAM
+
+; LD (.mode),A ; Clearing (.mode) is performed when clearing RAM
+
+ ;; Store CPU type
+ LD A, D
+ LD (__cpu), A
+ CP #.CGB_TYPE
+ JR NZ, 1$
+ XOR A
+ SRL E
+ RLA
+ LD (__is_GBA), A
+1$:
+
+ ;; Turn the screen off
+ CALL .display_off
+
+ XOR A
+ ;; Initialize the display
+ LDH (.SCY),A
+ LDH (.SCX),A
+ LDH (.STAT),A
+ LDH (.WY),A
+ LD A,#0x07
+ LDH (.WX),A
+
+ ;; Copy refresh_OAM routine to HRAM
+ LD DE,#.start_refresh_OAM ; source
+ LD HL,#.refresh_OAM ; dest
+ LD C,#(.end_refresh_OAM - .start_refresh_OAM) ; size
+ RST 0x30 ; call .MemcpySmall
+
+ ;; Clear the OAM by calling refresh_OAM
+ CALL .refresh_OAM
+
+ ;; Install interrupt routines
+ LD BC,#.std_vbl
+ CALL .add_VBL
+
+ ;; Standard color palettes
+ LD A,#0b11100100 ; Grey 3 = 11 (Black)
+ ; Grey 2 = 10 (Dark grey)
+ ; Grey 1 = 01 (Light grey)
+ ; Grey 0 = 00 (Transparent)
+ LDH (.BGP),A
+ LDH (.OBP0),A
+ LD A,#0b00011011
+ LDH (.OBP1),A
+
+ ;; Turn the screen on
+ LD A,#(LCDCF_ON | LCDCF_WIN9C00 | LCDCF_WINOFF | LCDCF_BG8800 | LCDCF_BG9800 | LCDCF_OBJ8 | LCDCF_OBJOFF | LCDCF_BGOFF)
+ LDH (.LCDC),A
+ XOR A
+ LDH (.IF),A
+ LD A,#.VBL_IFLAG ; switch on VBlank interrupt only
+ LDH (.IE),A
+
+ LDH (__current_bank),A ; current bank is 1 at startup
+
+ XOR A
+
+ LD HL,#.sys_time
+ LD (HL+),A
+ LD (HL),A
+
+ LDH (.NR52),A ; Turn sound off
+
+ CALL gsinit
+
+ EI ; Enable interrupts
+
+ ;; Call the main function
+ CALL _main
+_exit::
+99$:
+ HALT
+ NOP
+ JR 99$ ; Wait forever
+
+_set_interrupts::
+ DI
+ LDA HL,2(SP) ; Skip return address
+ XOR A
+ LDH (.IF),A ; Clear pending interrupts
+ LD A,(HL)
+ EI ; Enable interrupts
+ LDH (.IE),A ; interrupts are still disabled here
+ RET
+
+ ;; Copy OAM data to OAM RAM
+.start_refresh_OAM:
+ LDH A,(__shadow_OAM_base)
+ OR A
+ RET Z
+.refresh_OAM_DMA:
+ LDH (.DMA),A ; Put A into DMA registers
+ LD A,#0x28 ; We need to wait 160 ns
+1$:
+ DEC A
+ JR NZ,1$
+ RET
+.end_refresh_OAM:
+
+ .org .MODE_TABLE
+ ;; Jump table for modes
+ RET
+
+ ;; ****************************************
+
+ ;; Ordering of segments for the linker
+ ;; Code that really needs to be in bank 0
+ .area _HOME
+ ;; Similar to _HOME
+ .area _BASE
+ ;; Code
+ .area _CODE
+ ;; #pragma bank 0 workaround
+ .area _CODE_0
+ ;; Constant data
+ .area _LIT
+; ;; since _CODE_1 area base address is pre-defined in the linker from 0x4000,
+; ;; that moves initializer code and tables out of bank 0
+; .area _CODE_1
+ ;; Constant data, used to init _DATA
+ .area _INITIALIZER
+ ;; Code, used to init _DATA
+ .area _GSINIT
+ .area _GSFINAL
+ ;; Uninitialised ram data
+ .area _DATA
+ .area _BSS
+ ;; Initialised in ram data
+ .area _INITIALIZED
+ ;; For malloc
+ .area _HEAP
+ .area _HEAP_END
+
+ .area _DATA
+__cpu::
+ .ds 0x01 ; GB type (GB, PGB, CGB)
+__is_GBA::
+ .ds 0x01 ; detect GBA
+.mode::
+ .ds 0x01 ; Current mode
+.sys_time::
+_sys_time::
+ .ds 0x02 ; System time in VBL units
+.int_0x40::
+ .blkw 0x0A ; 4 interrupt handlers (built-in + user-defined)
+
+ .area _HRAM (ABS)
+
+ .org 0xFF90
+__current_bank:: ; Current bank
+ .ds 0x01
+.vbl_done:
+ .ds 0x01 ; Is VBL interrupt finished?
+__shadow_OAM_base::
+ .ds 0x01
+
+ ;; Runtime library
+ .area _GSINIT
+gsinit::
+ ;; initialize static storage variables
+ LD BC, #l__INITIALIZER
+ LD HL, #s__INITIALIZER
+ LD DE, #s__INITIALIZED
+ call .memcpy_simple
+
+ .area _GSFINAL
+ ret
+
+ .area _HOME
+
+ ;; fills memory at HL of length BC with A, clobbers DE
+.memset_simple::
+ LD E, A
+ LD A, B
+ OR C
+ RET Z
+ LD (HL), E
+ DEC BC
+ LD D, H
+ LD E, L
+ INC DE
+
+ ;; copies BC bytes from HL into DE
+.memcpy_simple::
+ LD A, B
+ OR C
+ RET Z
+
+ SRL B
+ RR C
+ JR NC,3$
+ LD A, (HL+)
+ LD (DE), A
+ INC DE
+3$:
+ INC B
+ INC C
+ JR 2$
+1$:
+ LD A, (HL+)
+ LD (DE), A
+ INC DE
+ LD A, (HL+)
+ LD (DE), A
+ INC DE
+2$:
+ DEC C
+ JR NZ,1$
+ DEC B
+ JR NZ,1$
+4$:
+ RET
+
+ ;; Remove interrupt routine in BC from the VBL interrupt list
+ ;; falldown to .remove_int
+.remove_VBL::
+ LD HL,#.int_0x40
+
+ ;; Remove interrupt BC from interrupt list HL if it exists
+ ;; Abort if a 0000 is found (end of list)
+.remove_int::
+1$:
+ LD A,(HL+)
+ LD E,A
+ LD D,(HL)
+ INC HL
+ OR D
+ RET Z ; No interrupt found
+
+ LD A,E
+ CP C
+ JR NZ,1$
+ LD A,D
+ CP B
+ JR NZ,1$
+
+ LD D,H
+ LD E,L
+ DEC DE
+ DEC DE
+
+ ;; Now do a memcpy from here until the end of the list
+2$:
+ LD A,(HL+)
+ LD (DE),A
+ LD B,A
+ INC DE
+ LD A,(HL+)
+ LD (DE),A
+ INC DE
+ OR B
+ RET Z
+ JR 2$
+
+ ;; Add interrupt routine in BC to the VBL interrupt list
+ ;; falldown to .add_int
+.add_VBL::
+ LD HL,#.int_0x40
+
+ ;; Add interrupt routine in BC to the interrupt list in HL
+.add_int::
+1$:
+ LD A,(HL+)
+ OR (HL)
+ JR Z,2$
+ INC HL
+ JR 1$
+2$:
+ LD A,B
+ LD (HL-),A
+ LD (HL),C
+ RET
+
+ ;; Wait for VBL interrupt to be finished
+.wait_vbl_done::
+_wait_vbl_done::
+ ;; Check if the screen is on
+ LDH A,(.LCDC)
+ AND #LCDCF_ON
+ RET Z ; Return if screen is off
+ XOR A
+ LDH (.vbl_done),A ; Clear any previous sets of vbl_done
+1$:
+ HALT ; Wait for any interrupt
+ NOP ; HALT sometimes skips the next instruction
+ LDH A,(.vbl_done) ; Was it a VBlank interrupt?
+ ;; Warning: we may lose a VBlank interrupt, if it occurs now
+ OR A
+ JR Z,1$ ; No: back to sleep!
+ RET
+
+.display_off::
+_display_off::
+ ;; Check if the screen is on
+ LDH A,(.LCDC)
+ AND #LCDCF_ON
+ RET Z ; Return if screen is off
+1$: ; We wait for the *NEXT* VBL
+ LDH A,(.LY)
+ CP #0x92 ; Smaller than or equal to 0x91?
+ JR NC,1$ ; Loop until smaller than or equal to 0x91
+2$:
+ LDH A,(.LY)
+ CP #0x91 ; Bigger than 0x90?
+ JR C,2$ ; Loop until bigger than 0x90
+
+ LDH A,(.LCDC)
+ AND #~LCDCF_ON
+ LDH (.LCDC),A ; Turn off screen
+ RET
+
+_remove_VBL::
+ PUSH BC
+ LDA HL,4(SP) ; Skip return address and registers
+ LD A,(HL+)
+ LD C,A
+ LD B,(HL)
+ CALL .remove_VBL
+ POP BC
+ RET
+
+_add_VBL::
+ PUSH BC
+ LDA HL, 4(SP) ; Skip return address and registers
+ LD A,(HL+)
+ LD C,A
+ LD B,(HL)
+ CALL .add_VBL
+ POP BC
+ RET
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/ap/global.s b/gbdk/gbdk-lib/libc/targets/sm83/ap/global.s
new file mode 100644
index 00000000..19d10ae3
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/ap/global.s
@@ -0,0 +1,533 @@
+ .NEAR_CALLS = 1 ; <near_calls> - tag so that sed can change this
+
+ _VRAM = 0x8000 ; $8000->$9FFF
+ _VRAM8000 = 0x8000
+ _VRAM8800 = 0x8800
+ _VRAM9000 = 0x9000
+ _SCRN0 = 0x9800 ; $9800->$9BFF
+ _SCRN1 = 0x9C00 ; $9C00->$9FFF
+ _SRAM = 0xA000 ; $A000->$BFFF
+ _RAM = 0xC000 ; $C000->$CFFF / $C000->$DFFF
+ _RAMBANK = 0xD000 ; $D000->$DFFF
+ _OAMRAM = 0xFE00 ; $FE00->$FE9F
+ _IO = 0xFF00 ; $FF00->$FF7F,$FFFF
+ _AUD3WAVERAM = 0xFF30 ; $FF30->$FF3F
+ _HRAM = 0xFF80 ; $FF80->$FFFE
+
+ ;; MBC Equates
+
+ .MBC1_ROM_PAGE = 0x2000 ; Address to write to for MBC1 switching
+ .MBC_ROM_PAGE = 0x2000 ; Default platform MBC rom switching address
+
+ rRAMG = 0x0000 ; $0000->$1fff
+ rROMB0 = 0x2000 ; $2000->$2fff
+ rROMB1 = 0x3000 ; $3000->$3fff - If more than 256 ROM banks are present.
+ rRAMB = 0x4000 ; $4000->$5fff - Bit 3 enables rumble (if present)
+
+ ;; Keypad
+ .START = 0x80
+ .SELECT = 0x40
+ .B = 0x20
+ .A = 0x10
+ .DOWN = 0x08
+ .UP = 0x04
+ .LEFT = 0x02
+ .RIGHT = 0x01
+
+ .P14 = 0x10
+ .P15 = 0x20
+
+ ;; Screen dimensions
+ .MAXCURSPOSX = 0x13 ; In tiles
+ .MAXCURSPOSY = 0x11
+
+ .SCREENWIDTH = 0xA0
+ .SCREENHEIGHT = 0x90
+ .MINWNDPOSX = 0x07
+ .MINWNDPOSY = 0x00
+ .MAXWNDPOSX = 0xA6
+ .MAXWNDPOSY = 0x8F
+
+ ;; Hardware registers
+
+ .P1 = 0x00 ; Joystick: 1.1.P15.P14.P13.P12.P11.P10
+ rP1 = 0xFF00
+
+ P1F_5 = 0b00100000 ; P15 out port, set to 0 to get buttons
+ P1F_4 = 0b00010000 ; P14 out port, set to 0 to get dpad
+ P1F_3 = 0b00001000 ; P13 in port
+ P1F_2 = 0b00000100 ; P12 in port
+ P1F_1 = 0b00000010 ; P11 in port
+ P1F_0 = 0b00000001 ; P10 in port
+
+ P1F_GET_DPAD = 0b00100000
+ P1F_GET_BTN = 0b00010000
+ P1F_GET_NONE = 0b00110000
+
+ .SB = 0x01 ; Serial IO data buffer
+ rSB = 0xFF01
+
+ .SC = 0x02 ; Serial IO control register
+ rSC = 0xFF02
+
+ .DIV = 0x04 ; Divider register
+ rDIV = 0xFF04
+
+ .TIMA = 0x05 ; Timer counter
+ rTIMA = 0xFF05
+
+ .TMA = 0x06 ; Timer modulo
+ rTMA = 0xFF06
+
+ .TAC = 0x07 ; Timer control
+ rTAC = 0xFF07
+
+ TACF_START = 0b00000100
+ TACF_STOP = 0b00000000
+ TACF_4KHZ = 0b00000000
+ TACF_16KHZ = 0b00000011
+ TACF_65KHZ = 0b00000010
+ TACF_262KHZ = 0b00000001
+
+ .IF = 0x0F ; Interrupt flags: 0.0.0.JST.SIO.TIM.LCD.VBL
+ rIF = 0xFF0F
+
+ .NR10 = 0x10 ; Sound register
+ rNR10 = 0xFF10
+ rAUD1SWEEP = 0xFF10
+
+ AUD1SWEEP_UP = 0b00000000
+ AUD1SWEEP_DOWN = 0b00001000
+
+ .NR11 = 0x11 ; Sound register
+ rNR11 = 0xFF11
+ rAUD1LEN = 0xFF11
+
+ .NR12 = 0x12 ; Sound register
+ rNR12 = 0xFF12
+ rAUD1ENV = 0xFF12
+
+ .NR13 = 0x13 ; Sound register
+ rNR13 = 0xFF13
+ rAUD1LOW = 0xFF13
+
+ .NR14 = 0x14 ; Sound register
+ rNR14 = 0xFF14
+ rAUD1HIGH = 0xFF14
+
+ .NR21 = 0x16 ; Sound register
+ rNR21 = 0xFF16
+ rAUD2LEN = 0xFF16
+
+ .NR22 = 0x17 ; Sound register
+ rNR22 = 0xFF17
+ rAUD2ENV = 0xFF17
+
+ .NR23 = 0x18 ; Sound register
+ rNR23 = 0xFF18
+ rAUD2LOW = 0xFF18
+
+ .NR24 = 0x19 ; Sound register
+ rNR24 = 0xFF19
+ rAUD2HIGH = 0xFF19
+
+ .NR30 = 0x1A ; Sound register
+ rNR30 = 0xFF1A
+ rAUD3ENA = 0xFF1A
+
+ .NR31 = 0x1B ; Sound register
+ rNR31 = 0xFF1B
+ rAUD3LEN = 0xFF1B
+
+ .NR32 = 0x1C ; Sound register
+ rNR32 = 0xFF1C
+ rAUD3LEVEL = 0xFF1C
+
+ .NR33 = 0x1D ; Sound register
+ rNR33 = 0xFF1D
+ rAUD3LOW = 0xFF1D
+
+ .NR34 = 0x1E ; Sound register
+ rNR34 = 0xFF1E
+ rAUD3HIGH = 0xFF1E
+
+ .NR41 = 0x20 ; Sound register
+ rNR41 = 0xFF20
+ rAUD4LEN = 0xFF20
+
+ .NR42 = 0x21 ; Sound register
+ rNR42 = 0xFF21
+ rAUD4ENV = 0xFF21
+
+ .NR43 = 0x22 ; Sound register
+ rNR43 = 0xFF22
+ rAUD4POLY = 0xFF22
+
+ .NR44 = 0x23 ; Sound register
+ rNR44 = 0xFF23
+ rAUD4GO = 0xFF23
+
+ .NR50 = 0x24 ; Sound register
+ rNR50 = 0xFF24
+ rAUDVOL = 0xFF24
+
+ AUDVOL_VIN_LEFT = 0b10000000 ; SO2
+ AUDVOL_VIN_RIGHT = 0b00001000 ; SO1
+
+ .NR51 = 0x25 ; Sound register
+ rNR51 = 0xFF25
+ rAUDTERM = 0xFF25
+
+ AUDTERM_4_LEFT = 0b10000000
+ AUDTERM_3_LEFT = 0b01000000
+ AUDTERM_2_LEFT = 0b00100000
+ AUDTERM_1_LEFT = 0b00010000
+ AUDTERM_4_RIGHT = 0b00001000
+ AUDTERM_3_RIGHT = 0b00000100
+ AUDTERM_2_RIGHT = 0b00000010
+ AUDTERM_1_RIGHT = 0b00000001
+
+ .NR52 = 0x26 ; Sound register
+ rNR52 = 0xFF26
+ rAUDENA = 0xFF26
+
+ AUDENA_ON = 0b10000000
+ AUDENA_OFF = 0b00000000 ; sets all audio regs to 0!
+
+ .LCDC = 0x4E ; LCD control
+ rLCDC = 0xFF4E
+
+ LCDCF_OFF = 0b00000000 ; LCD Control Operation
+ LCDCF_ON = 0b00000001 ; LCD Control Operation
+ LCDCF_WIN9800 = 0b00000000 ; Window Tile Map Display Select
+ LCDCF_WIN9C00 = 0b00000010 ; Window Tile Map Display Select
+ LCDCF_WINOFF = 0b00000000 ; Window Display
+ LCDCF_WINON = 0b00000100 ; Window Display
+ LCDCF_BG8800 = 0b00000000 ; BG & Window Tile Data Select
+ LCDCF_BG8000 = 0b00001000 ; BG & Window Tile Data Select
+ LCDCF_BG9800 = 0b00000000 ; BG Tile Map Display Select
+ LCDCF_BG9C00 = 0b00010000 ; BG Tile Map Display Select
+ LCDCF_OBJ8 = 0b00000000 ; OBJ Construction
+ LCDCF_OBJ16 = 0b00100000 ; OBJ Construction
+ LCDCF_OBJOFF = 0b00000000 ; OBJ Display
+ LCDCF_OBJON = 0b01000000 ; OBJ Display
+ LCDCF_BGOFF = 0b00000000 ; BG Display
+ LCDCF_BGON = 0b10000000 ; BG Display
+ LCDCF_B_ON = 0
+ LCDCF_B_WIN9C00 = 1
+ LCDCF_B_WINON = 2
+ LCDCF_B_BG8000 = 3
+ LCDCF_B_BG9C00 = 4
+ LCDCF_B_OBJ16 = 5
+ LCDCF_B_OBJON = 6
+ LCDCF_B_BGON = 7
+
+ .STAT = 0x41 ; LCD status
+ rSTAT = 0xFF41
+
+ STATF_LYC = 0b00000010 ; LYC=LY Coincidence (Selectable)
+ STATF_MODE10 = 0b00000100 ; Mode 10
+ STATF_MODE01 = 0b00001000 ; Mode 01 (V-Blank)
+ STATF_MODE00 = 0b00010000 ; Mode 00 (H-Blank)
+ STATF_LYCF = 0b00100000 ; Coincidence Flag
+ STATF_HBL = 0b00000000 ; H-Blank
+ STATF_VBL = 0b10000000 ; V-Blank
+ STATF_OAM = 0b01000000 ; OAM-RAM is used by system
+ STATF_LCD = 0b11000000 ; Both OAM and VRAM used by system
+ STATF_BUSY = 0b01000000 ; When set, VRAM access is unsafe
+ STATF_B_LYC = 1
+ STATF_B_MODE10 = 2
+ STATF_B_MODE01 = 3
+ STATF_B_MODE00 = 4
+ STATF_B_LYCF = 5
+ STATF_B_VBL = 7
+ STATF_B_OAM = 6
+ STATF_B_BUSY = 6
+
+ .SCY = 0x42 ; Scroll Y
+ rSCY = 0xFF42
+
+ .SCX = 0x43 ; Scroll X
+ rSCX = 0xFF43
+
+ .LY = 0x44 ; LCDC Y-coordinate
+ rLY = 0xFF44
+
+ .LYC = 0x45 ; LY compare
+ rLYC = 0xFF45
+
+ .DMA = 0x46 ; DMA transfer
+ rDMA = 0xFF46
+
+ .BGP = 0x47 ; BG palette data
+ rBGP = 0xFF47
+
+ .OBP0 = 0x48 ; OBJ palette 0 data
+ rOBP0 = 0xFF48
+
+ .OBP1 = 0x49 ; OBJ palette 1 data
+ rOBP1 = 0xFF49
+
+ .WY = 0x4A ; Window Y coordinate
+ rWY = 0xFF4A
+
+ .WX = 0x4B ; Window X coordinate
+ rWX = 0xFF4B
+
+ .KEY1 = 0x4D ; CPU speed
+ rKEY1 = 0xFF4D
+ rSPD = 0xFF4D
+
+ KEY1F_DBLSPEED = 0b10000000 ; 0=Normal Speed, 1=Double Speed (R)
+ KEY1F_PREPARE = 0b00000001 ; 0=No, 1=Prepare (R/W)
+
+ .VBK = 0x4F ; VRAM bank
+ rVBK = 0xFF4F
+
+ .HDMA1 = 0x51 ; DMA control 1
+ rHDMA1 = 0xFF51
+
+ .HDMA2 = 0x52 ; DMA control 2
+ rHDMA2 = 0xFF52
+
+ .HDMA3 = 0x53 ; DMA control 3
+ rHDMA3 = 0xFF53
+
+ .HDMA4 = 0x54 ; DMA control 4
+ rHDMA4 = 0xFF54
+
+ .HDMA5 = 0x55 ; DMA control 5
+ rHDMA5 = 0xFF55
+
+ HDMA5F_MODE_GP = 0b00000000 ; General Purpose DMA (W)
+ HDMA5F_MODE_HBL = 0b10000000 ; HBlank DMA (W)
+
+ HDMA5F_BUSY = 0b10000000 ; 0=Busy (DMA still in progress), 1=Transfer complete (R)
+
+ .RP = 0x56 ; IR port
+ rRP = 0xFF56
+
+ RPF_ENREAD = 0b11000000
+ RPF_DATAIN = 0b00000010 ; 0=Receiving IR Signal, 1=Normal
+ RPF_WRITE_HI = 0b00000001
+ RPF_WRITE_LO = 0b00000000
+
+ .BCPS = 0x68 ; BG color palette specification
+ rBCPS = 0xFF68
+
+ BCPSF_AUTOINC = 0b10000000 ; Auto Increment (0=Disabled, 1=Increment after Writing)
+
+ .BCPD = 0x69 ; BG color palette data
+ rBCPD = 0xFF69
+
+ .OCPS = 0x6A ; OBJ color palette specification
+ rOCPS = 0xFF6A
+
+ OCPSF_AUTOINC = 0b10000000 ; Auto Increment (0=Disabled, 1=Increment after Writing)
+
+ .OCPD = 0x6B ; OBJ color palette data
+ rOCPD = 0xFF6B
+
+ .SVBK = 0x70 ; WRAM bank
+ rSVBK = 0xFF70
+ rSMBK = 0xFF70
+
+ rPCM12 = 0xFF76
+
+ rPCM34 = 0xFF77
+
+ .IE = 0xFF ; Interrupt enable
+ rIE = 0xFFFF
+
+ .VBL_IFLAG = 0x01
+ .LCD_IFLAG = 0x02
+ .TIM_IFLAG = 0x04
+ .SIO_IFLAG = 0x08
+ .JOY_IFLAG = 0x10
+
+ IEF_HILO = 0b00010000 ; Transition from High to Low of Pin number P10-P13
+ IEF_SERIAL = 0b00001000 ; Serial I/O transfer end
+ IEF_TIMER = 0b00000100 ; Timer Overflow
+ IEF_STAT = 0b00000010 ; STAT
+ IEF_VBLANK = 0b00000001 ; V-Blank
+
+ ;; Flags common to multiple sound channels
+
+ AUDLEN_DUTY_12_5 = 0b00000000 ; 12.5%
+ AUDLEN_DUTY_25 = 0b01000000 ; 25%
+ AUDLEN_DUTY_50 = 0b10000000 ; 50%
+ AUDLEN_DUTY_75 = 0b11000000 ; 75%
+
+ AUDENV_UP = 0b00001000
+ AUDENV_DOWN = 0b00000000
+
+ AUDHIGH_RESTART = 0b10000000
+ AUDHIGH_LENGTH_ON = 0b01000000
+ AUDHIGH_LENGTH_OFF = 0b00000000
+
+ ;; OAM related constants
+
+ OAM_COUNT = 40 ; number of OAM entries in OAM RAM
+
+ OAMF_PRI = 0b10000000 ; Priority
+ OAMF_YFLIP = 0b01000000 ; Y flip
+ OAMF_XFLIP = 0b00100000 ; X flip
+ OAMF_PAL0 = 0b00000000 ; Palette number; 0,1 (DMG)
+ OAMF_PAL1 = 0b00010000 ; Palette number; 0,1 (DMG)
+ OAMF_BANK0 = 0b00000000 ; Bank number; 0,1 (GBC)
+ OAMF_BANK1 = 0b00001000 ; Bank number; 0,1 (GBC)
+
+ OAMF_PALMASK = 0b00000111 ; Palette (GBC)
+
+ OAMB_PRI = 7 ; Priority
+ OAMB_YFLIP = 6 ; Y flip
+ OAMB_XFLIP = 5 ; X flip
+ OAMB_PAL1 = 4 ; Palette number; 0,1 (DMG)
+ OAMB_BANK1 = 3 ; Bank number; 0,1 (GBC)
+
+ ;; SGB packets
+ .PAL_01 = 0x00
+ .PAL_23 = 0x01
+ .PAL_03 = 0x02
+ .PAL_12 = 0x03
+ .ATTR_BLK = 0x04
+ .ATTR_LIN = 0x05
+ .ATTR_DIV = 0x06
+ .ATTR_CHR = 0x07
+ .SOUND = 0x08
+ .SOU_TRN = 0x09
+ .PAL_SET = 0x0A
+ .PAL_TRN = 0x0B
+ .ATRC_EN = 0x0C
+ .TEST_EN = 0x0D
+ .ICON_EN = 0x0E
+ .DATA_SND = 0x0F
+ .DATA_TRN = 0x10
+ .MLT_REQ = 0x11
+ .JUMP = 0x12
+ .CHR_TRN = 0x13
+ .PCT_TRN = 0x14
+ .ATTR_TRN = 0x15
+ .ATTR_SET = 0x16
+ .MASK_EN = 0x17
+ .OBJ_TRN = 0x18
+
+ ;; CPU detection
+ .DMG_TYPE = 0x01 ; Original GB or Super GB
+ .MGB_TYPE = 0xFF ; Pocket GB or Super GB 2
+ .CGB_TYPE = 0x11 ; Color GB
+
+ ;; GBDK library screen modes
+
+ .G_MODE = 0x01 ; Graphic mode
+ .T_MODE = 0x02 ; Text mode (bit 2)
+ .T_MODE_OUT = 0x02 ; Text mode output only
+ .T_MODE_INOUT = 0x03 ; Text mode with input
+ .M_NO_SCROLL = 0x04 ; Disables scrolling of the screen in text mode
+ .M_NO_INTERP = 0x08 ; Disables special character interpretation
+
+ ;; Status codes for IO
+ .IO_IDLE = 0x00
+ .IO_SENDING = 0x01
+ .IO_RECEIVING = 0x02
+ .IO_ERROR = 0x04
+
+ ;; Type of IO data
+ .DT_IDLE = 0x66
+ .DT_RECEIVING = 0x55
+
+ ;; Table of routines for modes
+ .MODE_TABLE = 0x01E0
+
+ ;; C related
+ ;; Overheap of a banked call. Used for parameters
+ ;; = ret + real ret + bank
+
+ .if .NEAR_CALLS
+ .BANKOV = 2
+
+ .else
+ .BANKOV = 6
+
+ .endif
+
+ .globl __current_bank
+ .globl __shadow_OAM_base
+
+ ;; Global variables
+ .globl .mode
+
+ .globl __cpu
+ .globl __is_GBA
+
+ ;; Global routines
+; .globl .set_mode ;; don't link mode.o by default
+
+ .globl .reset
+
+ .globl .display_off
+
+ .globl .wait_vbl_done
+
+ ;; Interrupt routines
+ .globl .add_VBL
+; .globl .add_LCD ;; don't link LCD.o by default
+; .globl .add_TIM ;; don't link TIM.o by default
+; .globl .add_SIO ;; don't link serial.o by default
+; .globl .add_JOY ;; don't link JOY.o by default
+
+ ;; Symbols defined at link time
+ .globl .STACK
+ .globl _shadow_OAM
+ .globl .refresh_OAM
+
+ ;; Main user routine
+ .globl _main
+
+ ;; Macro definitions
+
+.macro WAIT_STAT ?lbl
+lbl: LDH A, (.STAT)
+ AND #STATF_BUSY ; Check if in LCD modes 0 or 1
+ JR NZ, lbl
+.endm
+
+.macro ADD_A_REG16 regH regL
+ ADD regL
+ LD regL, A
+ ADC regH
+ SUB regL
+ LD regH, A
+.endm
+
+.macro SIGNED_ADD_A_REG16 regH regL ?lbl
+ ; If A is negative, we need to subtract 1 from upper byte of 16-bit value
+ BIT 7, A ; set z if a signed bit is 0
+ JR Z, lbl ; if z is set jump to positive
+ dec regH ; if negative decrement upper byte
+lbl:
+ ADD_A_REG16 regH, regL
+.endm
+
+.macro SIGNED_SUB_A_REG16 regH regL ?lbl
+ ; negate A then add to 16-bit value
+ CPL
+ INC A
+ SIGNED_ADD_A_REG16 regH, regL
+.endm
+
+.macro MUL_DE_BY_A_RET_HL ?lbl1 ?lbl2 ?lbl3
+ ; Multiply DE by A, return result in HL; preserves: BC
+ LD HL, #0
+lbl1:
+ SRL A
+ JR NC, lbl2
+ ADD HL, DE
+lbl2:
+ JR Z, lbl3
+ SLA E
+ RL D
+ JR lbl1
+lbl3:
+.endm
+
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/ap/sfr.s b/gbdk/gbdk-lib/libc/targets/sm83/ap/sfr.s
new file mode 100644
index 00000000..98585886
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/ap/sfr.s
@@ -0,0 +1,111 @@
+__VRAM = 0x8000
+__VRAM8000 = 0x8000
+__VRAM8800 = 0x8800
+__VRAM9000 = 0x9000
+__SCRN0 = 0x9800
+__SCRN1 = 0x9C00
+__SRAM = 0xA000
+__RAM = 0xC000
+__RAMBANK = 0xD000
+__OAMRAM = 0xFE00
+__IO = 0xFF00
+__AUD3WAVERAM = 0xFF30
+__HRAM = 0xFF80
+
+.globl __VRAM, __VRAM8000, __VRAM8800, __VRAM9000, __SCRN0, __SCRN1, __SRAM, __RAM, __RAMBANK, __OAMRAM, __IO, __AUD3WAVERAM, __HRAM
+
+_rRAMG = 0x0000
+_rROMB0 = 0x2000
+_rROMB1 = 0x3000
+_rRAMB = 0x4000
+
+.globl _rRAMG, _rROMB0, _rROMB1, _rRAMB
+
+_P1_REG = 0xFF00 ; Joystick: 1.1.P15.P14.P13.P12.P11.P10
+_SB_REG = 0xFF01 ; Serial IO data buffer
+_SC_REG = 0xFF02 ; Serial IO control register
+_DIV_REG = 0xFF04 ; Divider register
+_TIMA_REG = 0xFF05 ; Timer counter
+_TMA_REG = 0xFF06 ; Timer modulo
+_TAC_REG = 0xFF07 ; Timer control
+_IF_REG = 0xFF0F ; Interrupt flags: 0.0.0.JOY.SIO.TIM.LCD.VBL
+_NR10_REG = 0xFF10 ; Sound register
+_NR11_REG = 0xFF11 ; Sound register
+_NR12_REG = 0xFF12 ; Sound register
+_NR13_REG = 0xFF13 ; Sound register
+_NR14_REG = 0xFF14 ; Sound register
+_NR21_REG = 0xFF16 ; Sound register
+_NR22_REG = 0xFF17 ; Sound register
+_NR23_REG = 0xFF18 ; Sound register
+_NR24_REG = 0xFF19 ; Sound register
+_NR30_REG = 0xFF1A ; Sound register
+_NR31_REG = 0xFF1B ; Sound register
+_NR32_REG = 0xFF1C ; Sound register
+_NR33_REG = 0xFF1D ; Sound register
+_NR34_REG = 0xFF1E ; Sound register
+_NR41_REG = 0xFF20 ; Sound register
+_NR42_REG = 0xFF21 ; Sound register
+_NR43_REG = 0xFF22 ; Sound register
+_NR44_REG = 0xFF23 ; Sound register
+_NR50_REG = 0xFF24 ; Sound register
+_NR51_REG = 0xFF25 ; Sound register
+_NR52_REG = 0xFF26 ; Sound register
+_PCM_SAMPLE = 0xFF30 ; PCM wave pattern
+_AUD3WAVE = 0xFF30 ; PCM wave pattern
+_LCDC_REG = 0xFF4E ; LCD control
+_STAT_REG = 0xFF41 ; LCD status
+_SCY_REG = 0xFF42 ; Scroll Y
+_SCX_REG = 0xFF43 ; Scroll X
+_LY_REG = 0xFF44 ; LCDC Y-coordinate
+_LYC_REG = 0xFF45 ; LY compare
+_DMA_REG = 0xFF46 ; DMA transfer
+_BGP_REG = 0xFF47 ; BG palette data
+_OBP0_REG = 0xFF48 ; OBJ palette 0 data
+_OBP1_REG = 0xFF49 ; OBJ palette 1 data
+_WY_REG = 0xFF4A ; Window Y coordinate
+_WX_REG = 0xFF4B ; Window X coordinate
+_KEY1_REG = 0xFF4D ; CPU speed
+_VBK_REG = 0xFF4F ; VRAM bank
+_HDMA1_REG = 0xFF51 ; DMA control 1
+_HDMA2_REG = 0xFF52 ; DMA control 2
+_HDMA3_REG = 0xFF53 ; DMA control 3
+_HDMA4_REG = 0xFF54 ; DMA control 4
+_HDMA5_REG = 0xFF55 ; DMA control 5
+_RP_REG = 0xFF56 ; IR port
+_BCPS_REG = 0xFF68 ; BG color palette specification
+_BCPD_REG = 0xFF69 ; BG color palette data
+_OCPS_REG = 0xFF6A ; OBJ color palette specification
+_OCPD_REG = 0xFF6B ; OBJ color palette data
+_SVBK_REG = 0xFF70 ; WRAM bank
+_PCM12_REG = 0xFF76 ; Sound channel 1&2 PCM amplitude (R)
+_PCM34_REG = 0xFF77 ; Sound channel 3&4 PCM amplitude (R)
+_IE_REG = 0xFFFF ; Interrupt enable
+
+.globl _P1_REG
+.globl _SB_REG, _SC_REG
+.globl _DIV_REG
+.globl _TIMA_REG, _TMA_REG, _TAC_REG
+.globl _IF_REG
+.globl _NR10_REG, _NR11_REG, _NR12_REG, _NR13_REG, _NR14_REG
+.globl _NR21_REG, _NR22_REG, _NR23_REG, _NR24_REG
+.globl _NR30_REG, _NR31_REG, _NR32_REG, _NR33_REG, _NR34_REG
+.globl _NR41_REG, _NR42_REG, _NR43_REG, _NR44_REG
+.globl _NR50_REG, _NR51_REG, _NR52_REG
+.globl _PCM_SAMPLE, _AUD3WAVE
+.globl _LCDC_REG
+.globl _STAT_REG
+.globl _SCY_REG, _SCX_REG
+.globl _LY_REG, _LYC_REG
+.globl _DMA_REG
+.globl _BGP_REG
+.globl _OBP0_REG, _OBP1_REG
+.globl _WY_REG, _WX_REG
+.globl _KEY1_REG
+.globl _VBK_REG
+.globl _HDMA1_REG, _HDMA2_REG, _HDMA3_REG, _HDMA4_REG, _HDMA5_REG
+.globl _RP_REG
+.globl _BCPS_REG, _BCPD_REG
+.globl _OCPS_REG, _OCPD_REG
+.globl _SVBK_REG
+.globl _PCM12_REG, _PCM34_REG
+.globl _IE_REG \ No newline at end of file
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/cgb.s b/gbdk/gbdk-lib/libc/targets/sm83/cgb.s
new file mode 100644
index 00000000..790097b7
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/cgb.s
@@ -0,0 +1,37 @@
+ .include "global.s"
+
+ .title "CGB support"
+ .module CGB
+
+ .area _CODE
+_cpu_slow:: ; Banked
+ LDH A,(.KEY1)
+ AND #0x80 ; Is GBC in double speed mode?
+ RET Z ; No, already in single speed
+
+.shift_speed:
+ LDH A,(.IE)
+ PUSH AF
+
+ XOR A ; A = 0
+ LDH (.IE),A ; Disable interrupts
+ LDH (.IF),A
+
+ LD A,#0x30
+ LDH (.P1),A
+
+ LD A,#0x01
+ LDH (.KEY1),A
+
+ STOP
+
+ POP AF
+ LDH (.IE),A
+
+ RET
+
+_cpu_fast:: ; Banked
+ LDH A,(.KEY1)
+ AND #0x80 ; Is GBC in double speed mode?
+ RET NZ ; Yes, exit
+ JR .shift_speed
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/cgb_compat.s b/gbdk/gbdk-lib/libc/targets/sm83/cgb_compat.s
new file mode 100644
index 00000000..11313d11
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/cgb_compat.s
@@ -0,0 +1,21 @@
+ .include "global.s"
+
+ .title "CGB support"
+ .module CGB
+
+ .globl _set_sprite_palette, _set_bkg_palette
+
+ .area _CODE
+
+_cgb_compatibility::
+_set_default_palette::
+ LD HL, #1$
+ PUSH HL
+ LD HL, #0x0100
+ PUSH HL
+ CALL _set_sprite_palette
+ CALL _set_bkg_palette
+ ADD SP, #4
+ RET
+1$:
+ .DW 0xFF7F, 0x56B5, 0x294A, 0x0000
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/cgb_palettes.s b/gbdk/gbdk-lib/libc/targets/sm83/cgb_palettes.s
new file mode 100644
index 00000000..830d218b
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/cgb_palettes.s
@@ -0,0 +1,78 @@
+ .include "global.s"
+
+ .title "CGB support"
+ .module CGB
+
+ .area _CODE
+
+_set_sprite_palette:: ; Non-banked
+ PUSH BC
+ LD C,#.OCPS
+ JR .set_palette
+
+_set_bkg_palette:: ; Non-banked
+ PUSH BC
+ LD C,#.BCPS
+
+.set_palette::
+ LDA HL,4(SP) ; Skip return address and registers
+ LD A,(HL+) ; first_palette
+ ADD A ; A *= 8
+ ADD A
+ ADD A
+ OR #0x80 ; Set auto-increment
+ LDH (C),A
+ INC C
+ LD A,(HL+) ; D = nb_palettes
+ ADD A ; A *= 8
+ ADD A
+ ADD A
+ LD B,A ; Number of bytes
+ LD A,(HL+) ; rgb_data
+ LD H,(HL)
+ LD L,A
+1$:
+ WAIT_STAT
+
+ LD A,(HL+)
+ LDH (C),A
+ DEC B
+ JR NZ,1$
+
+ POP BC
+ RET
+
+_set_sprite_palette_entry:: ; Banked
+ PUSH BC
+ LD C,#.OCPS
+ JR .set_palette_entry
+
+_set_bkg_palette_entry:: ; Banked
+ PUSH BC
+ LD C,#.BCPS
+
+.set_palette_entry::
+ LDA HL,4(SP); Skip return address and registers
+ LD A,(HL+) ; first_palette
+ ADD A ; A *= 4
+ ADD A
+ LD B,A
+ LD A,(HL+) ; pal_entry
+ ADD B ; A += first_palette * 4
+ ADD A ; A *= 2
+ OR #0x80 ; Set auto-increment
+ LDH (C),A
+ INC C
+ LD A,(HL+) ; rgb_data
+ LD H,(HL)
+ LD L,A
+
+ WAIT_STAT
+
+ LD A,L
+ LDH (C),A
+ LD A,H
+ LDH (C),A
+
+ POP BC
+ RET
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/clock.s b/gbdk/gbdk-lib/libc/targets/sm83/clock.s
new file mode 100644
index 00000000..f8d9aad5
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/clock.s
@@ -0,0 +1,16 @@
+ .include "global.s"
+
+ .title "System clock"
+ .module Clock
+
+ ;; BANKED: checked
+ .area _HOME
+
+_clock::
+ LD HL,#.sys_time
+ DI
+ LD A,(HL+)
+ EI ;; Interrupts are disabled for the next instruction...
+ LD D,(HL)
+ LD E,A
+ RET
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/color.s b/gbdk/gbdk-lib/libc/targets/sm83/color.s
new file mode 100644
index 00000000..632a76ed
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/color.s
@@ -0,0 +1,32 @@
+ .include "global.s"
+
+ ;; Data
+ .area _INITIALIZED
+__current_1bpp_colors::
+ ;; Foreground drawing colour
+.fg_colour::
+ .ds 1
+ ;; Background drawing colour
+.bg_colour::
+ .ds 1
+ ;; Drawing mode (.SOILD etc)
+.draw_mode::
+ .ds 1
+
+ .area _INITIALIZER
+
+ .db 0x03 ; .fg_colour
+ .db 0x00 ; .bg_color
+ .db 0x00 ; .draw_mode
+
+ .area _HOME
+_set_1bpp_colors_ex::
+_color::
+ LDA HL,2(SP) ; Skip return address and registers
+ LD A,(HL+) ; A = Foreground
+ LD (.fg_colour),a
+ LD A,(HL+)
+ LD (.bg_colour),a
+ LD A,(HL)
+ LD (.draw_mode),a
+ RET
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/cpy_data.s b/gbdk/gbdk-lib/libc/targets/sm83/cpy_data.s
new file mode 100644
index 00000000..a709ece8
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/cpy_data.s
@@ -0,0 +1,44 @@
+ .include "global.s"
+
+ .area _HOME
+
+ ;; Copy part (size = DE) of the VRAM from (BC) to (HL)
+.copy_vram::
+ INC D
+ INC E
+ JR 2$
+1$:
+ WAIT_STAT
+
+ LD A,(BC)
+ LD (HL+),A
+ INC BC
+2$:
+ DEC E
+ JR NZ, 1$
+ DEC D
+ JR NZ, 1$
+ RET
+
+_vmemcpy::
+_set_data::
+_get_data::
+ PUSH BC
+
+ LDA HL,9(SP) ; Skip return address and registers
+ LD A,(HL-) ; DE = len
+ LD D, A
+ LD A,(HL-)
+ LD E, A
+ LD A,(HL-) ; BC = src
+ LD B, A
+ LD A,(HL-)
+ LD C, A
+ LD A,(HL-) ; HL = dst
+ LD L,(HL)
+ LD H,A
+
+ CALL .copy_vram
+
+ POP BC
+ RET
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/crlf.c b/gbdk/gbdk-lib/libc/targets/sm83/crlf.c
new file mode 100644
index 00000000..aca6ec82
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/crlf.c
@@ -0,0 +1 @@
+const char * const __crlf = "\n"; \ No newline at end of file
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/delay.s b/gbdk/gbdk-lib/libc/targets/sm83/delay.s
new file mode 100644
index 00000000..19c862fb
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/delay.s
@@ -0,0 +1,73 @@
+ .include "global.s"
+
+ .area _HOME
+
+ ;; Delay DE milliseconds
+ ;;
+ ;; Entry conditions
+ ;; DE = number of milliseconds to delay (1 to 65536, 0 = 65536)
+ ;;
+ ;; Register used: AF, DE
+ .CPMS = 4194/4 ; 4.194304 MHz
+
+_delay::
+ LDA HL,2(SP) ; Skip return address
+ LD E,(HL) ; DE = delay
+ INC HL
+ LD D,(HL)
+
+.delay:: ; 6 cycles for the CALL
+ PUSH BC ; 4 cycles
+ CALL .dly ; 12 cycles to return from .dly (6+1+5)
+ LD B,#.CPMS/20-2 ; 2 cycles
+ ; =========
+ ; 24 cycles
+.ldlp:
+ PUSH BC ; 4 cycles
+ POP BC ; 3 cycles
+ PUSH BC ; 4 cycles
+ POP BC ; 3 cycles
+ NOP ; 1 cycles
+5$: DEC B ; 1 cycles
+ JP NZ,.ldlp ; 3 cycles (if TRUE: 4 cycles)
+ NOP ; 1 cycles
+ ; =========
+ ; 20 cycles
+ ;; Exit in 16 cycles
+ POP BC ; 3 cycles
+ PUSH BC ; 4 cycles
+ POP BC ; 3 cycles
+ NOP ; 1 cycles
+ NOP ; 1 cycles
+ RET ; 4 cycles
+ ; =========
+ ; 16 cycles
+
+ ;; Delay all but last millisecond
+.dly:
+ DEC DE ; 2 cycles
+ LD A,E ; 1 cycles
+ OR D ; 1 cycles
+ RET Z ; 2 cycles (upon return: 5 cycles)
+ LD B,#.CPMS/20-1 ; 2 cycles
+ ; =========
+ ; 8 cycles
+.dlp:
+ PUSH BC ; 4 cycles
+ POP BC ; 3 cycles
+ PUSH BC ; 4 cycles
+ POP BC ; 3 cycles
+ NOP ; 1 cycles
+ DEC B ; 1 cycles
+ JP NZ,.dlp ; 3 cycles (if TRUE: 4 cycles)
+ NOP ; 1 cycles
+ ; =========
+ ; 20 cycles
+ ;; Exit in 15 cycles
+ PUSH BC ; 4 cycles
+ POP BC ; 3 cycles
+ NOP ; 1 cycles
+ NOP ; 1 cycles
+ JR .dly ; 3 cycles
+ ; =========
+ ; 12 cycles
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/digits.c b/gbdk/gbdk-lib/libc/targets/sm83/digits.c
new file mode 100644
index 00000000..4668f154
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/digits.c
@@ -0,0 +1 @@
+const char * const digits = "0123456789ABCDEF";
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/drawing.s b/gbdk/gbdk-lib/libc/targets/sm83/drawing.s
new file mode 100644
index 00000000..cc774806
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/drawing.s
@@ -0,0 +1,1767 @@
+;; Optimised Drawing library
+;; By Jon Fuge (jonny@q-continuum.demon.co.uk) based on original file
+;; Updates
+;; 990223 Michael Removed mod_col, splitting it up into
+;; fg_colour, bg_colour, and draw_mode
+;; Note: some optimisations are available with unneded PUSH DE/POP DE's
+
+ .include "global.s"
+
+ .globl .init_vram
+ .globl .copy_vram
+
+ .globl .drawing_lcd, .drawing_vbl
+ .globl .bg_colour, .fg_colour, .draw_mode
+
+ .M_SOLID = 0x00
+ .M_OR = 0x01
+ .M_XOR = 0x02
+ .M_AND = 0x03
+
+ ;; Format of mod_col
+ ;; 7 6 5 4 3 2 1 0
+ ;; mode fg bg
+
+ .area _DRAW_HEADER (ABS)
+
+ .org 0x70
+.drawing_bits_tbl::
+ .byte 0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01
+ .byte 0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80
+
+ .org .MODE_TABLE+4*.G_MODE
+ JP .gmode
+
+ .module Drawing1
+
+ .area _DATA
+
+ ;; Fill style
+.style:
+ .ds 0x01
+ ;; Various varibles
+.x_s:
+ .ds 2
+.y_s:
+ .ds 2
+.delta_x:
+ .ds 1
+.delta_y:
+ .ds 1
+.l_inc:
+ .ds 1
+.l_d:
+ .ds 2
+.dinc1:
+ .ds 2
+.dinc2:
+ .ds 2
+.tx:
+ .ds 1
+.ty:
+ .ds 1
+
+ .area _HOME
+
+ ;; Enter graphic mode
+.gmode::
+ DI ; Disable interrupts
+
+ ;; Turn the screen off
+ LDH A,(.LCDC)
+ AND #LCDCF_ON
+ JR Z,1$
+
+ ;; Turn the screen off
+ CALL .display_off
+1$:
+ LD HL,#0x8000+0x10*0x10
+ LD DE,#0x1800-0x18*0x10
+ LD B,#0x00
+ CALL .init_vram ; Init the charset at 0x8000
+
+ ;; Install interrupt routines
+ LD BC,#.drawing_vbl
+ CALL .add_VBL
+ LD BC,#.drawing_lcd
+ CALL .add_LCD
+
+ LD A,#72 ; Set line at which LCD interrupt occurs
+ LDH (.LYC),A
+
+ LD A,#STATF_LYC
+ LDH (.STAT),A
+
+ LDH A,(.IE)
+ OR #.LCD_IFLAG ; Enable LCD interrupt
+ LDH (.IE),A
+
+ ;; (9*20) = 180 tiles are used in the upper part of the screen
+ ;; (9*20) = 180 tiles are used in the lower part of the screen
+ ;; => We have 24 tiles free
+ ;; We keep 16 at 0x8000->0x80FF, and 8 at 0x9780->97FF
+
+ LD HL,#0x9800
+ LD A,#0x10 ; Keep 16 tiles free
+ LD BC,#12 ; 12 unused columns
+ LD E,#18 ; 18 lines
+2$:
+ LD D,#20 ; 20 used columns
+3$:
+ LD (HL+),A
+ INC A
+ DEC D
+ JR NZ,3$
+ ADD HL,BC
+ DEC E
+ JR NZ,2$
+
+ ;; Turn the screen on
+ LDH A,(.LCDC)
+ OR #(LCDCF_ON | LCDCF_BG8000 | LCDCF_BGON)
+ AND #~LCDCF_BG9C00 ; BG Bank = 0x9800
+ LDH (.LCDC),A
+
+ LD A,#.G_MODE
+ LD (.mode),A
+
+ ;; Setup the default colours and draw modes
+ LD A,#.M_SOLID
+ LD (.draw_mode),A
+ LD A,#0x03 ; Black
+ LD (.fg_colour),A
+ LD A,#0x00 ; White
+ LD (.bg_colour),A
+
+ EI ; Enable interrupts
+
+ RET
+
+ ;; Draw a full-screen image at (BC)
+.draw_image::
+ LD HL,#0x8000+0x10*0x10
+ LD DE,#0x1680
+ CALL .copy_vram ; Move the charset
+ RET
+
+ ;; Replace tile data at (B,C) with data at DE and store old value at HL
+.switch_data::
+ PUSH DE ; Save src
+ PUSH HL ; Save dst
+ LD L,B
+ SLA L
+ SLA L
+ SLA L
+ LD H,#0x00
+ ADD HL,HL
+ LD D,H
+ LD E,L
+
+ LD HL,#.y_table
+ SLA C
+ SLA C
+ SLA C
+ LD B,#0x00
+ ADD HL,BC
+ ADD HL,BC
+ LD A,(HL+)
+ LD H,(HL)
+ LD L,A
+ ADD HL,DE
+
+ LD B,H ; BC = src
+ LD C,L
+ POP HL ; HL = dst
+ PUSH BC ; Save dst
+ LD A,H
+ OR L
+ JR Z,1$
+ LD DE,#0x10
+ CALL .copy_vram
+1$:
+ POP HL ; HL = dst
+ POP BC ; BC = src
+ LD A,B
+ OR C
+ JR Z,2$
+ LD DE,#0x10
+ CALL .copy_vram
+2$:
+ RET
+
+ ;; Advance the cursor
+.adv_gcurs::
+ PUSH HL
+ LD HL,#.tx ; X coordinate
+ LD A,#.MAXCURSPOSX
+ CP (HL)
+ JR Z,1$
+ INC (HL)
+ JR 99$
+1$:
+ LD (HL),#0x00
+ LD HL,#.ty ; Y coordinate
+ LD A,#.MAXCURSPOSY
+ CP (HL)
+ JR Z,2$
+ INC (HL)
+ JR 99$
+2$:
+ LD (HL),#0x00
+99$:
+ POP HL
+ RET
+
+ ;; Draw a circle from (B,C) with radius D
+.circle::
+ LD A,B ;Store center values
+ LD (.x_s),A
+ LD A,C
+ LD (.y_s),A
+
+ XOR A
+ LD (.x_s+1),A
+ LD A,D
+ LD (.y_s+1),A
+ CPL
+ LD L,A
+ LD H,#0xFF
+ INC HL
+ LD BC,#0
+ ADD HL,BC
+ LD A,L
+ LD (.l_d+1),A
+ LD A,H
+ LD (.l_d),A
+
+cloop$:
+ LD A,(.x_s+1)
+ LD B,A
+ LD A,(.y_s+1)
+ SUB B
+ RET C
+
+ LD A,(.style)
+ OR A
+ CALL Z,.circplot
+
+ LD A,(.l_d)
+ BIT 7,A
+ JR Z,ycirc$
+
+ LD A,(.style)
+ OR A
+ CALL NZ,.horlin
+ LD A,(.x_s+1)
+ INC A
+ LD (.x_s+1),A
+ LD A,(.l_d)
+ LD B,A
+ LD A,(.l_d+1)
+ LD C,A
+ LD H,#0
+ LD A,(.x_s+1)
+ LD L,A
+ ADD HL,HL
+ ADD HL,HL
+ ADD HL,BC
+ LD BC,#6
+ ADD HL,BC
+ LD A,H
+ LD (.l_d),A
+ LD A,L
+ LD (.l_d+1),A
+ JR cloop$
+ycirc$:
+ LD A,(.style)
+ OR A
+ CALL NZ,.verlin
+ LD A,(.x_s+1)
+ INC A
+ LD (.x_s+1),A
+ LD B,#0
+ LD A,(.x_s+1)
+ LD C,A
+ LD H,#0xFF
+ LD A,(.y_s+1)
+ CPL
+ LD L,A
+ INC HL
+ ADD HL,BC
+ LD A,(.l_d)
+ LD B,A
+ LD A,(.l_d+1)
+ LD C,A
+ ADD HL,HL
+ ADD HL,HL
+ ADD HL,BC
+ LD BC,#10
+ ADD HL,BC
+ LD A,H
+ LD (.l_d),A
+ LD A,L
+ LD (.l_d+1),A
+ LD A,(.y_s+1)
+ DEC A
+ LD (.y_s+1),A
+ JP cloop$
+
+.horlin::
+ LD A,(.x_s)
+ LD B,A
+ LD A,(.y_s)
+ LD C,A
+ LD A,(.x_s+1)
+ LD D,A
+ LD A,(.y_s+1)
+ LD E,A
+ PUSH BC
+ PUSH DE
+ LD A,B
+ SUB E
+ LD H,A
+ LD A,B
+ ADD E
+ LD B,A
+ LD A,C
+ ADD D
+ LD C,A
+ LD D,H
+ LD E,C
+ CALL .line
+ POP DE
+ POP BC
+ LD A,D
+ OR A
+ RET Z
+ PUSH BC
+ PUSH DE
+ LD A,B
+ SUB E
+ LD H,A
+ LD A,B
+ ADD E
+ LD B,A
+ LD A,C
+ SUB D
+ LD C,A
+ LD D,H
+ LD E,C
+ CALL .line
+ POP DE
+ POP BC
+ RET
+
+.verlin::
+ LD A,(.x_s)
+ LD B,A
+ LD A,(.y_s)
+ LD C,A
+ LD A,(.x_s+1)
+ LD D,A
+ LD A,(.y_s+1)
+ LD E,A
+ PUSH BC
+ PUSH DE
+ LD A,B
+ SUB E
+ LD H,A
+ LD A,B
+ ADD E
+ LD B,A
+ LD A,C
+ ADD D
+ LD C,A
+ LD D,H
+ LD E,C
+ CALL .line
+ POP DE
+ POP BC
+ PUSH BC
+ PUSH DE
+ LD A,B
+ SUB E
+ LD H,A
+ LD A,B
+ ADD E
+ LD B,A
+ LD A,C
+ SUB D
+ LD C,A
+ LD D,H
+ LD E,C
+ CALL .line
+ POP DE
+ POP BC
+ LD A,D
+ SUB E
+ RET Z
+ PUSH BC
+ PUSH DE
+ LD A,B
+ SUB D
+ LD H,A
+ LD A,B
+ ADD D
+ LD B,A
+ LD A,C
+ SUB E
+ LD C,A
+ LD D,H
+ LD E,C
+ CALL .line
+ POP DE
+ POP BC
+ PUSH BC
+ PUSH DE
+ LD A,B
+ SUB D
+ LD H,A
+ LD A,B
+ ADD D
+ LD B,A
+ LD A,C
+ ADD E
+ LD C,A
+ LD D,H
+ LD E,C
+ CALL .line
+ POP DE
+ POP BC
+ RET
+
+.circplot::
+ LD A,(.x_s)
+ LD B,A
+ LD A,(.y_s)
+ LD C,A
+ LD A,(.x_s+1)
+ LD D,A
+ LD A,(.y_s+1)
+ LD E,A
+ PUSH BC
+ PUSH DE
+ LD A,B
+ ADD D
+ LD B,A
+ LD A,C
+ SUB E
+ LD C,A
+ CALL .plot
+ POP DE
+ POP BC
+ PUSH BC
+ PUSH DE
+ LD A,B
+ SUB E
+ LD B,A
+ LD A,C
+ SUB D
+ LD C,A
+ CALL .plot
+ POP DE
+ POP BC
+ PUSH BC
+ PUSH DE
+ LD A,B
+ SUB D
+ LD B,A
+ LD A,C
+ ADD E
+ LD C,A
+ CALL .plot
+ POP DE
+ POP BC
+ PUSH BC
+ PUSH DE
+ LD A,B
+ ADD E
+ LD B,A
+ LD A,C
+ ADD D
+ LD C,A
+ CALL .plot
+ POP DE
+ POP BC
+
+ LD A,D
+ OR A
+ RET Z
+ SUB E
+ RET Z
+
+ PUSH BC
+ PUSH DE
+ LD A,B
+ SUB D
+ LD B,A
+ LD A,C
+ SUB E
+ LD C,A
+ CALL .plot
+ POP DE
+ POP BC
+ PUSH BC
+ PUSH DE
+ LD A,B
+ SUB E
+ LD B,A
+ LD A,C
+ ADD D
+ LD C,A
+ CALL .plot
+ POP DE
+ POP BC
+ PUSH BC
+ PUSH DE
+ LD A,B
+ ADD D
+ LD B,A
+ LD A,C
+ ADD E
+ LD C,A
+ CALL .plot
+ POP DE
+ POP BC
+ PUSH BC
+ PUSH DE
+ LD A,B
+ ADD E
+ LD B,A
+ LD A,C
+ SUB D
+ LD C,A
+ CALL .plot
+ POP DE
+ POP BC
+ RET
+
+ ;; Draw a box between (B,C) and (D,E)
+.box::
+ LD A,(.x_s)
+ LD B,A
+ LD A,(.x_s+1)
+ LD C,A
+ SUB B
+ JR NC,ychk$
+ LD A,C
+ LD (.x_s),A
+ LD A,B
+ LD (.x_s+1),A
+ychk$:
+ LD A,(.y_s)
+ LD B,A
+ LD A,(.y_s+1)
+ LD C,A
+ SUB B
+ JR NC,dbox$
+ LD A,C
+ LD (.y_s),A
+ LD A,B
+ LD (.y_s+1),A
+dbox$:
+ LD A,(.x_s)
+ LD B,A
+ LD D,A
+ LD A,(.y_s)
+ LD C,A
+ LD A,(.y_s+1)
+ LD E,A
+ CALL .line
+ LD A,(.x_s+1)
+ LD B,A
+ LD D,A
+ LD A,(.y_s)
+ LD C,A
+ LD A,(.y_s+1)
+ LD E,A
+ CALL .line
+ LD A,(.x_s)
+ INC A
+ LD (.x_s),A
+ LD A,(.x_s+1)
+ DEC A
+ LD (.x_s+1),A
+ LD A,(.x_s)
+ LD B,A
+ LD A,(.x_s+1)
+ LD D,A
+ LD A,(.y_s)
+ LD C,A
+ LD E,A
+ CALL .line
+ LD A,(.x_s)
+ LD B,A
+ LD A,(.x_s+1)
+ LD D,A
+ LD A,(.y_s+1)
+ LD C,A
+ LD E,A
+ CALL .line
+ LD A,(.style)
+ OR A
+ RET Z
+ LD A,(.x_s)
+ LD B,A
+ LD A,(.x_s+1)
+ SUB B
+ RET C
+ LD A,(.y_s)
+ INC A
+ LD (.y_s),A
+ LD A,(.y_s+1)
+ DEC A
+ LD (.y_s+1),A
+ LD A,(.y_s)
+ LD B,A
+ LD A,(.y_s+1)
+ SUB B
+ RET C
+
+ .if 0
+ LD A,(.mod_col) ;Swap fore + back colours.
+ LD D,A
+ AND #0xF0
+ LD C,A ;Preserve Style
+ LD A,D
+ AND #0x0C
+ RRCA
+ RRCA
+ OR C ;Foreground->background + style
+ LD C,A
+ LD A,D
+ AND #0x03
+ RLCA
+ RLCA
+ OR C
+ LD (.mod_col),A
+ .else
+ LD A,(.fg_colour)
+ LD C,A
+ LD A,(.bg_colour)
+ LD (.fg_colour),A
+ LD A,C
+ LD (.bg_colour),A
+ .endif
+filllp$:
+ LD A,(.x_s)
+ LD B,A
+ LD A,(.x_s+1)
+ LD D,A
+ LD A,(.y_s)
+ LD C,A
+ LD E,A
+ CALL .line
+ LD A,(.y_s+1)
+ LD B,A
+ LD A,(.y_s)
+ CP B
+ JR Z,swap$
+ INC A
+ LD (.y_s),A
+ JR filllp$
+swap$:
+ .if 0
+ LD A,(.mod_col) ;Swap fore + back colours.
+ LD D,A
+ AND #0xF0
+ LD C,A ;Preserve Style
+ LD A,D
+ AND #0x0C
+ RRCA
+ RRCA
+ OR C ;Foreground->background + style
+ LD C,A
+ LD A,D
+ AND #0x03
+ RLCA
+ RLCA
+ OR C
+ LD (.mod_col),A
+ .else
+ LD A,(.fg_colour)
+ LD C,A
+ LD A,(.bg_colour)
+ LD (.fg_colour),A
+ LD A,C
+ LD (.bg_colour),A
+ .endif
+ RET
+
+ ;; Draw a line between (B,C) and (D,E)
+.line::
+ LD A,C ;Calculate Delta Y
+ SUB E
+ JR NC,s1$
+ CPL
+ INC A
+
+s1$: LD (.delta_y),A
+ LD H,A
+
+ LD A,B ;Calculate Delta X
+ SUB D
+ JR NC,s2$
+ CPL
+ INC A
+
+s2$: LD (.delta_x),A
+
+ SUB H
+ JP C,y1
+
+ ;; Use Delta X
+
+ LD A,B
+ SUB D
+ JP NC,x2$
+
+ LD A,C
+ SUB E
+ JR Z,x3$
+ LD A,#0x00
+ JR NC,x3$
+ LD A,#0xFF
+ JR x3$
+
+x2$:
+ LD A,E
+ SUB C
+ JR Z,x2a$
+ LD A,#0x00
+ JR NC,x2a$
+ LD A,#0xFF
+
+x2a$:
+ LD B,D
+ LD C,E ;BC holds start X,Y
+x3$:
+ LD (.l_inc),A ;Store Y increment
+ LD HL,#.y_table
+ LD D,#0x00
+ LD E,C
+ ADD HL,DE
+ ADD HL,DE
+ LD A,(HL+)
+ LD H,(HL)
+ LD L,A
+
+ LD A,B
+ AND #0xf8
+ LD E,A
+ ADD HL,DE
+ ADD HL,DE
+
+ LD A,(.delta_y)
+ OR A
+ JP Z,.xonly
+
+ ;; Got to do it the hard way.
+
+ ; Calculate (2*deltay) -> dinc1
+
+ PUSH HL
+ LD H,#0x00
+ LD L,A
+ ADD HL,HL
+ LD A,H
+ LD (.dinc1),A
+ LD A,L
+ LD (.dinc1+1),A
+
+ ; Calculate (2*deltay)-deltax -> d
+
+
+ LD D,H
+ LD E,L
+ LD A,(.delta_x)
+ CPL
+ LD L,A
+ LD H,#0xFF
+ INC HL
+dx1$:
+ ADD HL,DE
+ LD A,H
+ LD (.l_d),A
+ LD A,L
+ LD (.l_d+1),A
+
+ ; Calculate (deltay-deltax)*2 -> dinc2
+
+ LD A,(.delta_x)
+ CPL
+ LD L,A
+ LD H,#0xFF
+ INC HL
+ LD A,(.delta_y)
+ LD D,#0x00
+ LD E,A
+ ADD HL,DE
+ ADD HL,HL
+
+ LD A,H
+ LD (.dinc2),A
+ LD A,L
+ LD (.dinc2+1),A
+
+ POP HL
+
+ .if 0
+ LD A,(.mod_col)
+ LD D,A
+ .endif
+
+ LD A,(.delta_x)
+ LD E,A
+
+ LD A,B
+ AND #7
+ ADD #<.drawing_bits_tbl ; Table of bits is located at 0x0070
+ LD C,A
+ LD B,#0x00
+ LD A,(BC) ; Get start bit
+ LD B,A
+ LD C,A
+
+xloop$:
+ RRC C
+ LD A,(.l_d)
+ BIT 7,A
+ JR Z,ychg$
+ PUSH DE
+ BIT 7,C
+ JR Z,nbit$
+ LD A,B
+ CPL
+ LD C,A
+ CALL .wrbyte
+ DEC HL
+ LD C,#0x80
+ LD B,C
+nbit$:
+ LD A,(.l_d+1)
+ LD D,A
+ LD A,(.dinc1+1)
+ ADD D
+ LD (.l_d+1),A
+ LD A,(.l_d)
+ LD D,A
+ LD A,(.dinc1)
+ ADC D
+ LD (.l_d),A
+ POP DE
+ JR nchg$
+ychg$:
+ PUSH DE
+ PUSH BC
+ LD A,B
+ CPL
+ LD C,A
+ CALL .wrbyte
+ LD A,(.l_inc)
+ OR A
+ JR Z,ydown$
+ INC HL
+ LD A,L
+ AND #0x0F
+ JR NZ,bound$
+ LD DE,#0x0130
+ ADD HL,DE ;Correct screen address
+ JR bound$
+ydown$:
+ DEC HL
+ DEC HL
+ DEC HL
+ LD A,L
+ AND #0x0F
+ XOR #0x0E
+ JR NZ,bound$
+ LD DE,#0xFED0
+ ADD HL,DE ;Correct screen address
+bound$:
+ LD A,(.l_d+1)
+ LD D,A
+ LD A,(.dinc2+1)
+ ADD D
+ LD (.l_d+1),A
+ LD A,(.l_d)
+ LD D,A
+ LD A,(.dinc2)
+ ADC D
+ LD (.l_d),A
+ POP BC
+ LD B,C
+ POP DE
+nchg$:
+ BIT 7,C
+ JR Z,nadj$
+ PUSH DE
+ LD DE,#0x0010
+ ADD HL,DE ;Correct screen address
+ POP DE
+ LD B,C
+nadj$:
+ LD A,B
+ OR C
+ LD B,A
+ DEC E
+ JP NZ,xloop$
+ LD A,B
+ CPL
+ LD C,A
+ JP .wrbyte
+
+.xonly::
+ ;; Draw accelerated horizontal line
+ .if 0
+ ;; xxx needed?
+ LD A,(.mod_col)
+ LD D,A
+ .endif
+
+ LD A,(.delta_x)
+ LD E,A
+ INC E
+
+ LD A,B ;check X
+ AND #7 ;just look at bottom 3 bits
+ JR Z,2$
+ PUSH HL
+ ADD #<.drawing_bits_tbl ;Table of bits is located at 0x0070
+ LD L,A
+ LD H,#0x00
+ LD C,(HL)
+ POP HL
+ XOR A ;Clear A
+1$: RRCA ;Shift data right 1
+ OR C
+ DEC E
+ JR Z,3$
+ BIT 0,A
+ JR Z,1$
+ JR 3$
+2$:
+ LD A,E
+ DEC A
+ AND #0xF8
+ JR Z,4$
+ JR 8$
+3$:
+ LD B,A
+ CPL
+ LD C,A
+ PUSH DE
+ CALL .wrbyte
+ LD DE,#0x0F
+ ADD HL,DE ;Correct screen address
+ POP DE
+
+8$: LD A,E
+ OR A
+ RET Z
+ AND #0xF8
+ JR Z,4$
+
+ XOR A
+ LD C,A
+ CPL
+ LD B,A
+
+ PUSH DE
+ CALL .wrbyte
+ LD DE,#0x0F
+ ADD HL,DE ;Correct screen address
+ POP DE
+ LD A,E
+ SUB #8
+ RET Z
+ LD E,A
+ JR 8$
+
+4$: LD A,#0x80
+5$: DEC E
+ JR Z,6$
+ SRA A
+ JR 5$
+6$: LD B,A
+ CPL
+ LD C,A
+ JP .wrbyte
+
+ ;; Use Delta Y
+y1:
+ LD A,C
+ SUB E
+ JP NC,y2$
+
+ LD A,B
+ SUB D
+ JR Z,y3$
+ LD A,#0x00
+ JR NC,y3$
+ LD A,#0xFF
+ JR y3$
+
+y2$:
+ LD A,C
+ SUB E
+ JR Z,y2a$
+ LD A,#0x00
+
+; JR NC,y2a$ ; old code; fix draw to up-left below
+; LD A,#0xFF
+
+ LD L,A ; invert delta if x1 less than x2
+ LD A,B
+ SUB D
+ LD A,L
+ JR C,y2a$
+ CPL
+
+y2a$:
+ LD B,D
+ LD C,E ;BC holds start X,Y
+
+y3$:
+ LD (.l_inc),A ;Store X increment
+ LD HL,#.y_table
+ LD D,#0x00
+ LD E,C
+ ADD HL,DE
+ ADD HL,DE
+ LD A,(HL+)
+ LD H,(HL)
+ LD L,A
+
+ LD A,B
+ AND #0xf8
+ LD E,A
+ ADD HL,DE
+ ADD HL,DE
+
+ .if 0
+ ;; Trashed by later instructions
+ LD A,(.mod_col)
+ LD D,A
+ .endif
+
+ LD A,(.delta_y)
+ LD E,A
+ INC E
+
+ LD A,(.delta_x)
+ OR A
+ JP Z,.yonly
+
+ ;; Got to do it the hard way.
+
+ ; Calculate (2*deltax) -> dinc1
+
+ PUSH HL
+ LD H,#0x00
+ LD L,A
+ ADD HL,HL
+ LD A,H
+ LD (.dinc1),A
+ LD A,L
+ LD (.dinc1+1),A
+
+ ; Calculate (2*deltax)-deltay -> d
+
+
+ LD D,H
+ LD E,L
+ LD A,(.delta_y)
+ CPL
+ LD L,A
+ LD H,#0xFF
+ INC HL
+dy1$:
+ ADD HL,DE
+ LD A,H
+ LD (.l_d),A
+ LD A,L
+ LD (.l_d+1),A
+
+ ; Calculate (deltax-deltay)*2 -> dinc2
+
+ LD A,(.delta_y)
+ CPL
+ LD L,A
+ LD H,#0xFF
+ INC HL
+ LD A,(.delta_x)
+ LD D,#0x00
+ LD E,A
+ ADD HL,DE
+ ADD HL,HL
+
+ LD A,H
+ LD (.dinc2),A
+ LD A,L
+ LD (.dinc2+1),A
+
+ POP HL
+
+ .if 0
+ ;; xxx Not used?
+ LD A,(.mod_col)
+ LD D,A
+ .endif
+
+ LD A,(.delta_y)
+ LD E,A
+
+ LD A,B
+ AND #7
+ ADD #<.drawing_bits_tbl ; Table of bits is located at 0x0070
+ LD C,A
+ LD B,#0x00
+ LD A,(BC) ; Get start bit
+ LD B,A
+ LD C,A
+
+yloop$:
+ PUSH DE
+ PUSH BC
+ LD A,B
+ CPL
+ LD C,A
+ CALL .wrbyte
+ INC HL
+ LD A,L
+ AND #0x0F
+ JR NZ,nybound$
+ LD DE,#0x0130
+ ADD HL,DE ;Correct screen address
+nybound$:
+ POP BC
+ LD A,(.l_d)
+ BIT 7,A
+ JR Z,xchg$
+ LD A,(.l_d+1)
+ LD D,A
+ LD A,(.dinc1+1)
+ ADD D
+ LD (.l_d+1),A
+ LD A,(.l_d)
+ LD D,A
+ LD A,(.dinc1)
+ ADC D
+ LD (.l_d),A
+ JR nchgy$
+xchg$:
+ LD A,(.l_inc)
+ OR A
+ JR NZ,yright$
+ RLC B
+ BIT 0,B
+ JR Z,boundy$
+ LD DE,#0xFFF0
+ ADD HL,DE ;Correct screen address
+ JR boundy$
+yright$:
+ RRC B
+ BIT 7,B
+ JR Z,boundy$
+ LD DE,#0x0010
+ ADD HL,DE ;Correct screen address
+boundy$:
+ LD A,(.l_d+1)
+ LD D,A
+ LD A,(.dinc2+1)
+ ADD D
+ LD (.l_d+1),A
+ LD A,(.l_d)
+ LD D,A
+ LD A,(.dinc2)
+ ADC D
+ LD (.l_d),A
+nchgy$:
+ POP DE
+ DEC E
+ JR NZ,yloop$
+ LD A,B
+ CPL
+ LD C,A
+ JP .wrbyte
+
+.yonly::
+ ;; Draw accelerated vertical line
+ LD A,B ;check X
+ AND #7 ;just look at bottom 3 bits
+ PUSH HL
+ ADD #<.drawing_bits_tbl ;Table of bits is located at 0x0070
+ LD L,A
+ LD H,#0x00
+ LD A,(HL) ;Get mask bit
+ POP HL
+ LD B,A
+ CPL
+ LD C,A
+
+1$: PUSH DE
+ CALL .wrbyte
+ INC HL ;Correct screen address
+ LD A,L
+ AND #0x0F
+ JR NZ,2$
+ LD DE,#0x0130
+ ADD HL,DE
+2$: POP DE
+ DEC E
+ RET Z
+ JR 1$
+
+ ;; Draw a point at (B,C) with mode and color D
+.plot::
+
+ LD HL,#.y_table
+ LD D,#0x00
+ LD E,C
+ ADD HL,DE
+ ADD HL,DE
+ LD A,(HL+)
+ LD H,(HL)
+ LD L,A
+
+ LD A,B
+ AND #0xf8
+ LD E,A
+ ADD HL,DE
+ ADD HL,DE
+
+ LD A,B
+
+ AND #7
+ ADD #<.drawing_bits_tbl ; Table of bits is located at 0x0070
+ LD C,A
+ LD B,#0x00
+ LD A,(BC)
+ LD B,A
+ CPL
+ LD C,A
+
+.wrbyte::
+ .if 0
+ LD A,(.mod_col) ; Restore color and mode
+ LD D,A
+
+ BIT 5,D
+ JR NZ,10$
+ BIT 6,D
+ JR NZ,20$
+ BIT 7,D
+ JR NZ,30$
+ .else
+ LD A,(.fg_colour)
+ LD D,A
+ LD A,(.draw_mode)
+ CP #.M_OR
+ JR Z,10$
+ CP #.M_XOR
+ JR Z,20$
+ CP #.M_AND
+ JR Z,30$
+ .endif
+
+ ; Fall through to SOLID by default
+1$:
+ ;; Solid
+ LD E,B
+ .if 0
+ BIT 2,D
+ .else
+ BIT 0,D
+ .endif
+ JR NZ,2$
+ PUSH BC
+ LD B,#0x00
+2$:
+ .if 0
+ BIT 3,D
+ .else
+ BIT 1,D
+ .endif
+ JR NZ,3$
+ LD E,#0x00
+3$:
+ WAIT_STAT
+
+ LD A,(HL)
+ AND C
+ OR B
+ LD (HL+),A
+
+ LD A,(HL)
+ AND C
+ OR E
+ LD (HL),A
+ LD A,B
+ OR A
+ RET NZ
+ POP BC
+ RET
+
+10$:
+ ;; Or
+ LD C,B
+ .if 0
+ BIT 2,D
+ .else
+ BIT 0,D
+ .endif
+ JR NZ,11$
+ LD B,#0x00
+11$:
+ .if 0
+ BIT 3,D
+ .else
+ BIT 1,D
+ .endif
+ JR NZ,12$
+ LD C,#0x00
+12$:
+ WAIT_STAT
+
+ LD A,(HL)
+ OR B
+ LD (HL+),A
+
+ LD A,(HL)
+ OR C
+ LD (HL),A
+ RET
+
+20$:
+ ;; Xor
+ LD C,B
+ .if 0
+ BIT 2,D
+ .else
+ BIT 0,D
+ .endif
+ JR NZ,21$
+ LD B,#0x00
+21$:
+ .if 0
+ BIT 3,D
+ .else
+ BIT 1,D
+ .endif
+ JR NZ,22$
+ LD C,#0x00
+22$:
+ WAIT_STAT
+
+ LD A,(HL)
+ XOR B
+ LD (HL+),A
+
+ LD A,(HL)
+ XOR C
+ LD (HL),A
+ RET
+
+30$:
+ ;; And
+ LD B,C
+ .if 0
+ BIT 2,D
+ .else
+ BIT 0,D
+ .endif
+ JR Z,31$
+ LD B,#0xFF
+31$:
+ .if 0
+ BIT 3,D
+ .else
+ BIT 1,D
+ .endif
+ JR Z,32$
+ LD C,#0xFF
+32$:
+ WAIT_STAT
+
+ LD A,(HL)
+ AND B
+ LD (HL+),A
+
+ LD A,(HL)
+ AND C
+ LD (HL),A
+ RET
+
+ ;; Get color of pixel at point (B,C) returns in A
+.getpix::
+ LD HL,#.y_table
+ LD D,#0x00
+ LD E,C
+ ADD HL,DE
+ ADD HL,DE
+ LD A,(HL+)
+ LD H,(HL)
+ LD L,A
+
+ LD A,B
+ AND #0xf8
+ LD E,A
+ ADD HL,DE
+ ADD HL,DE
+
+ LD A,B
+
+ AND #7
+ ADD #<.drawing_bits_tbl ; Table of bits is located at 0x0070
+ LD C,A
+ LD B,#0x00
+ LD A,(BC)
+ LD C,A
+
+ WAIT_STAT
+
+ LD A,(HL+)
+ LD D,A
+ LD A,(HL+)
+ LD E,A
+ LD B,#0
+ LD A,D
+ AND C
+ JR Z,1$
+ SET 0,B
+1$: LD A,E
+ AND C
+ JR Z,2$
+ SET 1,B
+2$: LD E,B
+ RET
+
+ ;; Write character C
+.wrtchr::
+ LD HL,#.y_table
+ LD D,#0x00
+ LD A,(.ty)
+ RLCA
+ RLCA
+ RLCA
+ LD E,A
+ ADD HL,DE
+ ADD HL,DE
+ LD A,(HL+)
+ LD B, A
+ LD H,(HL)
+ LD L,B
+
+ LD A,(.tx)
+ RLCA
+ RLCA
+ RLCA
+ LD E,A
+ ADD HL,DE
+ ADD HL,DE
+
+ LD A,C
+ LD B,H
+ LD C,L
+
+ LD H,D
+ LD L,A
+ ADD HL,HL
+ ADD HL,HL
+ ADD HL,HL
+
+ .if 0
+ LD DE,#.tp1
+ .else
+ .globl _font_ibm_fixed_tiles
+
+ LD DE,#_font_ibm_fixed_tiles
+ .endif
+
+ ADD HL,DE
+
+ LD D,H
+ LD E,L
+ LD H,B
+ LD L,C
+
+ .if 0
+ LD A,(.mod_col)
+ LD C,A
+ .else
+ LD A,(.fg_colour)
+ LD C,A
+ .endif
+1$:
+ LD A,(DE)
+ INC DE
+ PUSH DE
+
+ .if 1
+ PUSH HL
+ LD HL,#.bg_colour
+ LD L,(HL)
+ .endif
+
+ LD B,A
+ XOR A
+ .if 0
+ BIT 0,C
+ .else
+ BIT 0,L
+ .endif
+ JR Z,2$
+ CPL
+2$: OR B
+ .if 0
+ BIT 2,C
+ .else
+ BIT 0,C
+ .endif
+ JR NZ,3$
+ XOR B
+3$: LD D,A
+ XOR A
+ .if 0
+ BIT 1,C
+ .else
+ BIT 1,L
+ .endif
+ JR Z,4$
+ CPL
+4$: OR B
+ .if 0
+ BIT 3,C
+ .else
+ BIT 1,C
+ .endif
+ JR NZ,5$
+ XOR B
+5$:
+ LD E,A
+ .if 1
+ POP HL
+ .endif
+
+ WAIT_STAT
+
+ LD A,D
+ LD (HL+),A
+ LD A,E
+ LD (HL+),A
+ POP DE
+ LD A,L
+ AND #0x0F
+ JR NZ,1$
+ RET
+
+_gotogxy::
+ LDA HL,2(SP) ; Skip return address
+ LD A,(HL+) ; A = x
+ LD (.tx),A
+ LD A,(HL+) ; A = y
+ LD (.ty),A
+
+ RET
+
+_wrtchr::
+ PUSH BC
+
+ LD A,(.mode)
+ CP #.G_MODE
+ CALL NZ,.gmode
+
+ LDA HL,4(SP) ; Skip return address and registers
+ LD A,(HL)
+ LD C,A ; C = Char to print
+
+ CALL .wrtchr
+ CALL .adv_gcurs
+
+ POP BC
+ RET
+
+_getpix::
+ PUSH BC
+
+ LDA HL,4(SP) ; Skip return address and registers
+ LD A,(HL+) ; B = x
+ LD B,A
+ LD A,(HL+) ; C = y
+ LD C,A
+
+ CALL .getpix
+
+ POP BC
+ RET
+
+_circle::
+ PUSH BC
+
+ LD A,(.mode)
+ CP #.G_MODE
+ CALL NZ,.gmode
+
+ LDA HL,4(SP) ; Skip return address and registers
+ LD A,(HL+) ; B = x
+ LD B,A
+ LD A,(HL+) ; C = y
+ LD C,A
+ LD A,(HL+) ; D = Radius
+ LD D,A
+ LD A,(HL)
+ LD (.style),A
+
+ CALL .circle
+
+ POP BC
+ RET
+
+_box::
+ PUSH BC
+
+ LD A,(.mode)
+ CP #.G_MODE
+ CALL NZ,.gmode
+
+ LDA HL,4(SP) ; Skip return address and registers
+ LD A,(HL+) ; B = x1
+ LD (.x_s),A
+ LD A,(HL+) ; C = y1
+ LD (.y_s),A
+ LD A,(HL+) ; D = x2
+ LD (.x_s+1),A
+ LD A,(HL+) ; E = y2
+ LD (.y_s+1),A
+ LD A,(HL)
+ LD (.style),A
+ CALL .box
+ POP BC
+ RET
+
+_line::
+ PUSH BC
+
+ LD A,(.mode)
+ CP #.G_MODE
+ CALL NZ,.gmode
+
+ LDA HL,4(SP) ; Skip return address and registers
+ LD A,(HL+) ; B = x1
+ LD B,A
+ LD A,(HL+) ; C = y1
+ LD C,A
+ LD A,(HL+) ; D = x2
+ LD D,A
+ LD A,(HL+) ; E = y2
+ LD E,A
+
+ CALL .line
+
+ POP BC
+ RET
+
+_plot_point::
+ PUSH BC
+
+ LD A,(.mode)
+ CP #.G_MODE
+ CALL NZ,.gmode
+
+ LDA HL,4(SP) ; Skip return address and registers
+ LD A,(HL+) ; B = x
+ LD B,A
+ LD A,(HL+) ; C = y
+ LD C,A
+
+ CALL .plot
+
+ POP BC
+ RET
+
+ ;; Old, compatible version of plot()
+_plot::
+ PUSH BC
+
+ LD A,(.mode)
+ CP #.G_MODE
+ CALL NZ,.gmode
+
+ LDA HL,4(SP) ; Skip return address and registers
+ LD A,(HL+) ; B = x
+ LD B,A
+ LD A,(HL+) ; C = y
+ LD C,A
+ LD A,(HL+) ; colour
+ LD (.fg_colour),A
+ LD A,(HL+) ; mode
+ LD (.draw_mode),A
+
+ CALL .plot
+
+ POP BC
+ RET
+
+_switch_data:: ; Non Banked as pointer
+ PUSH BC
+
+ LD A,(.mode)
+ CP #.G_MODE
+ CALL NZ,.gmode
+
+ LDA HL,4(SP) ; Skip return address and registers
+ LD A,(HL+) ; B = x
+ LD B,A
+ LD A,(HL+) ; C = y
+ LD C,A
+ LD A,(HL+) ; DE = src
+ LD E,A
+ LD A,(HL+)
+ LD D,A
+ LD A,(HL+) ; HL = dst
+ LD H,(HL)
+ LD L,A
+
+ CALL .switch_data
+
+ POP BC
+ RET
+
+
+_draw_image:: ; Non banked as pointer
+ PUSH BC
+
+ LD A,(.mode)
+ CP #.G_MODE
+ CALL NZ,.gmode
+
+ LDA HL,4(SP) ; Skip return address and registers
+ LD A,(HL+) ; HL = data
+ LD C,A
+ LD B,(HL)
+
+ CALL .draw_image
+
+ POP BC
+ RET
+
+.y_table::
+ .word 0x8100,0x8102,0x8104,0x8106,0x8108,0x810A,0x810C,0x810E
+ .word 0x8240,0x8242,0x8244,0x8246,0x8248,0x824A,0x824C,0x824E
+ .word 0x8380,0x8382,0x8384,0x8386,0x8388,0x838A,0x838C,0x838E
+ .word 0x84C0,0x84C2,0x84C4,0x84C6,0x84C8,0x84CA,0x84CC,0x84CE
+ .word 0x8600,0x8602,0x8604,0x8606,0x8608,0x860A,0x860C,0x860E
+ .word 0x8740,0x8742,0x8744,0x8746,0x8748,0x874A,0x874C,0x874E
+ .word 0x8880,0x8882,0x8884,0x8886,0x8888,0x888A,0x888C,0x888E
+ .word 0x89C0,0x89C2,0x89C4,0x89C6,0x89C8,0x89CA,0x89CC,0x89CE
+ .word 0x8B00,0x8B02,0x8B04,0x8B06,0x8B08,0x8B0A,0x8B0C,0x8B0E
+ .word 0x8C40,0x8C42,0x8C44,0x8C46,0x8C48,0x8C4A,0x8C4C,0x8C4E
+ .word 0x8D80,0x8D82,0x8D84,0x8D86,0x8D88,0x8D8A,0x8D8C,0x8D8E
+ .word 0x8EC0,0x8EC2,0x8EC4,0x8EC6,0x8EC8,0x8ECA,0x8ECC,0x8ECE
+ .word 0x9000,0x9002,0x9004,0x9006,0x9008,0x900A,0x900C,0x900E
+ .word 0x9140,0x9142,0x9144,0x9146,0x9148,0x914A,0x914C,0x914E
+ .word 0x9280,0x9282,0x9284,0x9286,0x9288,0x928A,0x928C,0x928E
+ .word 0x93C0,0x93C2,0x93C4,0x93C6,0x93C8,0x93CA,0x93CC,0x93CE
+ .word 0x9500,0x9502,0x9504,0x9506,0x9508,0x950A,0x950C,0x950E
+ .word 0x9640,0x9642,0x9644,0x9646,0x9648,0x964A,0x964C,0x964E
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/drawing_isr.s b/gbdk/gbdk-lib/libc/targets/sm83/drawing_isr.s
new file mode 100644
index 00000000..e12a478c
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/drawing_isr.s
@@ -0,0 +1,23 @@
+ .include "global.s"
+
+ .area _HOME
+
+.drawing_vbl::
+ LDH A,(.LCDC)
+ OR #LCDCF_BG8000 ; Set BG Chr to 0x8000
+ LDH (.LCDC),A
+
+ LD A,#72 ; Set line at which LCD interrupt occurs
+ LDH (.LYC),A
+
+ RET
+
+ ;; Is the STAT check required, as we are already in the HBL?
+.drawing_lcd::
+ WAIT_STAT
+
+ LDH A,(.LCDC)
+ AND #~LCDCF_BG8000 ; Set BG Chr to 0x8800
+ LDH (.LCDC),A
+
+ RET
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/duck/Makefile b/gbdk/gbdk-lib/libc/targets/sm83/duck/Makefile
new file mode 100644
index 00000000..40007176
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/duck/Makefile
@@ -0,0 +1,47 @@
+# GB specific Makefile
+
+TOPDIR = ../../../..
+
+THIS = duck
+PORT = sm83
+
+CSRC = crlf.c digits.c gprint.c gprintf.c gprintln.c gprintn.c
+
+ASSRC = cgb.s cgb_palettes.s cgb_compat.s \
+ cpy_data.s \
+ drawing.s drawing_isr.s color.s \
+ f_ibm_full.s f_ibm_sh.s f_italic.s f_min.s f_spect.s \
+ get_bk_t.s get_data.s get_tile.s \
+ get_wi_t.s get_xy_t.s \
+ get_addr.s \
+ hiramcpy.s init_tt.s input.s \
+ pad.s \
+ serial.s set_bk_t.s set_tile.s \
+ set_data.s set_prop.s set_spr.s set_wi_t.s set_xy_t.s \
+ set_1bit_data.s \
+ sgb.s font.s font_color.s delay.s \
+ emu_debug.s emu_debug_printf.s \
+ nowait.s far_ptr.s \
+ lcd.s joy.s tim.s tim.s tim_nested.s tim_common.s \
+ crash_handler.s \
+ ___sdcc_bcall_ehl.s ___sdcc_bcall.s \
+ mv_spr.s \
+ pad_ex.s \
+ mode.s clock.s \
+ get_t.s set_t.s init_vram.s \
+ fill_rect.s fill_rect_bk.s fill_rect_wi.s \
+ metasprites.s metasprites_flip.s metasprites_hide.s metasprites_hide_spr.s \
+ set_tile_submap.s set_win_tile_submap.s \
+ gb_decompress.s gb_decompress_tiles.s \
+ rle_decompress.s \
+ heap.s \
+ sfr.s \
+ crt0.s
+
+CRT0 = crt0.s
+
+include $(TOPDIR)/Makefile.common
+
+AS = $(AS_SM83)
+
+include ../../../Makefile.platform
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/duck/crash_handler.s b/gbdk/gbdk-lib/libc/targets/sm83/duck/crash_handler.s
new file mode 100644
index 00000000..889ab300
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/duck/crash_handler.s
@@ -0,0 +1,476 @@
+; Crash handler support
+; Original code by ISSOtm
+; Adapted by Toxa from gb-starter-kit: https://github.com/ISSOtm/gb-starter-kit
+
+ .include "global.s"
+
+ .globl _font_ibm
+
+ SCRN_X = 160 ; Width of screen in pixels
+ SCRN_Y = 144 ; Height of screen in pixels
+ SCRN_X_B = 20 ; Width of screen in bytes
+ SCRN_Y_B = 18 ; Height of screen in bytes
+
+ SCRN_VX = 256 ; Virtual width of screen in pixels
+ SCRN_VY = 256 ; Virtual height of screen in pixels
+ SCRN_VX_B = 32 ; Virtual width of screen in bytes
+ SCRN_VY_B = 32 ; Virtual height of screen in bytes
+
+
+ .area _CRASH_HEADER(ABS)
+
+ .org 0x38
+ di
+ jp ___HandleCrash
+
+
+ .area _HOME
+
+___HandleCrash::
+
+ ; We will use VRAM as scratch, since we are going to overwrite it for
+ ; screen output anyways. The thing is, we need to turn the LCD off
+ ; *without* affecting flags... fun task, eh?
+
+ ; Note: it's assumed that this was jumped to with IME off.
+ ; Don't call this directly, use `rst Crash`.
+
+ ld (wCrashA), a ; We need to have at least one working register, so...
+ ldh a, (.IE) ; We're also going to overwrite this
+ ld (wCrashIE), a
+ ldh a, (.LCDC)
+ ld (wCrashLCDC), a
+ ld a, #LCDCF_ON ; LCDCF_ON Make sure the LCD is turned on to avoid waiting infinitely
+ ldh (.LCDC), a
+ ld a, #IEF_VBLANK ; IEF_VBLANK
+ ld (.IE), a
+ ld a, #0 ; `xor a` would overwrite flags
+ ld (.IF), a ; No point in backing up that register, it's always changing
+ halt ; With interrupts disabled, this will exit when `IE & IF != 0`
+ nop ; Handle hardware bug if it becomes true *before* starting to execute the instruction (1-cycle window)
+
+ ; We're now in VBlank! So we can now use VRAM as scratch for some cycles
+ ld a, #0
+ ldh (.LCDC), a ; Turn off LCD so VRAM can always be safely accessed
+ ; Save regs
+ ld (vCrashSP), sp
+ ld sp, #vCrashSP
+ push hl
+ push de
+ push bc
+ ld a, (wCrashA)
+ push af
+
+ ; We need to have all the data in bank 0, but we can't guarantee we were there
+ ldh a, (.VBK)
+ ld e, a
+ bit #0, a
+ jr z, .bank0
+ ; Oh noes. We need to copy the data across banks!
+ ld hl, #vCrashAF
+ ld c, #(5 * 2)
+.copyAcross:
+ ld b, (hl)
+ xor a
+ ldh (.VBK), a
+ ld (hl), b
+ inc l ; inc hl
+ inc a ; ld a, 1
+ ldh (.VBK), a
+ dec c
+ jr nz, .copyAcross
+.bank0:
+ xor a
+ ldh (.NR52), a ; Kill sound for this screen
+
+ ldh (.VBK), a
+ ld a, e
+ ld (vCrashVBK), a ; copy vCrashVBK across banks
+
+ ld a, #1
+ ldh (.VBK), a
+ ld hl, #vCrashDumpScreen
+ ld b, #SCRN_Y_B
+.writeAttrRow:
+ xor a
+ ld c, #(SCRN_X_B + 1)
+ rst #0x28 ; .MemsetSmall
+ ld a, l
+ add a, #(SCRN_VX_B - SCRN_X_B - 1)
+ ld l, a
+ dec b
+ jr nz, .writeAttrRow
+ xor a
+ ldh (.VBK), a
+
+ ; Load palettes
+ ld a, #0x03
+ ldh (.BGP), a
+ ld a, #0x80
+ ldh (.BCPS), a
+ xor a
+ ld c, #.BCPD
+ ldh (c), a
+ ldh (c), a
+ dec a ; ld a, $FF
+ ldh (c), a
+ ldh (c), a
+ ldh (c), a
+ ldh (c), a
+ ldh (c), a
+ ldh (c), a
+
+ ld a, #(SCRN_VY - SCRN_Y)
+ ldh (.SCY), a
+ ld a, #(SCRN_VX - SCRN_X - 4)
+ ldh (.SCX), a
+
+ call loadfont
+
+ ; Copy the registers to the dump viewers
+ ld hl, #vDumpHL
+ ld de, #vCrashHL
+ ld c, #4
+ rst #0x30 ; .MemcpySmall
+
+ ; We're now going to draw the screen, top to bottom
+ ld hl, #vCrashDumpScreen
+
+ ; First 3 lines of text
+ ld de, #.header
+ ld b, #3
+.writeHeaderLine:
+ ld a, #0x20 ; " "
+ ld (hl+), a
+ ld c, #19
+ rst #0x30 ; .MemcpySmall
+ ld a, #0x20 ; " "
+ ld (hl+), a
+ ld a, l
+ add a, #(SCRN_VX_B - SCRN_X_B - 1)
+ ld l, a
+ dec b
+ jr nz, .writeHeaderLine
+
+ ; Blank line
+ ld a, #0x20 ; " "
+ ld c, #(SCRN_X_B + 1)
+ rst #0x28 ; .MemsetSmall
+
+ ; AF and console model
+ ld l, #<vCrashDumpScreenRow4
+ ld c, #4
+ rst #0x30 ; .MemcpySmall
+ pop bc
+ call .printHexBC
+ ld c, #8
+ rst #0x30 ; .MemcpySmall
+ ld a, (__cpu)
+ call .printHexA
+ ld a, #0x20 ; " "
+ ld (hl+), a
+ ld (hl+), a
+ ld (hl+), a
+
+ ; BC and DE
+ ld l, #<vCrashDumpScreenRow5
+ ld c, #4
+ rst #0x30 ; .MemcpySmall
+ pop bc
+ call .printHexBC
+ ld c, #6
+ rst #0x30 ; .MemcpySmall
+ pop bc
+ call .printHexBC
+ ld a, #0x20
+ ld (hl+), a
+ ld (hl+), a
+ ld (hl+), a
+
+ ; Now, the two memory dumps
+.writeDump:
+ ld a, l
+ add a, #(SCRN_VX_B - SCRN_X_B - 1)
+ ld l, a
+ ld c, #4
+ rst #0x30 ; .MemcpySmall
+ pop bc
+ push bc
+ call .printHexBC
+ ld de, #.viewStr
+ ld c, #7
+ rst #0x30 ; .MemcpySmall
+ pop de
+ call .printDump
+ ld de, #.spStr
+ bit #7, l
+ jr z, .writeDump
+
+ ld de, #.hwRegsStrs
+ ld l, #<vCrashDumpScreenRow14
+ ld c, #6
+ rst #0x30 ; .MemcpySmall
+ ld a, (wCrashLCDC)
+ call .printHexA
+ ld c, #4
+ rst #0x30 ; .MemcpySmall
+ ldh a, (.KEY1)
+ call .printHexA
+ ld c, #4
+ rst #0x30 ; .MemcpySmall
+ ld a, (wCrashIE)
+ call .printHexA
+ ld (hl), #0x20 ; " "
+
+ ld l, #<vCrashDumpScreenRow15
+ ld c, #7
+ rst #0x30 ; .MemcpySmall
+.writeBank:
+ ld a, #0x20 ; " "
+ ld (hl+), a
+ ld a, (de)
+ inc de
+ ld (hl+), a
+ cp #0x20 ; " "
+ jr z, .banksDone
+ ld a, (de)
+ inc de
+ ld c, a
+ ld a, (de)
+ inc de
+ ld b, a
+ ld a, (bc)
+ call .printHexA
+ jr .writeBank
+.banksDone:
+
+ ; Start displaying
+ ld a, #(LCDCF_ON | LCDCF_BG9C00 | LCDCF_BGON)
+ ldh (.LCDC), a
+
+.loop:
+ ; The code never lags, and IE is equal to IEF_VBLANK
+ xor a
+ ldh (.IF), a
+ halt
+
+ jr .loop
+
+.printHexBC:
+ call .printHexB
+ ld a, c
+.printHexA:
+ ld b, a
+.printHexB:
+ ld a, b
+ and #0xF0
+ swap a
+ add a, #0x30
+ cp #0x3a
+ jr c, 1$
+ add a, #(0x41 - 0x3a)
+1$: ld (hl+), a
+ ld a, b
+ and #0x0F
+ add a, #0x30
+ cp #0x3a
+ jr c, 2$
+ add a, #(0x41 - 0x3a)
+2$: ld (hl+), a
+ ret
+
+.printDump:
+ ld b, d
+ ld c, e
+ call .printHexBC
+ ld a, #0x20 ; " "
+ ld (hl+), a
+ ld (hl+), a
+ ld a, e
+ sub #8
+ ld e, a
+ ld a, d
+ sbc #0
+ ld d, a
+.writeDumpLine:
+ ld a, l
+ add a, #(SCRN_VX_B - SCRN_X_B - 1)
+ ld l, a
+ ld a, #0x20 ; " "
+ ld (hl+), a
+.writeDumpWord:
+ ld a, (de)
+ inc de
+ call .printHexA
+ ld a, (de)
+ inc de
+ call .printHexA
+ ld a, #0x20 ; " "
+ ld (hl+), a
+ bit 4, l
+ jr nz, .writeDumpWord
+ ld a, l
+ and #0x7F
+ jr nz, .writeDumpLine
+ ret
+
+loadfont:
+ xor a
+ cpl
+ ld hl, #0x9000
+ ld c, #16
+ rst #0x28 ; .MemsetSmall
+ ld hl, #(0x9000 + ' ' * 16)
+ ld c, #16
+ rst #0x28 ; .MemsetSmall
+
+ ld de, #(_font_ibm + 2 + '0') ; recode table
+ ld hl, #(0x9000 + '0' * 16) ; destination
+ push hl
+ ld c, #(16 * 3)
+1$:
+ ld a, (de)
+ inc de
+ push de
+
+ swap a
+ ld l, a
+ and #0x0f
+ ld h, a
+ ld a, l
+ and #0xf0
+ srl h
+ rra
+ ld l, a
+ ld de, #(_font_ibm + 2 + 128)
+ add hl, de
+
+ ld d, h
+ ld e, l
+
+ ldhl sp, #2
+ ld a, (hl+)
+ ld h, (hl)
+ ld l, a
+
+ ld b, #8
+2$:
+ ld a, (de)
+ cpl
+ inc de
+ ld (hl+), a
+ ld (hl+), a
+
+ dec b
+ jr nz, 2$
+
+ ld d, h
+ ld a, l
+ ldhl sp, #2
+ ld (hl+), a
+ ld (hl), d
+
+ pop de
+
+ dec c
+ jr nz, 1$
+
+ add sp, #2
+ ret
+
+.header:
+ ; 0123456789ABCDEFGHI 19 chars
+ .ascii "KERNEL PANIC PLEASE"
+ .ascii "SEND A CLEAR PIC OF"
+ .ascii "THIS SCREEN TO DEVS"
+ .ascii " AF:"
+ .ascii " MODEL:"
+ .ascii " BC:"
+ .ascii " DE:"
+ .ascii " HL:"
+.viewStr:
+ .ascii " VIEW:"
+.spStr:
+ .ascii " SP:"
+.hwRegsStrs:
+ .ascii " LCDC:"
+ .ascii " K1:"
+ .ascii " IE:"
+ .ascii " BANK:"
+ .ascii "R"
+ .dw __current_bank
+ .ascii "V"
+ .dw vCrashVBK
+ .ascii "W"
+ .db .SVBK, 0xff
+ .ascii " "
+
+
+ .area _DATA
+
+wCrashA:
+ .ds 1 ; We need at least one working register, and A allows accessing memory
+wCrashIE:
+ .ds 1
+wCrashLCDC:
+ .ds 1
+
+
+ .area _CRASH_SCRATCH(ABS)
+
+ .org 0x9C00
+
+ ; Put the crash dump screen at the bottom-right of the 9C00 tilemap, since that tends to be unused space
+ .ds SCRN_VX_B * (SCRN_VY_B - SCRN_Y_B - 2) ; 2 rows reserved as scratch space
+
+ .ds SCRN_X_B ; Try not to overwrite the window area
+ .ds 2 * 1 ; Free stack entries (we spill into the above by 1 entry, though :/)
+ ; These are the initial values of the registers
+ ; They are popped off the stack when printed, freeing up stack space
+
+vCrashAF:
+ .ds 2
+vCrashBC:
+ .ds 2
+vCrashDE:
+ .ds 2
+vCrashHL:
+ .ds 2
+vCrashSP:
+ .ds 2
+
+ .ds SCRN_X_B
+vHeldKeys:
+ .ds 1 ; Keys held on previous frame
+vUnlockCounter:
+ .ds 1 ; How many frames until dumps are "unlocked"
+vWhichDump:
+ .ds 1
+vDumpHL:
+ .ds 2
+vDumpSP:
+ .ds 2
+vCrashVBK:
+ .ds 1
+ .ds 4 ; Unused
+
+ .ds SCRN_VX_B - SCRN_X_B - 1
+vCrashDumpScreen:
+vCrashDumpScreenRow0 = vCrashDumpScreen + 1 * SCRN_VX_B
+vCrashDumpScreenRow1 = vCrashDumpScreen + 2 * SCRN_VX_B
+vCrashDumpScreenRow2 = vCrashDumpScreen + 3 * SCRN_VX_B
+vCrashDumpScreenRow3 = vCrashDumpScreen + 4 * SCRN_VX_B
+vCrashDumpScreenRow4 = vCrashDumpScreen + 5 * SCRN_VX_B
+vCrashDumpScreenRow5 = vCrashDumpScreen + 6 * SCRN_VX_B
+vCrashDumpScreenRow6 = vCrashDumpScreen + 7 * SCRN_VX_B
+vCrashDumpScreenRow7 = vCrashDumpScreen + 8 * SCRN_VX_B
+vCrashDumpScreenRow8 = vCrashDumpScreen + 9 * SCRN_VX_B
+vCrashDumpScreenRow9 = vCrashDumpScreen + 10 * SCRN_VX_B
+vCrashDumpScreenRow10 = vCrashDumpScreen + 11 * SCRN_VX_B
+vCrashDumpScreenRow11 = vCrashDumpScreen + 12 * SCRN_VX_B
+vCrashDumpScreenRow12 = vCrashDumpScreen + 13 * SCRN_VX_B
+vCrashDumpScreenRow13 = vCrashDumpScreen + 14 * SCRN_VX_B
+vCrashDumpScreenRow14 = vCrashDumpScreen + 15 * SCRN_VX_B
+vCrashDumpScreenRow15 = vCrashDumpScreen + 16 * SCRN_VX_B
+vCrashDumpScreenRow16 = vCrashDumpScreen + 17 * SCRN_VX_B
+vCrashDumpScreenRow17 = vCrashDumpScreen + 18 * SCRN_VX_B
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/duck/crt0.s b/gbdk/gbdk-lib/libc/targets/sm83/duck/crt0.s
new file mode 100644
index 00000000..0022cc42
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/duck/crt0.s
@@ -0,0 +1,468 @@
+ .include "global.s"
+
+ ;; ****************************************
+ ;; Beginning of module
+ ;; BANKED: checked
+ .title "Runtime"
+ .module Runtime
+ .area _HEADER (ABS)
+
+ ;; RST vectors
+ .org 0x00 ; MEGADUCK entry point/reset
+ JP .code_start
+
+; .org 0x08 ; --profile handler utilized by emu_debug.h
+
+; .org 0x10 ; empty
+
+; .org 0x18 ; empty
+
+ .org 0x20 ; RST 0x20 == call HL
+.call_hl::
+ JP (HL)
+
+ .org 0x28 ; zero up to 256 bytes in C pointed by HL
+.MemsetSmall::
+ LD (HL+),A
+ DEC C
+ JR NZ,.MemsetSmall
+ ret
+
+ .org 0x30 ; copy up to 256 bytes in C from DE to HL
+.MemcpySmall::
+ LD A, (DE)
+ LD (HL+), A
+ INC DE
+ DEC C
+ JR NZ,.MemcpySmall
+ RET
+
+; .org 0x38 ; crash handler utilized by crash_handler.h
+
+ ;; Hardware interrupt vectors
+ .org 0x40 ; VBL
+.int_VBL:
+ PUSH AF
+ PUSH HL
+ LD HL,#.int_0x40
+ JP .int
+
+; .org 0x48 ; LCD
+
+; .org 0x50 ; TIM
+
+; .org 0x58 ; SIO
+
+; .org 0x60 ; JOY
+
+; .org 0x70
+ ;; space for drawing.s bit table
+
+ .org 0x80
+.int::
+ PUSH BC
+ PUSH DE
+1$:
+ LD A,(HL+)
+ OR (HL)
+ JR Z,.int_tail
+ PUSH HL
+ LD A,(HL-)
+ LD L,(HL)
+ LD H,A
+ RST 0x20 ; .call_hl
+ POP HL
+ INC HL
+ JR 1$
+_wait_int_handler::
+ ADD SP,#4
+.int_tail:
+ POP DE
+ POP BC
+ POP HL
+
+ ;; we return at least at the beginning of mode 2
+ WAIT_STAT
+
+ POP AF
+ RETI
+
+ ;; VBlank default interrupt routine
+__standard_VBL_handler::
+.std_vbl:
+ LD HL,#.sys_time
+ INC (HL)
+ JR NZ,2$
+ INC HL
+ INC (HL)
+2$:
+ CALL .refresh_OAM
+
+ LD A, #1
+ LDH (.vbl_done),A
+ RET
+
+_refresh_OAM::
+ WAIT_STAT
+ LD A, #>_shadow_OAM
+ JP .refresh_OAM + (.refresh_OAM_DMA - .start_refresh_OAM)
+
+.clear_WRAM:
+ PUSH DE
+ XOR A
+ LD BC, #l__DATA
+ LD HL, #s__DATA
+ CALL .memset_simple
+
+ LD A, #>_shadow_OAM
+ LDH (__shadow_OAM_base), A
+ LD H, A
+ XOR A
+ LD L, A
+ LD C, #(40 << 2) ; 40 entries 4 bytes each
+ RST 0x28
+ POP DE
+ RET
+
+ .org 0x150
+
+ ;; soft reset: falldown to .code_start
+.reset::
+_reset::
+
+ ;; Initialization code
+.code_start::
+ DI ; Disable interrupts
+ ;; Initialize the stack
+ LD SP, #.STACK
+
+ CALL .clear_WRAM
+
+; LD (.mode),A ; Clearing (.mode) is performed when clearing RAM
+
+ ;; Store CPU type
+ LD A, #.DMG_TYPE ; MEGADUCK is always a DMG
+ LD (__cpu), A
+ XOR A
+ LD (__is_GBA), A ; and it is never GBA
+
+ ;; Turn the screen off
+ CALL .display_off
+
+ XOR A
+ ;; Initialize the display
+ LDH (.SCY),A
+ LDH (.SCX),A
+ LDH (.STAT),A
+ LDH (.WY),A
+ LD A,#0x07
+ LDH (.WX),A
+
+ ;; Copy refresh_OAM routine to HRAM
+ LD DE,#.start_refresh_OAM ; source
+ LD HL,#.refresh_OAM ; dest
+ LD C,#(.end_refresh_OAM - .start_refresh_OAM) ; size
+ RST 0x30 ; call .MemcpySmall
+
+ ;; Clear the OAM by calling refresh_OAM
+ CALL .refresh_OAM
+
+ ;; Install interrupt routines
+ LD BC,#.std_vbl
+ CALL .add_VBL
+
+ ;; Standard color palettes
+ LD A,#0b11100100 ; Grey 3 = 11 (Black)
+ ; Grey 2 = 10 (Dark grey)
+ ; Grey 1 = 01 (Light grey)
+ ; Grey 0 = 00 (Transparent)
+ LDH (.BGP),A
+ LDH (.OBP0),A
+ LD A,#0b00011011
+ LDH (.OBP1),A
+
+ ;; Turn the screen on
+ LD A,#(LCDCF_ON | LCDCF_WIN9C00 | LCDCF_WINOFF | LCDCF_BG8800 | LCDCF_BG9800 | LCDCF_OBJ8 | LCDCF_OBJOFF | LCDCF_BGOFF)
+ LDH (.LCDC),A
+ XOR A
+ LDH (.IF),A
+ LD A,#.VBL_IFLAG ; switch on VBlank interrupt only
+ LDH (.IE),A
+
+ LDH (__current_bank),A ; current bank is 1 at startup
+
+ XOR A
+
+ LD HL,#.sys_time
+ LD (HL+),A
+ LD (HL),A
+
+ LDH (.NR52),A ; Turn sound off
+
+ CALL gsinit
+
+ EI ; Enable interrupts
+
+ ;; Call the main function
+ CALL _main
+_exit::
+99$:
+ HALT
+ NOP
+ JR 99$ ; Wait forever
+
+_set_interrupts::
+ DI
+ LDA HL,2(SP) ; Skip return address
+ XOR A
+ LDH (.IF),A ; Clear pending interrupts
+ LD A,(HL)
+ EI ; Enable interrupts
+ LDH (.IE),A ; interrupts are still disabled here
+ RET
+
+ ;; Copy OAM data to OAM RAM
+.start_refresh_OAM:
+ LDH A,(__shadow_OAM_base)
+ OR A
+ RET Z
+.refresh_OAM_DMA:
+ LDH (.DMA),A ; Put A into DMA registers
+ LD A,#0x28 ; We need to wait 160 ns
+1$:
+ DEC A
+ JR NZ,1$
+ RET
+.end_refresh_OAM:
+
+ .org .MODE_TABLE
+ ;; Jump table for modes
+ RET
+
+ ;; ****************************************
+
+ ;; Ordering of segments for the linker
+ ;; Code that really needs to be in bank 0
+ .area _HOME
+ ;; Similar to _HOME
+ .area _BASE
+ ;; Code
+ .area _CODE
+ ;; #pragma bank 0 workaround
+ .area _CODE_0
+ ;; Constant data
+ .area _LIT
+; ;; since _CODE_1 area base address is pre-defined in the linker from 0x4000,
+; ;; that moves initializer code and tables out of bank 0
+; .area _CODE_1
+ ;; Constant data, used to init _DATA
+ .area _INITIALIZER
+ ;; Code, used to init _DATA
+ .area _GSINIT
+ .area _GSFINAL
+ ;; Uninitialised ram data
+ .area _DATA
+ .area _BSS
+ ;; Initialised in ram data
+ .area _INITIALIZED
+ ;; For malloc
+ .area _HEAP
+ .area _HEAP_END
+
+ .area _DATA
+__cpu::
+ .ds 0x01 ; GB type (GB, PGB, CGB)
+__is_GBA::
+ .ds 0x01 ; detect GBA
+.mode::
+ .ds 0x01 ; Current mode
+.sys_time::
+_sys_time::
+ .ds 0x02 ; System time in VBL units
+.int_0x40::
+ .blkw 0x0A ; 4 interrupt handlers (built-in + user-defined)
+
+ .area _HRAM (ABS)
+
+ .org 0xFF90
+__current_bank:: ; Current bank
+ .ds 0x01
+.vbl_done:
+ .ds 0x01 ; Is VBL interrupt finished?
+__shadow_OAM_base::
+ .ds 0x01
+
+ ;; Runtime library
+ .area _GSINIT
+gsinit::
+ ;; initialize static storage variables
+ LD BC, #l__INITIALIZER
+ LD HL, #s__INITIALIZER
+ LD DE, #s__INITIALIZED
+ call .memcpy_simple
+
+ .area _GSFINAL
+ ret
+
+ .area _HOME
+
+ ;; fills memory at HL of length BC with A, clobbers DE
+.memset_simple::
+ LD E, A
+ LD A, B
+ OR C
+ RET Z
+ LD (HL), E
+ DEC BC
+ LD D, H
+ LD E, L
+ INC DE
+
+ ;; copies BC bytes from HL into DE
+.memcpy_simple::
+ LD A, B
+ OR C
+ RET Z
+
+ SRL B
+ RR C
+ JR NC,3$
+ LD A, (HL+)
+ LD (DE), A
+ INC DE
+3$:
+ INC B
+ INC C
+ JR 2$
+1$:
+ LD A, (HL+)
+ LD (DE), A
+ INC DE
+ LD A, (HL+)
+ LD (DE), A
+ INC DE
+2$:
+ DEC C
+ JR NZ,1$
+ DEC B
+ JR NZ,1$
+4$:
+ RET
+
+ ;; Remove interrupt routine in BC from the VBL interrupt list
+ ;; falldown to .remove_int
+.remove_VBL::
+ LD HL,#.int_0x40
+
+ ;; Remove interrupt BC from interrupt list HL if it exists
+ ;; Abort if a 0000 is found (end of list)
+.remove_int::
+1$:
+ LD A,(HL+)
+ LD E,A
+ LD D,(HL)
+ INC HL
+ OR D
+ RET Z ; No interrupt found
+
+ LD A,E
+ CP C
+ JR NZ,1$
+ LD A,D
+ CP B
+ JR NZ,1$
+
+ LD D,H
+ LD E,L
+ DEC DE
+ DEC DE
+
+ ;; Now do a memcpy from here until the end of the list
+2$:
+ LD A,(HL+)
+ LD (DE),A
+ LD B,A
+ INC DE
+ LD A,(HL+)
+ LD (DE),A
+ INC DE
+ OR B
+ RET Z
+ JR 2$
+
+ ;; Add interrupt routine in BC to the VBL interrupt list
+ ;; falldown to .add_int
+.add_VBL::
+ LD HL,#.int_0x40
+
+ ;; Add interrupt routine in BC to the interrupt list in HL
+.add_int::
+1$:
+ LD A,(HL+)
+ OR (HL)
+ JR Z,2$
+ INC HL
+ JR 1$
+2$:
+ LD A,B
+ LD (HL-),A
+ LD (HL),C
+ RET
+
+ ;; Wait for VBL interrupt to be finished
+.wait_vbl_done::
+_wait_vbl_done::
+ ;; Check if the screen is on
+ LDH A,(.LCDC)
+ AND #LCDCF_ON
+ RET Z ; Return if screen is off
+ XOR A
+ LDH (.vbl_done),A ; Clear any previous sets of vbl_done
+1$:
+ HALT ; Wait for any interrupt
+ NOP ; HALT sometimes skips the next instruction
+ LDH A,(.vbl_done) ; Was it a VBlank interrupt?
+ ;; Warning: we may lose a VBlank interrupt, if it occurs now
+ OR A
+ JR Z,1$ ; No: back to sleep!
+ RET
+
+.display_off::
+_display_off::
+ ;; Check if the screen is on
+ LDH A,(.LCDC)
+ AND #LCDCF_ON
+ RET Z ; Return if screen is off
+1$: ; We wait for the *NEXT* VBL
+ LDH A,(.LY)
+ CP #0x92 ; Smaller than or equal to 0x91?
+ JR NC,1$ ; Loop until smaller than or equal to 0x91
+2$:
+ LDH A,(.LY)
+ CP #0x91 ; Bigger than 0x90?
+ JR C,2$ ; Loop until bigger than 0x90
+
+ LDH A,(.LCDC)
+ AND #~LCDCF_ON
+ LDH (.LCDC),A ; Turn off screen
+ RET
+
+_remove_VBL::
+ PUSH BC
+ LDA HL,4(SP) ; Skip return address and registers
+ LD A,(HL+)
+ LD C,A
+ LD B,(HL)
+ CALL .remove_VBL
+ POP BC
+ RET
+
+_add_VBL::
+ PUSH BC
+ LDA HL, 4(SP) ; Skip return address and registers
+ LD A,(HL+)
+ LD C,A
+ LD B,(HL)
+ CALL .add_VBL
+ POP BC
+ RET
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/duck/global.s b/gbdk/gbdk-lib/libc/targets/sm83/duck/global.s
new file mode 100644
index 00000000..70771412
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/duck/global.s
@@ -0,0 +1,533 @@
+ .NEAR_CALLS = 1 ; <near_calls> - tag so that sed can change this
+
+ _VRAM = 0x8000 ; $8000->$9FFF
+ _VRAM8000 = 0x8000
+ _VRAM8800 = 0x8800
+ _VRAM9000 = 0x9000
+ _SCRN0 = 0x9800 ; $9800->$9BFF
+ _SCRN1 = 0x9C00 ; $9C00->$9FFF
+ _SRAM = 0xA000 ; $A000->$BFFF
+ _RAM = 0xC000 ; $C000->$CFFF / $C000->$DFFF
+ _RAMBANK = 0xD000 ; $D000->$DFFF
+ _OAMRAM = 0xFE00 ; $FE00->$FE9F
+ _IO = 0xFF00 ; $FF00->$FF7F,$FFFF
+ _AUD3WAVERAM = 0xFF30 ; $FF30->$FF3F
+ _HRAM = 0xFF80 ; $FF80->$FFFE
+
+ ;; MBC Equates
+
+ .MBC1_ROM_PAGE = 0x2000 ; Address to write to for MBC1 switching
+ .MBC_ROM_PAGE = 0x0001 ; Default platform MBC rom switching address
+
+ rRAMG = 0x0000 ; $0000->$1fff
+ rROMB0 = 0x0001 ; $2000->$2fff
+ rROMB1 = 0x3000 ; $3000->$3fff - If more than 256 ROM banks are present.
+ rRAMB = 0x4000 ; $4000->$5fff - Bit 3 enables rumble (if present)
+
+ ;; Keypad
+ .START = 0x80
+ .SELECT = 0x40
+ .B = 0x20
+ .A = 0x10
+ .DOWN = 0x08
+ .UP = 0x04
+ .LEFT = 0x02
+ .RIGHT = 0x01
+
+ .P14 = 0x10
+ .P15 = 0x20
+
+ ;; Screen dimensions
+ .MAXCURSPOSX = 0x13 ; In tiles
+ .MAXCURSPOSY = 0x11
+
+ .SCREENWIDTH = 0xA0
+ .SCREENHEIGHT = 0x90
+ .MINWNDPOSX = 0x07
+ .MINWNDPOSY = 0x00
+ .MAXWNDPOSX = 0xA6
+ .MAXWNDPOSY = 0x8F
+
+ ;; Hardware registers
+
+ .P1 = 0x00 ; Joystick: 1.1.P15.P14.P13.P12.P11.P10
+ rP1 = 0xFF00
+
+ P1F_5 = 0b00100000 ; P15 out port, set to 0 to get buttons
+ P1F_4 = 0b00010000 ; P14 out port, set to 0 to get dpad
+ P1F_3 = 0b00001000 ; P13 in port
+ P1F_2 = 0b00000100 ; P12 in port
+ P1F_1 = 0b00000010 ; P11 in port
+ P1F_0 = 0b00000001 ; P10 in port
+
+ P1F_GET_DPAD = 0b00100000
+ P1F_GET_BTN = 0b00010000
+ P1F_GET_NONE = 0b00110000
+
+ .SB = 0x01 ; Serial IO data buffer
+ rSB = 0xFF01
+
+ .SC = 0x02 ; Serial IO control register
+ rSC = 0xFF02
+
+ .DIV = 0x04 ; Divider register
+ rDIV = 0xFF04
+
+ .TIMA = 0x05 ; Timer counter
+ rTIMA = 0xFF05
+
+ .TMA = 0x06 ; Timer modulo
+ rTMA = 0xFF06
+
+ .TAC = 0x07 ; Timer control
+ rTAC = 0xFF07
+
+ TACF_START = 0b00000100
+ TACF_STOP = 0b00000000
+ TACF_4KHZ = 0b00000000
+ TACF_16KHZ = 0b00000011
+ TACF_65KHZ = 0b00000010
+ TACF_262KHZ = 0b00000001
+
+ .IF = 0x0F ; Interrupt flags: 0.0.0.JST.SIO.TIM.LCD.VBL
+ rIF = 0xFF0F
+
+ .NR10 = 0x20 ; Sound register
+ rNR10 = 0xFF20
+ rAUD1SWEEP = 0xFF20
+
+ AUD1SWEEP_UP = 0b00000000
+ AUD1SWEEP_DOWN = 0b00001000
+
+ .NR11 = 0x22 ; Sound register
+ rNR11 = 0xFF22
+ rAUD1LEN = 0xFF22
+
+ .NR12 = 0x21 ; Sound register
+ rNR12 = 0xFF21
+ rAUD1ENV = 0xFF21
+
+ .NR13 = 0x23 ; Sound register
+ rNR13 = 0xFF23
+ rAUD1LOW = 0xFF23
+
+ .NR14 = 0x24 ; Sound register
+ rNR14 = 0xFF24
+ rAUD1HIGH = 0xFF24
+
+ .NR21 = 0x25 ; Sound register
+ rNR21 = 0xFF25
+ rAUD2LEN = 0xFF25
+
+ .NR22 = 0x27 ; Sound register
+ rNR22 = 0xFF27
+ rAUD2ENV = 0xFF27
+
+ .NR23 = 0x28 ; Sound register
+ rNR23 = 0xFF28
+ rAUD2LOW = 0xFF28
+
+ .NR24 = 0x29 ; Sound register
+ rNR24 = 0xFF29
+ rAUD2HIGH = 0xFF29
+
+ .NR30 = 0x2A ; Sound register
+ rNR30 = 0xFF2A
+ rAUD3ENA = 0xFF2A
+
+ .NR31 = 0x2B ; Sound register
+ rNR31 = 0xFF2B
+ rAUD3LEN = 0xFF2B
+
+ .NR32 = 0x2C ; Sound register
+ rNR32 = 0xFF2C
+ rAUD3LEVEL = 0xFF2C
+
+ .NR33 = 0x2E ; Sound register
+ rNR33 = 0xFF2E
+ rAUD3LOW = 0xFF2E
+
+ .NR34 = 0x2D ; Sound register
+ rNR34 = 0xFF2D
+ rAUD3HIGH = 0xFF2D
+
+ .NR41 = 0x40 ; Sound register
+ rNR41 = 0xFF40
+ rAUD4LEN = 0xFF40
+
+ .NR42 = 0x42 ; Sound register
+ rNR42 = 0xFF42
+ rAUD4ENV = 0xFF42
+
+ .NR43 = 0x41 ; Sound register
+ rNR43 = 0xFF41
+ rAUD4POLY = 0xFF41
+
+ .NR44 = 0x43 ; Sound register
+ rNR44 = 0xFF43
+ rAUD4GO = 0xFF43
+
+ .NR50 = 0x44 ; Sound register
+ rNR50 = 0xFF44
+ rAUDVOL = 0xFF44
+
+ AUDVOL_VIN_LEFT = 0b10000000 ; SO2
+ AUDVOL_VIN_RIGHT = 0b00001000 ; SO1
+
+ .NR51 = 0x46 ; Sound register
+ rNR51 = 0xFF46
+ rAUDTERM = 0xFF46
+
+ AUDTERM_4_LEFT = 0b10000000
+ AUDTERM_3_LEFT = 0b01000000
+ AUDTERM_2_LEFT = 0b00100000
+ AUDTERM_1_LEFT = 0b00010000
+ AUDTERM_4_RIGHT = 0b00001000
+ AUDTERM_3_RIGHT = 0b00000100
+ AUDTERM_2_RIGHT = 0b00000010
+ AUDTERM_1_RIGHT = 0b00000001
+
+ .NR52 = 0x45 ; Sound register
+ rNR52 = 0xFF45
+ rAUDENA = 0xFF45
+
+ AUDENA_ON = 0b10000000
+ AUDENA_OFF = 0b00000000 ; sets all audio regs to 0!
+
+ .LCDC = 0x10 ; LCD control
+ rLCDC = 0xFF10
+
+ LCDCF_OFF = 0b00000000 ; LCD Control Operation
+ LCDCF_ON = 0b10000000 ; LCD Control Operation
+ LCDCF_WIN9800 = 0b00000000 ; Window Tile Map Display Select
+ LCDCF_WIN9C00 = 0b00001000 ; Window Tile Map Display Select
+ LCDCF_WINOFF = 0b00000000 ; Window Display
+ LCDCF_WINON = 0b00100000 ; Window Display
+ LCDCF_BG8800 = 0b00000000 ; BG & Window Tile Data Select
+ LCDCF_BG8000 = 0b00010000 ; BG & Window Tile Data Select
+ LCDCF_BG9800 = 0b00000000 ; BG Tile Map Display Select
+ LCDCF_BG9C00 = 0b00000100 ; BG Tile Map Display Select
+ LCDCF_OBJ8 = 0b00000000 ; OBJ Construction
+ LCDCF_OBJ16 = 0b00000010 ; OBJ Construction
+ LCDCF_OBJOFF = 0b00000000 ; OBJ Display
+ LCDCF_OBJON = 0b00000001 ; OBJ Display
+ LCDCF_BGOFF = 0b00000000 ; BG Display
+ LCDCF_BGON = 0b01000000 ; BG Display
+ LCDCF_B_ON = 7
+ LCDCF_B_WIN9C00 = 3
+ LCDCF_B_WINON = 5
+ LCDCF_B_BG8000 = 4
+ LCDCF_B_BG9C00 = 2
+ LCDCF_B_OBJ16 = 1
+ LCDCF_B_OBJON = 0
+ LCDCF_B_BGON = 6
+
+ .STAT = 0x11 ; LCD status
+ rSTAT = 0xFF11
+
+ STATF_LYC = 0b01000000 ; LYC=LY Coincidence (Selectable)
+ STATF_MODE10 = 0b00100000 ; Mode 10
+ STATF_MODE01 = 0b00010000 ; Mode 01 (V-Blank)
+ STATF_MODE00 = 0b00001000 ; Mode 00 (H-Blank)
+ STATF_LYCF = 0b00000100 ; Coincidence Flag
+ STATF_HBL = 0b00000000 ; H-Blank
+ STATF_VBL = 0b00000001 ; V-Blank
+ STATF_OAM = 0b00000010 ; OAM-RAM is used by system
+ STATF_LCD = 0b00000011 ; Both OAM and VRAM used by system
+ STATF_BUSY = 0b00000010 ; When set, VRAM access is unsafe
+ STATF_B_LYC = 6
+ STATF_B_MODE10 = 5
+ STATF_B_MODE01 = 4
+ STATF_B_MODE00 = 3
+ STATF_B_LYCF = 2
+ STATF_B_VBL = 0
+ STATF_B_OAM = 1
+ STATF_B_BUSY = 1
+
+ .SCY = 0x12 ; Scroll Y
+ rSCY = 0xFF12
+
+ .SCX = 0x13 ; Scroll X
+ rSCX = 0xFF13
+
+ .LY = 0x18 ; LCDC Y-coordinate
+ rLY = 0xFF18
+
+ .LYC = 0x19 ; LY compare
+ rLYC = 0xFF19
+
+ .DMA = 0x1A ; DMA transfer
+ rDMA = 0xFF1A
+
+ .BGP = 0x1B ; BG palette data
+ rBGP = 0xFF1B
+
+ .OBP0 = 0x14 ; OBJ palette 0 data
+ rOBP0 = 0xFF14
+
+ .OBP1 = 0x15 ; OBJ palette 1 data
+ rOBP1 = 0xFF15
+
+ .WY = 0x16 ; Window Y coordinate
+ rWY = 0xFF16
+
+ .WX = 0x17 ; Window X coordinate
+ rWX = 0xFF17
+
+ .KEY1 = 0x4D ; CPU speed
+ rKEY1 = 0xFF4D
+ rSPD = 0xFF4D
+
+ KEY1F_DBLSPEED = 0b10000000 ; 0=Normal Speed, 1=Double Speed (R)
+ KEY1F_PREPARE = 0b00000001 ; 0=No, 1=Prepare (R/W)
+
+ .VBK = 0x4F ; VRAM bank
+ rVBK = 0xFF4F
+
+ .HDMA1 = 0x51 ; DMA control 1
+ rHDMA1 = 0xFF51
+
+ .HDMA2 = 0x52 ; DMA control 2
+ rHDMA2 = 0xFF52
+
+ .HDMA3 = 0x53 ; DMA control 3
+ rHDMA3 = 0xFF53
+
+ .HDMA4 = 0x54 ; DMA control 4
+ rHDMA4 = 0xFF54
+
+ .HDMA5 = 0x55 ; DMA control 5
+ rHDMA5 = 0xFF55
+
+ HDMA5F_MODE_GP = 0b00000000 ; General Purpose DMA (W)
+ HDMA5F_MODE_HBL = 0b10000000 ; HBlank DMA (W)
+
+ HDMA5F_BUSY = 0b10000000 ; 0=Busy (DMA still in progress), 1=Transfer complete (R)
+
+ .RP = 0x56 ; IR port
+ rRP = 0xFF56
+
+ RPF_ENREAD = 0b11000000
+ RPF_DATAIN = 0b00000010 ; 0=Receiving IR Signal, 1=Normal
+ RPF_WRITE_HI = 0b00000001
+ RPF_WRITE_LO = 0b00000000
+
+ .BCPS = 0x68 ; BG color palette specification
+ rBCPS = 0xFF68
+
+ BCPSF_AUTOINC = 0b10000000 ; Auto Increment (0=Disabled, 1=Increment after Writing)
+
+ .BCPD = 0x69 ; BG color palette data
+ rBCPD = 0xFF69
+
+ .OCPS = 0x6A ; OBJ color palette specification
+ rOCPS = 0xFF6A
+
+ OCPSF_AUTOINC = 0b10000000 ; Auto Increment (0=Disabled, 1=Increment after Writing)
+
+ .OCPD = 0x6B ; OBJ color palette data
+ rOCPD = 0xFF6B
+
+ .SVBK = 0x70 ; WRAM bank
+ rSVBK = 0xFF70
+ rSMBK = 0xFF70
+
+ rPCM12 = 0xFF76
+
+ rPCM34 = 0xFF77
+
+ .IE = 0xFF ; Interrupt enable
+ rIE = 0xFFFF
+
+ .VBL_IFLAG = 0x01
+ .LCD_IFLAG = 0x02
+ .TIM_IFLAG = 0x04
+ .SIO_IFLAG = 0x08
+ .JOY_IFLAG = 0x10
+
+ IEF_HILO = 0b00010000 ; Transition from High to Low of Pin number P10-P13
+ IEF_SERIAL = 0b00001000 ; Serial I/O transfer end
+ IEF_TIMER = 0b00000100 ; Timer Overflow
+ IEF_STAT = 0b00000010 ; STAT
+ IEF_VBLANK = 0b00000001 ; V-Blank
+
+ ;; Flags common to multiple sound channels
+
+ AUDLEN_DUTY_12_5 = 0b00000000 ; 12.5%
+ AUDLEN_DUTY_25 = 0b01000000 ; 25%
+ AUDLEN_DUTY_50 = 0b10000000 ; 50%
+ AUDLEN_DUTY_75 = 0b11000000 ; 75%
+
+ AUDENV_UP = 0b00001000
+ AUDENV_DOWN = 0b00000000
+
+ AUDHIGH_RESTART = 0b10000000
+ AUDHIGH_LENGTH_ON = 0b01000000
+ AUDHIGH_LENGTH_OFF = 0b00000000
+
+ ;; OAM related constants
+
+ OAM_COUNT = 40 ; number of OAM entries in OAM RAM
+
+ OAMF_PRI = 0b10000000 ; Priority
+ OAMF_YFLIP = 0b01000000 ; Y flip
+ OAMF_XFLIP = 0b00100000 ; X flip
+ OAMF_PAL0 = 0b00000000 ; Palette number; 0,1 (DMG)
+ OAMF_PAL1 = 0b00010000 ; Palette number; 0,1 (DMG)
+ OAMF_BANK0 = 0b00000000 ; Bank number; 0,1 (GBC)
+ OAMF_BANK1 = 0b00001000 ; Bank number; 0,1 (GBC)
+
+ OAMF_PALMASK = 0b00000111 ; Palette (GBC)
+
+ OAMB_PRI = 7 ; Priority
+ OAMB_YFLIP = 6 ; Y flip
+ OAMB_XFLIP = 5 ; X flip
+ OAMB_PAL1 = 4 ; Palette number; 0,1 (DMG)
+ OAMB_BANK1 = 3 ; Bank number; 0,1 (GBC)
+
+ ;; SGB packets
+ .PAL_01 = 0x00
+ .PAL_23 = 0x01
+ .PAL_03 = 0x02
+ .PAL_12 = 0x03
+ .ATTR_BLK = 0x04
+ .ATTR_LIN = 0x05
+ .ATTR_DIV = 0x06
+ .ATTR_CHR = 0x07
+ .SOUND = 0x08
+ .SOU_TRN = 0x09
+ .PAL_SET = 0x0A
+ .PAL_TRN = 0x0B
+ .ATRC_EN = 0x0C
+ .TEST_EN = 0x0D
+ .ICON_EN = 0x0E
+ .DATA_SND = 0x0F
+ .DATA_TRN = 0x10
+ .MLT_REQ = 0x11
+ .JUMP = 0x12
+ .CHR_TRN = 0x13
+ .PCT_TRN = 0x14
+ .ATTR_TRN = 0x15
+ .ATTR_SET = 0x16
+ .MASK_EN = 0x17
+ .OBJ_TRN = 0x18
+
+ ;; CPU detection
+ .DMG_TYPE = 0x01 ; Original GB or Super GB
+ .MGB_TYPE = 0xFF ; Pocket GB or Super GB 2
+ .CGB_TYPE = 0x11 ; Color GB
+
+ ;; GBDK library screen modes
+
+ .G_MODE = 0x01 ; Graphic mode
+ .T_MODE = 0x02 ; Text mode (bit 2)
+ .T_MODE_OUT = 0x02 ; Text mode output only
+ .T_MODE_INOUT = 0x03 ; Text mode with input
+ .M_NO_SCROLL = 0x04 ; Disables scrolling of the screen in text mode
+ .M_NO_INTERP = 0x08 ; Disables special character interpretation
+
+ ;; Status codes for IO
+ .IO_IDLE = 0x00
+ .IO_SENDING = 0x01
+ .IO_RECEIVING = 0x02
+ .IO_ERROR = 0x04
+
+ ;; Type of IO data
+ .DT_IDLE = 0x66
+ .DT_RECEIVING = 0x55
+
+ ;; Table of routines for modes
+ .MODE_TABLE = 0x01E0
+
+ ;; C related
+ ;; Overheap of a banked call. Used for parameters
+ ;; = ret + real ret + bank
+
+ .if .NEAR_CALLS
+ .BANKOV = 2
+
+ .else
+ .BANKOV = 6
+
+ .endif
+
+ .globl __current_bank
+ .globl __shadow_OAM_base
+
+ ;; Global variables
+ .globl .mode
+
+ .globl __cpu
+ .globl __is_GBA
+
+ ;; Global routines
+; .globl .set_mode ;; don't link mode.o by default
+
+ .globl .reset
+
+ .globl .display_off
+
+ .globl .wait_vbl_done
+
+ ;; Interrupt routines
+ .globl .add_VBL
+; .globl .add_LCD ;; don't link LCD.o by default
+; .globl .add_TIM ;; don't link TIM.o by default
+; .globl .add_SIO ;; don't link serial.o by default
+; .globl .add_JOY ;; don't link JOY.o by default
+
+ ;; Symbols defined at link time
+ .globl .STACK
+ .globl _shadow_OAM
+ .globl .refresh_OAM
+
+ ;; Main user routine
+ .globl _main
+
+ ;; Macro definitions
+
+.macro WAIT_STAT ?lbl
+lbl: LDH A, (.STAT)
+ AND #STATF_BUSY ; Check if in LCD modes 0 or 1
+ JR NZ, lbl
+.endm
+
+.macro ADD_A_REG16 regH regL
+ ADD regL
+ LD regL, A
+ ADC regH
+ SUB regL
+ LD regH, A
+.endm
+
+.macro SIGNED_ADD_A_REG16 regH regL ?lbl
+ ; If A is negative, we need to subtract 1 from upper byte of 16-bit value
+ BIT 7, A ; set z if a signed bit is 0
+ JR Z, lbl ; if z is set jump to positive
+ dec regH ; if negative decrement upper byte
+lbl:
+ ADD_A_REG16 regH, regL
+.endm
+
+.macro SIGNED_SUB_A_REG16 regH regL ?lbl
+ ; negate A then add to 16-bit value
+ CPL
+ INC A
+ SIGNED_ADD_A_REG16 regH, regL
+.endm
+
+.macro MUL_DE_BY_A_RET_HL ?lbl1 ?lbl2 ?lbl3
+ ; Multiply DE by A, return result in HL; preserves: BC
+ LD HL, #0
+lbl1:
+ SRL A
+ JR NC, lbl2
+ ADD HL, DE
+lbl2:
+ JR Z, lbl3
+ SLA E
+ RL D
+ JR lbl1
+lbl3:
+.endm
+
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/duck/sfr.s b/gbdk/gbdk-lib/libc/targets/sm83/duck/sfr.s
new file mode 100644
index 00000000..e91040c7
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/duck/sfr.s
@@ -0,0 +1,111 @@
+__VRAM = 0x8000
+__VRAM8000 = 0x8000
+__VRAM8800 = 0x8800
+__VRAM9000 = 0x9000
+__SCRN0 = 0x9800
+__SCRN1 = 0x9C00
+__SRAM = 0xA000
+__RAM = 0xC000
+__RAMBANK = 0xD000
+__OAMRAM = 0xFE00
+__IO = 0xFF00
+__AUD3WAVERAM = 0xFF30
+__HRAM = 0xFF80
+
+.globl __VRAM, __VRAM8000, __VRAM8800, __VRAM9000, __SCRN0, __SCRN1, __SRAM, __RAM, __RAMBANK, __OAMRAM, __IO, __AUD3WAVERAM, __HRAM
+
+_rRAMG = 0x0000
+_rROMB0 = 0x0001
+_rROMB1 = 0x3000
+_rRAMB = 0x4000
+
+.globl _rRAMG, _rROMB0, _rROMB1, _rRAMB
+
+_P1_REG = 0xFF00 ; Joystick: 1.1.P15.P14.P13.P12.P11.P10
+_SB_REG = 0xFF01 ; Serial IO data buffer
+_SC_REG = 0xFF02 ; Serial IO control register
+_DIV_REG = 0xFF04 ; Divider register
+_TIMA_REG = 0xFF05 ; Timer counter
+_TMA_REG = 0xFF06 ; Timer modulo
+_TAC_REG = 0xFF07 ; Timer control
+_IF_REG = 0xFF0F ; Interrupt flags: 0.0.0.JOY.SIO.TIM.LCD.VBL
+_LCDC_REG = 0xFF10 ; LCD control
+_STAT_REG = 0xFF11 ; LCD status
+_SCY_REG = 0xFF12 ; Scroll Y
+_SCX_REG = 0xFF13 ; Scroll X
+_OBP0_REG = 0xFF14 ; OBJ palette 0 data
+_OBP1_REG = 0xFF15 ; OBJ palette 1 data
+_WY_REG = 0xFF16 ; Window Y coordinate
+_WX_REG = 0xFF17 ; Window X coordinate
+_LY_REG = 0xFF18 ; LCDC Y-coordinate
+_LYC_REG = 0xFF19 ; LY compare
+_DMA_REG = 0xFF1A ; DMA transfer
+_BGP_REG = 0xFF1B ; BG palette data
+_NR10_REG = 0xFF20 ; Sound register
+_NR12_REG = 0xFF21 ; Sound register
+_NR11_REG = 0xFF22 ; Sound register
+_NR13_REG = 0xFF23 ; Sound register
+_NR14_REG = 0xFF24 ; Sound register
+_NR21_REG = 0xFF25 ; Sound register
+_NR22_REG = 0xFF27 ; Sound register
+_NR23_REG = 0xFF28 ; Sound register
+_NR24_REG = 0xFF29 ; Sound register
+_NR30_REG = 0xFF2A ; Sound register
+_NR31_REG = 0xFF2B ; Sound register
+_NR32_REG = 0xFF2C ; Sound register
+_NR34_REG = 0xFF2D ; Sound register
+_NR33_REG = 0xFF2E ; Sound register
+_NR41_REG = 0xFF40 ; Sound register
+_NR43_REG = 0xFF41 ; Sound register
+_NR42_REG = 0xFF42 ; Sound register
+_NR44_REG = 0xFF43 ; Sound register
+_NR50_REG = 0xFF44 ; Sound register
+_NR52_REG = 0xFF45 ; Sound register
+_NR51_REG = 0xFF46 ; Sound register
+_PCM_SAMPLE = 0xFF30 ; PCM wave pattern
+_AUD3WAVE = 0xFF30 ; PCM wave pattern
+_KEY1_REG = 0xFF4D ; CPU speed
+_VBK_REG = 0xFF4F ; VRAM bank
+_HDMA1_REG = 0xFF51 ; DMA control 1
+_HDMA2_REG = 0xFF52 ; DMA control 2
+_HDMA3_REG = 0xFF53 ; DMA control 3
+_HDMA4_REG = 0xFF54 ; DMA control 4
+_HDMA5_REG = 0xFF55 ; DMA control 5
+_RP_REG = 0xFF56 ; IR port
+_BCPS_REG = 0xFF68 ; BG color palette specification
+_BCPD_REG = 0xFF69 ; BG color palette data
+_OCPS_REG = 0xFF6A ; OBJ color palette specification
+_OCPD_REG = 0xFF6B ; OBJ color palette data
+_SVBK_REG = 0xFF70 ; WRAM bank
+_PCM12_REG = 0xFF76 ; Sound channel 1&2 PCM amplitude (R)
+_PCM34_REG = 0xFF77 ; Sound channel 3&4 PCM amplitude (R)
+_IE_REG = 0xFFFF ; Interrupt enable
+
+.globl _P1_REG
+.globl _SB_REG, _SC_REG
+.globl _DIV_REG
+.globl _TIMA_REG, _TMA_REG, _TAC_REG
+.globl _IF_REG
+.globl _NR10_REG, _NR11_REG, _NR12_REG, _NR13_REG, _NR14_REG
+.globl _NR21_REG, _NR22_REG, _NR23_REG, _NR24_REG
+.globl _NR30_REG, _NR31_REG, _NR32_REG, _NR33_REG, _NR34_REG
+.globl _NR41_REG, _NR42_REG, _NR43_REG, _NR44_REG
+.globl _NR50_REG, _NR51_REG, _NR52_REG
+.globl _PCM_SAMPLE, _AUD3WAVE
+.globl _LCDC_REG
+.globl _STAT_REG
+.globl _SCY_REG, _SCX_REG
+.globl _LY_REG, _LYC_REG
+.globl _DMA_REG
+.globl _BGP_REG
+.globl _OBP0_REG, _OBP1_REG
+.globl _WY_REG, _WX_REG
+.globl _KEY1_REG
+.globl _VBK_REG
+.globl _HDMA1_REG, _HDMA2_REG, _HDMA3_REG, _HDMA4_REG, _HDMA5_REG
+.globl _RP_REG
+.globl _BCPS_REG, _BCPD_REG
+.globl _OCPS_REG, _OCPD_REG
+.globl _SVBK_REG
+.globl _PCM12_REG, _PCM34_REG
+.globl _IE_REG \ No newline at end of file
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/emu_debug.s b/gbdk/gbdk-lib/libc/targets/sm83/emu_debug.s
new file mode 100644
index 00000000..46fe66c2
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/emu_debug.s
@@ -0,0 +1,20 @@
+ .include "global.s"
+
+ .title "EMU_debug"
+ .module EMU_debug
+
+ .area _EMU_HEADER (ABS)
+
+ .org 0x08
+ JP _EMU_profiler_message
+
+ .area _HOME
+
+ ;; EMU profiler message
+_EMU_profiler_message::
+ LD D, D
+ JR 1$
+ .dw 0x6464
+ .dw 0
+ .ascii "PROFILE,%(SP+$0)%,%(SP+$1)%,%A%,%TOTALCLKS%,%ROMBANK%,%WRAMBANK%"
+1$: RET
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/emu_debug_printf.s b/gbdk/gbdk-lib/libc/targets/sm83/emu_debug_printf.s
new file mode 100644
index 00000000..1fd5cbbe
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/emu_debug_printf.s
@@ -0,0 +1,43 @@
+ .include "global.s"
+
+ .title "EMU_debug"
+ .module EMU_debug
+
+ .globl _sprintf
+
+ .area _DATA
+
+ret_save:
+ .ds 0x02
+printf_buffer:
+ .ds 0x80
+
+ .area _HOME
+
+ ;; EMU_printf(fmt, ...)
+_EMU_printf::
+ di
+ pop de
+ ld hl, #ret_save
+ ld (hl), e
+ inc hl
+ ld (hl), d
+
+ ld de, #printf_buffer
+ push de
+ call _sprintf
+ pop hl
+
+ ld d,d
+ jr 1$
+ .dw 0x6464
+ .dw 0x0001
+ .dw #printf_buffer
+ .dw 0
+1$:
+ ld hl, #ret_save
+ ld a, (hl+)
+ ld h, (hl)
+ ld l, a
+ ei
+ jp (hl)
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/f_ibm_full.s b/gbdk/gbdk-lib/libc/targets/sm83/f_ibm_full.s
new file mode 100644
index 00000000..d7f09b18
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/f_ibm_full.s
@@ -0,0 +1,2616 @@
+; font: font
+
+ .area _HOME
+
+ .globl font_load
+ ;; Perform tricks with banking to shift this font out of
+ ;; bank 0. Doesnt currently work as the encoding table
+ ;; must always be visible.
+_font_load_ibm_fixed:: ; Banked
+ ld hl,#_font_ibm_fixed
+ call font_load
+ ret
+
+_font_ibm_fixed::
+ .db 0+4 ; 256 char encoding, compressed
+ .db 255 ; Number of tiles
+
+; Encoding table
+
+ ; Hack
+ .db 0x00
+ .db 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08
+ .db 0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,0x10
+ .db 0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18
+ .db 0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,0x20
+ .db 0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28
+ .db 0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,0x30
+ .db 0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38
+ .db 0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F,0x40
+ .db 0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48
+ .db 0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F,0x50
+ .db 0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58
+ .db 0x59,0x5A,0x5B,0x5C,0x5D,0x5E,0x5F,0x60
+ .db 0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68
+ .db 0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F,0x70
+ .db 0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78
+ .db 0x79,0x7A,0x7B,0x7C,0x7D,0x7E,0x7F,0x80
+ .db 0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88
+ .db 0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90
+ .db 0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98
+ .db 0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,0xA0
+ .db 0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8
+ .db 0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0
+ .db 0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8
+ .db 0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF,0xC0
+ .db 0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8
+ .db 0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0
+ .db 0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8
+ .db 0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF,0xE0
+ .db 0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8
+ .db 0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0
+ .db 0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8
+ .db 0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF
+ ; Tile data
+ ;; Hook for the graphics routines
+_font_ibm_fixed_tiles::
+; Default character (space)
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+
+; Character: ? (01)
+ .db 0b00011000 ; oo
+ .db 0b00100100 ; o o
+ .db 0b01000010 ; o o
+ .db 0b10000001 ; o o
+ .db 0b11100111 ; ooo ooo
+ .db 0b00100100 ; o o
+ .db 0b00100100 ; o o
+ .db 0b00111100 ; oooo
+
+; Character: ? (02)
+ .db 0b00111100 ; oooo
+ .db 0b00100100 ; o o
+ .db 0b00100100 ; o o
+ .db 0b11100111 ; ooo ooo
+ .db 0b10000001 ; o o
+ .db 0b01000010 ; o o
+ .db 0b00100100 ; o o
+ .db 0b00011000 ; oo
+
+; Character: ? (03)
+ .db 0b00011000 ; oo
+ .db 0b00010100 ; o o
+ .db 0b11110010 ; oooo o
+ .db 0b10000001 ; o o
+ .db 0b10000001 ; o o
+ .db 0b11110010 ; oooo o
+ .db 0b00010100 ; o o
+ .db 0b00011000 ; oo
+
+; Character: ? (04)
+ .db 0b00011000 ; oo
+ .db 0b00101000 ; o o
+ .db 0b01001111 ; o oooo
+ .db 0b10000001 ; o o
+ .db 0b10000001 ; o o
+ .db 0b01001111 ; o oooo
+ .db 0b00101000 ; o o
+ .db 0b00011000 ; oo
+
+; Character: ? (05)
+ .db 0b11111111 ; oooooooo
+ .db 0b10000001 ; o o
+ .db 0b10000001 ; o o
+ .db 0b10000001 ; o o
+ .db 0b10000001 ; o o
+ .db 0b10000001 ; o o
+ .db 0b10000001 ; o o
+ .db 0b11111111 ; oooooooo
+
+; Character: ? (06)
+ .db 0b11111000 ; ooooo
+ .db 0b10001000 ; o o
+ .db 0b10001111 ; o oooo
+ .db 0b10001001 ; o o o
+ .db 0b11111001 ; ooooo o
+ .db 0b01000001 ; o o
+ .db 0b01000001 ; o o
+ .db 0b01111111 ; ooooooo
+
+; Character: ? (07)
+ .db 0b11111111 ; oooooooo
+ .db 0b10001001 ; o o o
+ .db 0b10001001 ; o o o
+ .db 0b10001001 ; o o o
+ .db 0b11111001 ; ooooo o
+ .db 0b10000001 ; o o
+ .db 0b10000001 ; o o
+ .db 0b11111111 ; oooooooo
+
+; Character: ? (08)
+ .db 0b00000001 ; o
+ .db 0b00000011 ; oo
+ .db 0b00000110 ; oo
+ .db 0b10001100 ; o oo
+ .db 0b11011000 ; oo oo
+ .db 0b01110000 ; ooo
+ .db 0b00100000 ; o
+ .db 0b00000000 ;
+
+; Character: ? (09)
+ .db 0b01111110 ; oooooo
+ .db 0b11000011 ; oo oo
+ .db 0b11010011 ; oo o oo
+ .db 0b11010011 ; oo o oo
+ .db 0b11011011 ; oo oo oo
+ .db 0b11000011 ; oo oo
+ .db 0b11000011 ; oo oo
+ .db 0b01111110 ; oooooo
+
+; Character: ? (0A)
+ .db 0b00011000 ; oo
+ .db 0b00111100 ; oooo
+ .db 0b00101100 ; o oo
+ .db 0b00101100 ; o oo
+ .db 0b01111110 ; oooooo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+
+; Character: ? (0B)
+ .db 0b00010000 ; o
+ .db 0b00011100 ; ooo
+ .db 0b00010010 ; o o
+ .db 0b00010000 ; o
+ .db 0b00010000 ; o
+ .db 0b01110000 ; ooo
+ .db 0b11110000 ; oooo
+ .db 0b01100000 ; oo
+
+; Character: ? (0C)
+ .db 0b11110000 ; oooo
+ .db 0b11000000 ; oo
+ .db 0b11111110 ; ooooooo
+ .db 0b11011000 ; oo oo
+ .db 0b11011110 ; oo oooo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+
+; Character: ? (0D)
+ .db 0b01110000 ; ooo
+ .db 0b11001000 ; oo o
+ .db 0b11011110 ; oo oooo
+ .db 0b11011011 ; oo oo oo
+ .db 0b11011011 ; oo oo oo
+ .db 0b01111110 ; oooooo
+ .db 0b00011011 ; oo oo
+ .db 0b00011011 ; oo oo
+
+; Character: ? (0E)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b11111111 ; oooooooo
+ .db 0b11111111 ; oooooooo
+ .db 0b11111111 ; oooooooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (0F)
+ .db 0b00011100 ; ooo
+ .db 0b00011100 ; ooo
+ .db 0b00011100 ; ooo
+ .db 0b00011100 ; ooo
+ .db 0b00011100 ; ooo
+ .db 0b00011100 ; ooo
+ .db 0b00011100 ; ooo
+ .db 0b00011100 ; ooo
+
+; Character: ? (10)
+ .db 0b01111100 ; ooooo
+ .db 0b11000110 ; oo oo
+ .db 0b11000110 ; oo oo
+ .db 0b00000000 ;
+ .db 0b11000110 ; oo oo
+ .db 0b11000110 ; oo oo
+ .db 0b01111100 ; ooooo
+ .db 0b00000000 ;
+
+; Character: ? (11)
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00000000 ;
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00000000 ;
+
+; Character: ? (12)
+ .db 0b01111100 ; ooooo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b01111100 ; ooooo
+ .db 0b11000000 ; oo
+ .db 0b11000000 ; oo
+ .db 0b01111100 ; ooooo
+ .db 0b00000000 ;
+
+; Character: ? (13)
+ .db 0b01111100 ; ooooo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b01111100 ; ooooo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b01111100 ; ooooo
+ .db 0b00000000 ;
+
+; Character: ? (14)
+ .db 0b11000110 ; oo oo
+ .db 0b11000110 ; oo oo
+ .db 0b11000110 ; oo oo
+ .db 0b01111100 ; ooooo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00000000 ;
+
+; Character: ? (15)
+ .db 0b01111100 ; ooooo
+ .db 0b11000000 ; oo
+ .db 0b11000000 ; oo
+ .db 0b01111100 ; ooooo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b01111100 ; ooooo
+ .db 0b00000000 ;
+
+; Character: ? (16)
+ .db 0b01111100 ; ooooo
+ .db 0b11000000 ; oo
+ .db 0b11000000 ; oo
+ .db 0b01111100 ; ooooo
+ .db 0b11000110 ; oo oo
+ .db 0b11000110 ; oo oo
+ .db 0b01111100 ; ooooo
+ .db 0b00000000 ;
+
+; Character: ? (17)
+ .db 0b01111100 ; ooooo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00000000 ;
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00000000 ;
+
+; Character: ? (18)
+ .db 0b01111100 ; ooooo
+ .db 0b11000110 ; oo oo
+ .db 0b11000110 ; oo oo
+ .db 0b01111100 ; ooooo
+ .db 0b11000110 ; oo oo
+ .db 0b11000110 ; oo oo
+ .db 0b01111100 ; ooooo
+ .db 0b00000000 ;
+
+; Character: ? (19)
+ .db 0b01111100 ; ooooo
+ .db 0b11000110 ; oo oo
+ .db 0b11000110 ; oo oo
+ .db 0b01111100 ; ooooo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b01111100 ; ooooo
+ .db 0b00000000 ;
+
+; Character: ? (1A)
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01000110 ; o oo
+ .db 0b00000110 ; oo
+ .db 0b01111110 ; oooooo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: ? (1B)
+ .db 0b01111000 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01111101 ; ooooo o
+ .db 0b01100100 ; oo o
+ .db 0b01111110 ; oooooo
+ .db 0b00000011 ; oo
+ .db 0b00001011 ; o oo
+ .db 0b00000110 ; oo
+
+; Character: ? (1C)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00011111 ; ooooo
+ .db 0b00011111 ; ooooo
+ .db 0b00011111 ; ooooo
+ .db 0b00011100 ; ooo
+ .db 0b00011100 ; ooo
+
+; Character: ? (1D)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b11111100 ; oooooo
+ .db 0b11111100 ; oooooo
+ .db 0b11111100 ; oooooo
+ .db 0b00011100 ; ooo
+ .db 0b00011100 ; ooo
+
+; Character: ? (1E)
+ .db 0b00011100 ; ooo
+ .db 0b00011100 ; ooo
+ .db 0b00011100 ; ooo
+ .db 0b00011111 ; ooooo
+ .db 0b00011111 ; ooooo
+ .db 0b00011111 ; ooooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (1F)
+ .db 0b00011100 ; ooo
+ .db 0b00011100 ; ooo
+ .db 0b00011100 ; ooo
+ .db 0b11111100 ; oooooo
+ .db 0b11111100 ; oooooo
+ .db 0b11111100 ; oooooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: (20)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ! (21)
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+
+; Character: " (22)
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01000100 ; o o
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: # (23)
+ .db 0b00000000 ;
+ .db 0b00100100 ; o o
+ .db 0b01111110 ; oooooo
+ .db 0b00100100 ; o o
+ .db 0b00100100 ; o o
+ .db 0b01111110 ; oooooo
+ .db 0b00100100 ; o o
+ .db 0b00000000 ;
+
+; Character: $ (24)
+ .db 0b00010100 ; o o
+ .db 0b00111110 ; ooooo
+ .db 0b01010101 ; o o o o
+ .db 0b00111100 ; oooo
+ .db 0b00011110 ; oooo
+ .db 0b01010101 ; o o o o
+ .db 0b00111110 ; ooooo
+ .db 0b00010100 ; o o
+
+; Character: % (25)
+ .db 0b01100010 ; oo o
+ .db 0b01100110 ; oo oo
+ .db 0b00001100 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00110000 ; oo
+ .db 0b01100110 ; oo oo
+ .db 0b01000110 ; o oo
+ .db 0b00000000 ;
+
+; Character: & (26)
+ .db 0b01111000 ; oooo
+ .db 0b11001100 ; oo oo
+ .db 0b01100001 ; oo o
+ .db 0b11001110 ; oo ooo
+ .db 0b11001100 ; oo oo
+ .db 0b11001100 ; oo oo
+ .db 0b01111000 ; oooo
+ .db 0b00000000 ;
+
+; Character: ' (27)
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00010000 ; o
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ( (28)
+ .db 0b00000100 ; o
+ .db 0b00001000 ; o
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00001000 ; o
+ .db 0b00000100 ; o
+
+; Character: ) (29)
+ .db 0b00100000 ; o
+ .db 0b00010000 ; o
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00010000 ; o
+ .db 0b00100000 ; o
+
+; Character: * (2A)
+ .db 0b00000000 ;
+ .db 0b01010100 ; o o o
+ .db 0b00111000 ; ooo
+ .db 0b11111110 ; ooooooo
+ .db 0b00111000 ; ooo
+ .db 0b01010100 ; o o o
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: + (2B)
+ .db 0b00000000 ;
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b01111110 ; oooooo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: , (2C)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00110000 ; oo
+ .db 0b00110000 ; oo
+ .db 0b00100000 ; o
+
+; Character: - (2D)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: . (2E)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+
+; Character: / (2F)
+ .db 0b00000011 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00110000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b11000000 ; oo
+ .db 0b00000000 ;
+
+; Character: 0 (30)
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01101110 ; oo ooo
+ .db 0b01110110 ; ooo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: 1 (31)
+ .db 0b00011000 ; oo
+ .db 0b00111000 ; ooo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+
+; Character: 2 (32)
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b00001110 ; ooo
+ .db 0b00011100 ; ooo
+ .db 0b00111000 ; ooo
+ .db 0b01110000 ; ooo
+ .db 0b01111110 ; oooooo
+ .db 0b00000000 ;
+
+; Character: 3 (33)
+ .db 0b01111110 ; oooooo
+ .db 0b00001100 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00111100 ; oooo
+ .db 0b00000110 ; oo
+ .db 0b01000110 ; o oo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: 4 (34)
+ .db 0b00001100 ; oo
+ .db 0b00011100 ; ooo
+ .db 0b00101100 ; o oo
+ .db 0b01001100 ; o oo
+ .db 0b01111110 ; oooooo
+ .db 0b00001100 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00000000 ;
+
+; Character: 5 (35)
+ .db 0b01111110 ; oooooo
+ .db 0b01100000 ; oo
+ .db 0b01111100 ; ooooo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b01000110 ; o oo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: 6 (36)
+ .db 0b00011100 ; ooo
+ .db 0b00100000 ; o
+ .db 0b01100000 ; oo
+ .db 0b01111100 ; ooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: 7 (37)
+ .db 0b01111110 ; oooooo
+ .db 0b00000110 ; oo
+ .db 0b00001110 ; ooo
+ .db 0b00011100 ; ooo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+
+; Character: 8 (38)
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: 9 (39)
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111110 ; ooooo
+ .db 0b00000110 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00111000 ; ooo
+ .db 0b00000000 ;
+
+; Character: : (3A)
+ .db 0b00000000 ;
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+
+; Character: ; (3B)
+ .db 0b00000000 ;
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00010000 ; o
+ .db 0b00000000 ;
+
+; Character: < (3C)
+ .db 0b00000110 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00110000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00000000 ;
+
+; Character: = (3D)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: > (3E)
+ .db 0b01100000 ; oo
+ .db 0b00110000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00110000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b00000000 ;
+
+; Character: ? (3F)
+ .db 0b00111100 ; oooo
+ .db 0b01000110 ; o oo
+ .db 0b00000110 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+ .db 0b00011000 ; oo
+
+; Character: @ (40)
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01101110 ; oo ooo
+ .db 0b01101010 ; oo o o
+ .db 0b01101110 ; oo ooo
+ .db 0b01100000 ; oo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: A (41)
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01111110 ; oooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00000000 ;
+
+; Character: B (42)
+ .db 0b01111100 ; ooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01111100 ; ooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01111100 ; ooooo
+ .db 0b00000000 ;
+
+; Character: C (43)
+ .db 0b00111100 ; oooo
+ .db 0b01100010 ; oo o
+ .db 0b01100000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b01100010 ; oo o
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: D (44)
+ .db 0b01111100 ; ooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01111100 ; ooooo
+ .db 0b00000000 ;
+
+; Character: E (45)
+ .db 0b01111110 ; oooooo
+ .db 0b01100000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b01111100 ; ooooo
+ .db 0b01100000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b01111110 ; oooooo
+ .db 0b00000000 ;
+
+; Character: F (46)
+ .db 0b01111110 ; oooooo
+ .db 0b01100000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b01111100 ; ooooo
+ .db 0b01100000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b00000000 ;
+
+; Character: G (47)
+ .db 0b00111100 ; oooo
+ .db 0b01100010 ; oo o
+ .db 0b01100000 ; oo
+ .db 0b01101110 ; oo ooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111110 ; ooooo
+ .db 0b00000000 ;
+
+; Character: H (48)
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01111110 ; oooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00000000 ;
+
+; Character: I (49)
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+
+; Character: J (4A)
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b01000110 ; o oo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: K (4B)
+ .db 0b01100110 ; oo oo
+ .db 0b01101100 ; oo oo
+ .db 0b01111000 ; oooo
+ .db 0b01110000 ; ooo
+ .db 0b01111000 ; oooo
+ .db 0b01101100 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00000000 ;
+
+; Character: L (4C)
+ .db 0b01100000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b01111100 ; ooooo
+ .db 0b00000000 ;
+
+; Character: M (4D)
+ .db 0b11111100 ; oooooo
+ .db 0b11010110 ; oo o oo
+ .db 0b11010110 ; oo o oo
+ .db 0b11010110 ; oo o oo
+ .db 0b11010110 ; oo o oo
+ .db 0b11000110 ; oo oo
+ .db 0b11000110 ; oo oo
+ .db 0b00000000 ;
+
+; Character: N (4E)
+ .db 0b01100010 ; oo o
+ .db 0b01110010 ; ooo o
+ .db 0b01111010 ; oooo o
+ .db 0b01011110 ; o oooo
+ .db 0b01001110 ; o ooo
+ .db 0b01000110 ; o oo
+ .db 0b01000010 ; o o
+ .db 0b00000000 ;
+
+; Character: O (4F)
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: P (50)
+ .db 0b01111100 ; ooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01111100 ; ooooo
+ .db 0b01100000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b00000000 ;
+
+; Character: Q (51)
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b00000110 ; oo
+
+; Character: R (52)
+ .db 0b01111100 ; ooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01111100 ; ooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00000000 ;
+
+; Character: S (53)
+ .db 0b00111100 ; oooo
+ .db 0b01100010 ; oo o
+ .db 0b01110000 ; ooo
+ .db 0b00111100 ; oooo
+ .db 0b00001110 ; ooo
+ .db 0b01000110 ; o oo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: T (54)
+ .db 0b01111110 ; oooooo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+
+; Character: U (55)
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: V (56)
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100100 ; oo o
+ .db 0b01111000 ; oooo
+ .db 0b00000000 ;
+
+; Character: W (57)
+ .db 0b11000110 ; oo oo
+ .db 0b11000110 ; oo oo
+ .db 0b11000110 ; oo oo
+ .db 0b11010110 ; oo o oo
+ .db 0b11010110 ; oo o oo
+ .db 0b11010110 ; oo o oo
+ .db 0b11111100 ; oooooo
+ .db 0b00000000 ;
+
+; Character: X (58)
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00000000 ;
+
+; Character: Y (59)
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+
+; Character: Z (5A)
+ .db 0b01111110 ; oooooo
+ .db 0b00001110 ; ooo
+ .db 0b00011100 ; ooo
+ .db 0b00111000 ; ooo
+ .db 0b01110000 ; ooo
+ .db 0b01100000 ; oo
+ .db 0b01111110 ; oooooo
+ .db 0b00000000 ;
+
+; Character: [ (5B)
+ .db 0b00011110 ; oooo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011110 ; oooo
+ .db 0b00000000 ;
+
+; Character: \ (5C)
+ .db 0b01000000 ; o
+ .db 0b01100000 ; oo
+ .db 0b00110000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00000010 ; o
+ .db 0b00000000 ;
+
+; Character: ] (5D)
+ .db 0b01111000 ; oooo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b01111000 ; oooo
+ .db 0b00000000 ;
+
+; Character: ^ (5E)
+ .db 0b00010000 ; o
+ .db 0b00111000 ; ooo
+ .db 0b01101100 ; oo oo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: _ (5F)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b01111110 ; oooooo
+ .db 0b00000000 ;
+
+; Character: ` (60)
+ .db 0b00000000 ;
+ .db 0b11000000 ; oo
+ .db 0b11000000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: a (61)
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01000110 ; o oo
+ .db 0b00111110 ; ooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111110 ; ooooo
+ .db 0b00000000 ;
+
+; Character: b (62)
+ .db 0b01100000 ; oo
+ .db 0b01111100 ; ooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01111100 ; ooooo
+ .db 0b00000000 ;
+
+; Character: c (63)
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01100010 ; oo o
+ .db 0b01100000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b01100010 ; oo o
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: d (64)
+ .db 0b00000110 ; oo
+ .db 0b00111110 ; ooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111110 ; ooooo
+ .db 0b00000000 ;
+
+; Character: e (65)
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01111110 ; oooooo
+ .db 0b01100000 ; oo
+ .db 0b01100010 ; oo o
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: f (66)
+ .db 0b00011110 ; oooo
+ .db 0b00110000 ; oo
+ .db 0b01111100 ; ooooo
+ .db 0b00110000 ; oo
+ .db 0b00110000 ; oo
+ .db 0b00110000 ; oo
+ .db 0b00110000 ; oo
+ .db 0b00000000 ;
+
+; Character: g (67)
+ .db 0b00000000 ;
+ .db 0b00111110 ; ooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111110 ; ooooo
+ .db 0b01000110 ; o oo
+ .db 0b00111100 ; oooo
+
+; Character: h (68)
+ .db 0b01100000 ; oo
+ .db 0b01111100 ; ooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00000000 ;
+
+; Character: i (69)
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+
+; Character: j (6A)
+ .db 0b00000000 ;
+ .db 0b00001000 ; o
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b01011000 ; o oo
+ .db 0b00110000 ; oo
+
+; Character: k (6B)
+ .db 0b01100000 ; oo
+ .db 0b01100100 ; oo o
+ .db 0b01101000 ; oo o
+ .db 0b01110000 ; ooo
+ .db 0b01111000 ; oooo
+ .db 0b01101100 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00000000 ;
+
+; Character: l (6C)
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00000000 ;
+
+; Character: m (6D)
+ .db 0b00000000 ;
+ .db 0b11111100 ; oooooo
+ .db 0b11010110 ; oo o oo
+ .db 0b11010110 ; oo o oo
+ .db 0b11010110 ; oo o oo
+ .db 0b11010110 ; oo o oo
+ .db 0b11000110 ; oo oo
+ .db 0b00000000 ;
+
+; Character: n (6E)
+ .db 0b00000000 ;
+ .db 0b01111100 ; ooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00000000 ;
+
+; Character: o (6F)
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: p (70)
+ .db 0b00000000 ;
+ .db 0b01111100 ; ooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01111100 ; ooooo
+ .db 0b01100000 ; oo
+ .db 0b01100000 ; oo
+
+; Character: q (71)
+ .db 0b00000000 ;
+ .db 0b00111110 ; ooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111110 ; ooooo
+ .db 0b00000110 ; oo
+
+; Character: r (72)
+ .db 0b00000000 ;
+ .db 0b01101100 ; oo oo
+ .db 0b01110000 ; ooo
+ .db 0b01100000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b00000000 ;
+
+; Character: s (73)
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01110010 ; ooo o
+ .db 0b00111000 ; ooo
+ .db 0b00011100 ; ooo
+ .db 0b01001110 ; o ooo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: t (74)
+ .db 0b00011000 ; oo
+ .db 0b00111100 ; oooo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00000000 ;
+
+; Character: u (75)
+ .db 0b00000000 ;
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111110 ; ooooo
+ .db 0b00000000 ;
+
+; Character: v (76)
+ .db 0b00000000 ;
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100100 ; oo o
+ .db 0b01111000 ; oooo
+ .db 0b00000000 ;
+
+; Character: w (77)
+ .db 0b00000000 ;
+ .db 0b11000110 ; oo oo
+ .db 0b11000110 ; oo oo
+ .db 0b11010110 ; oo o oo
+ .db 0b11010110 ; oo o oo
+ .db 0b11010110 ; oo o oo
+ .db 0b11111100 ; oooooo
+ .db 0b00000000 ;
+
+; Character: x (78)
+ .db 0b00000000 ;
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00000000 ;
+
+; Character: y (79)
+ .db 0b00000000 ;
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00100110 ; o oo
+ .db 0b00011110 ; oooo
+ .db 0b01000110 ; o oo
+ .db 0b00111100 ; oooo
+
+; Character: z (7A)
+ .db 0b00000000 ;
+ .db 0b01111110 ; oooooo
+ .db 0b00001110 ; ooo
+ .db 0b00011100 ; ooo
+ .db 0b00111000 ; ooo
+ .db 0b01110000 ; ooo
+ .db 0b01111110 ; oooooo
+ .db 0b00000000 ;
+
+; Character: { (7B)
+ .db 0b00001110 ; ooo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00110000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00001110 ; ooo
+ .db 0b00000000 ;
+
+; Character: | (7C)
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+
+; Character: } (7D)
+ .db 0b01110000 ; ooo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b01110000 ; ooo
+ .db 0b00000000 ;
+
+; Character: ~ (7E)
+ .db 0b00000000 ;
+ .db 0b01100000 ; oo
+ .db 0b11110010 ; oooo o
+ .db 0b10011110 ; o oooo
+ .db 0b00001100 ; oo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (7F)
+ .db 0b00010000 ; o
+ .db 0b00010000 ; o
+ .db 0b00101000 ; o o
+ .db 0b00101000 ; o o
+ .db 0b01000100 ; o o
+ .db 0b01000100 ; o o
+ .db 0b10000010 ; o o
+ .db 0b11111110 ; ooooooo
+
+; Character: ? (80)
+ .db 0b00111100 ; oooo
+ .db 0b01100010 ; oo o
+ .db 0b01100000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b01100010 ; oo o
+ .db 0b00011100 ; ooo
+ .db 0b00110000 ; oo
+
+; Character: ? (81)
+ .db 0b00100100 ; o o
+ .db 0b00000000 ;
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111110 ; ooooo
+ .db 0b00000000 ;
+
+; Character: ? (82)
+ .db 0b00001100 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01111110 ; oooooo
+ .db 0b01100000 ; oo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: ? (83)
+ .db 0b00011000 ; oo
+ .db 0b01100110 ; oo oo
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b00000110 ; oo
+ .db 0b01111110 ; oooooo
+ .db 0b00111110 ; ooooo
+ .db 0b00000000 ;
+
+; Character: ? (84)
+ .db 0b00100100 ; o o
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01000110 ; o oo
+ .db 0b00111110 ; ooooo
+ .db 0b01000110 ; o oo
+ .db 0b00111110 ; ooooo
+ .db 0b00000000 ;
+
+; Character: ? (85)
+ .db 0b00110000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b00000110 ; oo
+ .db 0b01111110 ; oooooo
+ .db 0b00111110 ; ooooo
+ .db 0b00000000 ;
+
+; Character: ? (86)
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b00000110 ; oo
+ .db 0b01111110 ; oooooo
+ .db 0b00111110 ; ooooo
+ .db 0b00000000 ;
+
+; Character: ? (87)
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01100010 ; oo o
+ .db 0b01100000 ; oo
+ .db 0b01100010 ; oo o
+ .db 0b00111100 ; oooo
+ .db 0b00001000 ; o
+ .db 0b00011000 ; oo
+
+; Character: ? (88)
+ .db 0b00011000 ; oo
+ .db 0b00110100 ; oo o
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01111110 ; oooooo
+ .db 0b01100000 ; oo
+ .db 0b00111110 ; ooooo
+ .db 0b00000000 ;
+
+; Character: ? (89)
+ .db 0b00100100 ; o o
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01111110 ; oooooo
+ .db 0b01100000 ; oo
+ .db 0b00111110 ; ooooo
+ .db 0b00000000 ;
+
+; Character: ? (8A)
+ .db 0b00110000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01111110 ; oooooo
+ .db 0b01100000 ; oo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: ? (8B)
+ .db 0b00100100 ; o o
+ .db 0b00000000 ;
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+
+; Character: ? (8C)
+ .db 0b00011000 ; oo
+ .db 0b00100100 ; o o
+ .db 0b00000000 ;
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+
+; Character: ? (8D)
+ .db 0b00010000 ; o
+ .db 0b00001000 ; o
+ .db 0b00000000 ;
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+
+; Character: ? (8E)
+ .db 0b00100100 ; o o
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01111110 ; oooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00000000 ;
+
+; Character: ? (8F)
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01111110 ; oooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00000000 ;
+
+; Character: ? (90)
+ .db 0b00001100 ; oo
+ .db 0b00011000 ; oo
+ .db 0b01111110 ; oooooo
+ .db 0b01100000 ; oo
+ .db 0b01111100 ; ooooo
+ .db 0b01100000 ; oo
+ .db 0b01111110 ; oooooo
+ .db 0b00000000 ;
+
+; Character: ? (91)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b01111110 ; oooooo
+ .db 0b00011011 ; oo oo
+ .db 0b01111111 ; ooooooo
+ .db 0b11011000 ; oo oo
+ .db 0b01111110 ; oooooo
+ .db 0b00000000 ;
+
+; Character: ? (92)
+ .db 0b00111111 ; oooooo
+ .db 0b01111000 ; oooo
+ .db 0b11011000 ; oo oo
+ .db 0b11011110 ; oo oooo
+ .db 0b11111000 ; ooooo
+ .db 0b11011000 ; oo oo
+ .db 0b11011111 ; oo ooooo
+ .db 0b00000000 ;
+
+; Character: ? (93)
+ .db 0b00011000 ; oo
+ .db 0b00110100 ; oo o
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: ? (94)
+ .db 0b00100100 ; o o
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: ? (95)
+ .db 0b00110000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: ? (96)
+ .db 0b00011000 ; oo
+ .db 0b00100100 ; o o
+ .db 0b00000000 ;
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: ? (97)
+ .db 0b00110000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: ? (98)
+ .db 0b01100110 ; oo oo
+ .db 0b00000000 ;
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111110 ; ooooo
+ .db 0b01000110 ; o oo
+ .db 0b00111100 ; oooo
+
+; Character: ? (99)
+ .db 0b01100110 ; oo oo
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: ? (9A)
+ .db 0b01100110 ; oo oo
+ .db 0b00000000 ;
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: ? (9B)
+ .db 0b00011000 ; oo
+ .db 0b00111100 ; oooo
+ .db 0b01100010 ; oo o
+ .db 0b01100000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b01100010 ; oo o
+ .db 0b00111100 ; oooo
+ .db 0b00011000 ; oo
+
+; Character: ? (9C)
+ .db 0b00011100 ; ooo
+ .db 0b00111010 ; ooo o
+ .db 0b00110000 ; oo
+ .db 0b01111100 ; ooooo
+ .db 0b00110000 ; oo
+ .db 0b00110000 ; oo
+ .db 0b01111110 ; oooooo
+ .db 0b00000000 ;
+
+; Character: ? (9D)
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b00011000 ; oo
+ .db 0b00111100 ; oooo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+
+; Character: ? (9E)
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01101100 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b11101100 ; ooo oo
+ .db 0b00000000 ;
+
+; Character: ? (9F)
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+
+; Character: ? (A0)
+ .db 0b00001100 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b00000110 ; oo
+ .db 0b01111110 ; oooooo
+ .db 0b00111110 ; ooooo
+ .db 0b00000000 ;
+
+; Character: ? (A1)
+ .db 0b00001100 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+
+; Character: ? (A2)
+ .db 0b00001100 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: ? (A3)
+ .db 0b00001100 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111110 ; ooooo
+ .db 0b00000000 ;
+
+; Character: ? (A4)
+ .db 0b00110100 ; oo o
+ .db 0b01011000 ; o oo
+ .db 0b00000000 ;
+ .db 0b01111100 ; ooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00000000 ;
+
+; Character: ? (A5)
+ .db 0b00011010 ; oo o
+ .db 0b00101100 ; o oo
+ .db 0b01100010 ; oo o
+ .db 0b01110010 ; ooo o
+ .db 0b01011010 ; o oo o
+ .db 0b01001110 ; o ooo
+ .db 0b01000110 ; o oo
+ .db 0b00000000 ;
+
+; Character: ? (A6)
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01000110 ; o oo
+ .db 0b00111110 ; ooooo
+ .db 0b01100110 ; oo oo
+ .db 0b00111110 ; ooooo
+ .db 0b00000000 ;
+ .db 0b01111110 ; oooooo
+
+; Character: ? (A7)
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+ .db 0b01111110 ; oooooo
+
+; Character: ? (A8)
+ .db 0b00000000 ;
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+ .db 0b00011000 ; oo
+ .db 0b00110000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+
+; Character: ? (A9)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00111110 ; ooooo
+ .db 0b00110000 ; oo
+ .db 0b00110000 ; oo
+ .db 0b00110000 ; oo
+ .db 0b00000000 ;
+
+; Character: ? (AA)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b01111100 ; ooooo
+ .db 0b00001100 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00000000 ;
+
+; Character: ? (AB)
+ .db 0b01100010 ; oo o
+ .db 0b11100100 ; ooo o
+ .db 0b01101000 ; oo o
+ .db 0b01110110 ; ooo oo
+ .db 0b00101011 ; o o oo
+ .db 0b01000011 ; o oo
+ .db 0b10000110 ; o oo
+ .db 0b00001111 ; oooo
+
+; Character: ? (AC)
+ .db 0b01100010 ; oo o
+ .db 0b11100100 ; ooo o
+ .db 0b01101000 ; oo o
+ .db 0b01110110 ; ooo oo
+ .db 0b00101110 ; o ooo
+ .db 0b01010110 ; o o oo
+ .db 0b10011111 ; o ooooo
+ .db 0b00000110 ; oo
+
+; Character: ? (AD)
+ .db 0b00000000 ;
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+
+; Character: ? (AE)
+ .db 0b00011011 ; oo oo
+ .db 0b00110110 ; oo oo
+ .db 0b01101100 ; oo oo
+ .db 0b11011000 ; oo oo
+ .db 0b01101100 ; oo oo
+ .db 0b00110110 ; oo oo
+ .db 0b00011011 ; oo oo
+ .db 0b00000000 ;
+
+; Character: ? (AF)
+ .db 0b11011000 ; oo oo
+ .db 0b01101100 ; oo oo
+ .db 0b00110110 ; oo oo
+ .db 0b00011011 ; oo oo
+ .db 0b00110110 ; oo oo
+ .db 0b01101100 ; oo oo
+ .db 0b11011000 ; oo oo
+ .db 0b00000000 ;
+
+; Character: ? (B0)
+ .db 0b00110100 ; oo o
+ .db 0b01011000 ; o oo
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b00000110 ; oo
+ .db 0b01111110 ; oooooo
+ .db 0b00111110 ; ooooo
+ .db 0b00000000 ;
+
+; Character: ? (B1)
+ .db 0b00110100 ; oo o
+ .db 0b01011000 ; o oo
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: ? (B2)
+ .db 0b00000010 ; o
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01101110 ; oo ooo
+ .db 0b01110110 ; ooo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b01000000 ; o
+
+; Character: ? (B3)
+ .db 0b00000000 ;
+ .db 0b00000010 ; o
+ .db 0b00111100 ; oooo
+ .db 0b01101110 ; oo ooo
+ .db 0b01110110 ; ooo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b01000000 ; o
+
+; Character: ? (B4)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b01111110 ; oooooo
+ .db 0b11011011 ; oo oo oo
+ .db 0b11011110 ; oo oooo
+ .db 0b11011000 ; oo oo
+ .db 0b01111111 ; ooooooo
+ .db 0b00000000 ;
+
+; Character: ? (B5)
+ .db 0b00000000 ;
+ .db 0b01111110 ; oooooo
+ .db 0b11011000 ; oo oo
+ .db 0b11011000 ; oo oo
+ .db 0b11111100 ; oooooo
+ .db 0b11011000 ; oo oo
+ .db 0b11011000 ; oo oo
+ .db 0b11011110 ; oo oooo
+
+; Character: ? (B6)
+ .db 0b00100000 ; o
+ .db 0b00010000 ; o
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01111110 ; oooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+
+; Character: ? (B7)
+ .db 0b00110100 ; oo o
+ .db 0b01011000 ; o oo
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01111110 ; oooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+
+; Character: ? (B8)
+ .db 0b00110100 ; oo o
+ .db 0b01011000 ; o oo
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+
+; Character: ? (B9)
+ .db 0b01100110 ; oo oo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (BA)
+ .db 0b00001100 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00110000 ; oo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (BB)
+ .db 0b00000000 ;
+ .db 0b00010000 ; o
+ .db 0b00111000 ; ooo
+ .db 0b00010000 ; o
+ .db 0b00010000 ; o
+ .db 0b00010000 ; o
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (BC)
+ .db 0b01111010 ; oooo o
+ .db 0b11001010 ; oo o o
+ .db 0b11001010 ; oo o o
+ .db 0b11001010 ; oo o o
+ .db 0b01111010 ; oooo o
+ .db 0b00001010 ; o o
+ .db 0b00001010 ; o o
+ .db 0b00001010 ; o o
+
+; Character: ? (BD)
+ .db 0b00111100 ; oooo
+ .db 0b01000010 ; o o
+ .db 0b10011001 ; o oo o
+ .db 0b10110101 ; o oo o o
+ .db 0b10110001 ; o oo o
+ .db 0b10011101 ; o ooo o
+ .db 0b01000010 ; o o
+ .db 0b00111100 ; oooo
+
+; Character: ? (BE)
+ .db 0b00111100 ; oooo
+ .db 0b01000010 ; o o
+ .db 0b10111001 ; o ooo o
+ .db 0b10110101 ; o oo o o
+ .db 0b10111001 ; o ooo o
+ .db 0b10110101 ; o oo o o
+ .db 0b01000010 ; o o
+ .db 0b00111100 ; oooo
+
+; Character: ? (BF)
+ .db 0b11110001 ; oooo o
+ .db 0b01011011 ; o oo oo
+ .db 0b01010101 ; o o o o
+ .db 0b01010001 ; o o o
+ .db 0b01010001 ; o o o
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (C0)
+ .db 0b01100110 ; oo oo
+ .db 0b00000000 ;
+ .db 0b11100110 ; ooo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b11110110 ; oooo oo
+ .db 0b00000110 ; oo
+ .db 0b00011100 ; ooo
+
+; Character: ? (C1)
+ .db 0b11110110 ; oooo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b11110110 ; oooo oo
+ .db 0b00000110 ; oo
+ .db 0b00011100 ; ooo
+
+; Character: ? (C2)
+ .db 0b00000000 ;
+ .db 0b01100110 ; oo oo
+ .db 0b01110110 ; ooo oo
+ .db 0b00111100 ; oooo
+ .db 0b01101110 ; oo ooo
+ .db 0b01100110 ; oo oo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (C3)
+ .db 0b00000000 ;
+ .db 0b01111100 ; ooooo
+ .db 0b00001100 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00001100 ; oo
+ .db 0b01111110 ; oooooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (C4)
+ .db 0b00000000 ;
+ .db 0b00011110 ; oooo
+ .db 0b00000110 ; oo
+ .db 0b00001110 ; ooo
+ .db 0b00011110 ; oooo
+ .db 0b00110110 ; oo oo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (C5)
+ .db 0b00000000 ;
+ .db 0b01111110 ; oooooo
+ .db 0b00001100 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (C6)
+ .db 0b00000000 ;
+ .db 0b01111100 ; ooooo
+ .db 0b00000110 ; oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (C7)
+ .db 0b00000000 ;
+ .db 0b00011100 ; ooo
+ .db 0b00001100 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (C8)
+ .db 0b00000000 ;
+ .db 0b00011110 ; oooo
+ .db 0b00001100 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (C9)
+ .db 0b00000000 ;
+ .db 0b01111110 ; oooooo
+ .db 0b00110110 ; oo oo
+ .db 0b00110110 ; oo oo
+ .db 0b00110110 ; oo oo
+ .db 0b00110110 ; oo oo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (CA)
+ .db 0b01100000 ; oo
+ .db 0b01101110 ; oo ooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01111110 ; oooooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (CB)
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b00001100 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (CC)
+ .db 0b00000000 ;
+ .db 0b00111110 ; ooooo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00111110 ; ooooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (CD)
+ .db 0b01100000 ; oo
+ .db 0b01111110 ; oooooo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00001110 ; ooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (CE)
+ .db 0b00000000 ;
+ .db 0b01101100 ; oo oo
+ .db 0b00111110 ; ooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01101110 ; oo ooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (CF)
+ .db 0b00000000 ;
+ .db 0b00011100 ; ooo
+ .db 0b00001100 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (D0)
+ .db 0b00000000 ;
+ .db 0b00111110 ; ooooo
+ .db 0b00110110 ; oo oo
+ .db 0b00110110 ; oo oo
+ .db 0b00110110 ; oo oo
+ .db 0b00011100 ; ooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (D1)
+ .db 0b00000000 ;
+ .db 0b00110110 ; oo oo
+ .db 0b00110110 ; oo oo
+ .db 0b00110110 ; oo oo
+ .db 0b00110110 ; oo oo
+ .db 0b01111110 ; oooooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (D2)
+ .db 0b00000000 ;
+ .db 0b01111110 ; oooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01110110 ; ooo oo
+ .db 0b00000110 ; oo
+ .db 0b01111110 ; oooooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (D3)
+ .db 0b00000000 ;
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b00001110 ; ooo
+ .db 0b01111110 ; oooooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (D4)
+ .db 0b00000000 ;
+ .db 0b00111110 ; ooooo
+ .db 0b00000110 ; oo
+ .db 0b00110110 ; oo oo
+ .db 0b00110110 ; oo oo
+ .db 0b00110100 ; oo o
+ .db 0b00110000 ; oo
+ .db 0b00000000 ;
+
+; Character: ? (D5)
+ .db 0b00000000 ;
+ .db 0b01111000 ; oooo
+ .db 0b00001100 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (D6)
+ .db 0b00000000 ;
+ .db 0b11010110 ; oo o oo
+ .db 0b11010110 ; oo o oo
+ .db 0b11010110 ; oo o oo
+ .db 0b11010110 ; oo o oo
+ .db 0b11111110 ; ooooooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (D7)
+ .db 0b00000000 ;
+ .db 0b01111100 ; ooooo
+ .db 0b01101100 ; oo oo
+ .db 0b01101100 ; oo oo
+ .db 0b01101100 ; oo oo
+ .db 0b11101100 ; ooo oo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (D8)
+ .db 0b00000000 ;
+ .db 0b00011100 ; ooo
+ .db 0b00001100 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00000000 ;
+
+; Character: ? (D9)
+ .db 0b00000000 ;
+ .db 0b00111110 ; ooooo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00000000 ;
+
+; Character: ? (DA)
+ .db 0b00000000 ;
+ .db 0b11111110 ; ooooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01111110 ; oooooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (DB)
+ .db 0b00000000 ;
+ .db 0b01111110 ; oooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01110110 ; ooo oo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00000000 ;
+
+; Character: ? (DC)
+ .db 0b00000000 ;
+ .db 0b00110110 ; oo oo
+ .db 0b00110110 ; oo oo
+ .db 0b00011100 ; ooo
+ .db 0b00001100 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00000000 ;
+
+; Character: ? (DD)
+ .db 0b00011100 ; ooo
+ .db 0b00110010 ; oo o
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b01001100 ; o oo
+ .db 0b00111000 ; ooo
+
+; Character: ? (DE)
+ .db 0b00000000 ;
+ .db 0b00010000 ; o
+ .db 0b00111000 ; ooo
+ .db 0b01101100 ; oo oo
+ .db 0b11000110 ; oo oo
+ .db 0b10000010 ; o o
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (DF)
+ .db 0b01100110 ; oo oo
+ .db 0b11110111 ; oooo ooo
+ .db 0b10011001 ; o oo o
+ .db 0b10011001 ; o oo o
+ .db 0b11101111 ; ooo oooo
+ .db 0b01100110 ; oo oo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (E0)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b01110110 ; ooo oo
+ .db 0b11011100 ; oo ooo
+ .db 0b11001000 ; oo o
+ .db 0b11011100 ; oo ooo
+ .db 0b01110110 ; ooo oo
+ .db 0b00000000 ;
+
+; Character: ? (E1)
+ .db 0b00011100 ; ooo
+ .db 0b00110110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01111100 ; ooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01111100 ; ooooo
+ .db 0b01100000 ; oo
+
+; Character: ? (E2)
+ .db 0b00000000 ;
+ .db 0b11111110 ; ooooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100010 ; oo o
+ .db 0b01100000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b11111000 ; ooooo
+
+; Character: ? (E3)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b11111110 ; ooooooo
+ .db 0b01101100 ; oo oo
+ .db 0b01101100 ; oo oo
+ .db 0b01101100 ; oo oo
+ .db 0b01101100 ; oo oo
+ .db 0b01001000 ; o o
+
+; Character: ? (E4)
+ .db 0b11111110 ; ooooooo
+ .db 0b01100110 ; oo oo
+ .db 0b00110000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00110000 ; oo
+ .db 0b01100110 ; oo oo
+ .db 0b11111110 ; ooooooo
+ .db 0b00000000 ;
+
+; Character: ? (E5)
+ .db 0b00000000 ;
+ .db 0b00011110 ; oooo
+ .db 0b00111000 ; ooo
+ .db 0b01101100 ; oo oo
+ .db 0b01101100 ; oo oo
+ .db 0b01101100 ; oo oo
+ .db 0b00111000 ; ooo
+ .db 0b00000000 ;
+
+; Character: ? (E6)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b01101100 ; oo oo
+ .db 0b01101100 ; oo oo
+ .db 0b01101100 ; oo oo
+ .db 0b01101100 ; oo oo
+ .db 0b01111111 ; ooooooo
+ .db 0b11000000 ; oo
+
+; Character: ? (E7)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b01111110 ; oooooo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00010000 ; o
+
+; Character: ? (E8)
+ .db 0b00111100 ; oooo
+ .db 0b00011000 ; oo
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b00011000 ; oo
+ .db 0b00111100 ; oooo
+
+; Character: ? (E9)
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01111110 ; oooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: ? (EA)
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00100100 ; o o
+ .db 0b01100110 ; oo oo
+ .db 0b00000000 ;
+
+; Character: ? (EB)
+ .db 0b00011100 ; ooo
+ .db 0b00110110 ; oo oo
+ .db 0b01111000 ; oooo
+ .db 0b11011100 ; oo ooo
+ .db 0b11001100 ; oo oo
+ .db 0b11101100 ; ooo oo
+ .db 0b01111000 ; oooo
+ .db 0b00000000 ;
+
+; Character: ? (EC)
+ .db 0b00001100 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00111000 ; ooo
+ .db 0b01010100 ; o o o
+ .db 0b01010100 ; o o o
+ .db 0b00111000 ; ooo
+ .db 0b00110000 ; oo
+ .db 0b01100000 ; oo
+
+; Character: ? (ED)
+ .db 0b00000000 ;
+ .db 0b00010000 ; o
+ .db 0b01111100 ; ooooo
+ .db 0b11010110 ; oo o oo
+ .db 0b11010110 ; oo o oo
+ .db 0b11010110 ; oo o oo
+ .db 0b01111100 ; ooooo
+ .db 0b00010000 ; o
+
+; Character: ? (EE)
+ .db 0b00111110 ; ooooo
+ .db 0b01110000 ; ooo
+ .db 0b01100000 ; oo
+ .db 0b01111110 ; oooooo
+ .db 0b01100000 ; oo
+ .db 0b01110000 ; ooo
+ .db 0b00111110 ; ooooo
+ .db 0b00000000 ;
+
+; Character: ? (EF)
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00000000 ;
+
+; Character: ? (F0)
+ .db 0b00000000 ;
+ .db 0b01111110 ; oooooo
+ .db 0b00000000 ;
+ .db 0b01111110 ; oooooo
+ .db 0b00000000 ;
+ .db 0b01111110 ; oooooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (F1)
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b01111110 ; oooooo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+ .db 0b01111110 ; oooooo
+ .db 0b00000000 ;
+
+; Character: ? (F2)
+ .db 0b00110000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00110000 ; oo
+ .db 0b00000000 ;
+ .db 0b01111110 ; oooooo
+ .db 0b00000000 ;
+
+; Character: ? (F3)
+ .db 0b00001100 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00110000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00000000 ;
+ .db 0b01111110 ; oooooo
+ .db 0b00000000 ;
+
+; Character: ? (F4)
+ .db 0b00000000 ;
+ .db 0b00001110 ; ooo
+ .db 0b00011011 ; oo oo
+ .db 0b00011011 ; oo oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+
+; Character: ? (F5)
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b11011000 ; oo oo
+ .db 0b11011000 ; oo oo
+ .db 0b01110000 ; ooo
+ .db 0b00000000 ;
+
+; Character: ? (F6)
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+ .db 0b01111110 ; oooooo
+ .db 0b00000000 ;
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+
+; Character: ? (F7)
+ .db 0b00000000 ;
+ .db 0b00110010 ; oo o
+ .db 0b01001100 ; o oo
+ .db 0b00000000 ;
+ .db 0b00110010 ; oo o
+ .db 0b01001100 ; o oo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (F8)
+ .db 0b00111000 ; ooo
+ .db 0b01101100 ; oo oo
+ .db 0b00111000 ; ooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (F9)
+ .db 0b00111000 ; ooo
+ .db 0b01111100 ; ooooo
+ .db 0b00111000 ; ooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (FA)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (FB)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00001111 ; oooo
+ .db 0b00011000 ; oo
+ .db 0b11011000 ; oo oo
+ .db 0b01110000 ; ooo
+ .db 0b00110000 ; oo
+ .db 0b00000000 ;
+
+; Character: ? (FC)
+ .db 0b00111000 ; ooo
+ .db 0b01101100 ; oo oo
+ .db 0b01101100 ; oo oo
+ .db 0b01101100 ; oo oo
+ .db 0b01101100 ; oo oo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (FD)
+ .db 0b00111000 ; ooo
+ .db 0b01101100 ; oo oo
+ .db 0b00011000 ; oo
+ .db 0b00110000 ; oo
+ .db 0b01111100 ; ooooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (FE)
+ .db 0b01111000 ; oooo
+ .db 0b00001100 ; oo
+ .db 0b00111000 ; ooo
+ .db 0b00001100 ; oo
+ .db 0b01111000 ; oooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (FF)
+ .db 0b00000000 ;
+ .db 0b11111110 ; ooooooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/f_ibm_sh.s b/gbdk/gbdk-lib/libc/targets/sm83/f_ibm_sh.s
new file mode 100644
index 00000000..83e66d6b
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/f_ibm_sh.s
@@ -0,0 +1,174 @@
+; ibm_fixed.ms - fixed width IBM font
+
+ .area _HOME
+
+ ; 898 bytes giving ' '-'0'-'@'-'A'-'Z'-'???'-'a'-'z'-127
+_font_ibm::
+ .byte 1+4 ; 128 character encoding
+ .byte 128-32+6 ; Tiles required
+
+ .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,96,97 ; All map to space
+ .byte 0,0,0,0,0,0,0,0,0,0,0,0,98,99,100,101
+ .byte 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 ; 0x20
+ .byte 16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31
+ .byte 32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47 ; 0x40
+ .byte 48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63
+ .byte 64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79 ; 0x60
+ .byte 80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95
+
+ .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+ .byte 0x18,0x18,0x18,0x18,0x18,0x00,0x18,0x00
+ .byte 0x66,0x66,0x44,0x00,0x00,0x00,0x00,0x00
+ .byte 0x00,0x24,0x7E,0x24,0x24,0x7E,0x24,0x00
+ .byte 0x14,0x3E,0x55,0x3C,0x1E,0x55,0x3E,0x14
+ .byte 0x62,0x66,0x0C,0x18,0x30,0x66,0x46,0x00
+ .byte 0x78,0xCC,0x61,0xCE,0xCC,0xCC,0x78,0x00
+ .byte 0x18,0x18,0x10,0x00,0x00,0x00,0x00,0x00
+ .byte 0x04,0x08,0x18,0x18,0x18,0x18,0x08,0x04
+ .byte 0x20,0x10,0x18,0x18,0x18,0x18,0x10,0x20
+ .byte 0x00,0x54,0x38,0xFE,0x38,0x54,0x00,0x00
+ .byte 0x00,0x18,0x18,0x7E,0x18,0x18,0x00,0x00
+ .byte 0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x20
+ .byte 0x00,0x00,0x00,0x3C,0x00,0x00,0x00,0x00
+ .byte 0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00
+ .byte 0x03,0x06,0x0C,0x18,0x30,0x60,0xC0,0x00
+ .byte 0x3C,0x66,0x6E,0x76,0x66,0x66,0x3C,0x00
+ .byte 0x18,0x38,0x18,0x18,0x18,0x18,0x18,0x00
+ .byte 0x3C,0x66,0x0E,0x1C,0x38,0x70,0x7E,0x00
+ .byte 0x7E,0x0C,0x18,0x3C,0x06,0x46,0x3C,0x00
+ .byte 0x0C,0x1C,0x2C,0x4C,0x7E,0x0C,0x0C,0x00
+ .byte 0x7E,0x60,0x7C,0x06,0x06,0x46,0x3C,0x00
+ .byte 0x1C,0x20,0x60,0x7C,0x66,0x66,0x3C,0x00
+ .byte 0x7E,0x06,0x0E,0x1C,0x18,0x18,0x18,0x00
+ .byte 0x3C,0x66,0x66,0x3C,0x66,0x66,0x3C,0x00
+ .byte 0x3C,0x66,0x66,0x3E,0x06,0x0C,0x38,0x00
+ .byte 0x00,0x18,0x18,0x00,0x00,0x18,0x18,0x00
+ .byte 0x00,0x18,0x18,0x00,0x18,0x18,0x10,0x00
+ .byte 0x06,0x0C,0x18,0x30,0x18,0x0C,0x06,0x00
+ .byte 0x00,0x00,0x3C,0x00,0x00,0x3C,0x00,0x00
+ .byte 0x60,0x30,0x18,0x0C,0x18,0x30,0x60,0x00
+ .byte 0x3C,0x46,0x06,0x0C,0x18,0x18,0x00,0x18
+ .byte 0x3C,0x66,0x6E,0x6A,0x6E,0x60,0x3C,0x00
+ .byte 0x3C,0x66,0x66,0x7E,0x66,0x66,0x66,0x00
+ .byte 0x7C,0x66,0x66,0x7C,0x66,0x66,0x7C,0x00
+ .byte 0x3C,0x62,0x60,0x60,0x60,0x62,0x3C,0x00
+ .byte 0x7C,0x66,0x66,0x66,0x66,0x66,0x7C,0x00
+ .byte 0x7E,0x60,0x60,0x7C,0x60,0x60,0x7E,0x00
+ .byte 0x7E,0x60,0x60,0x7C,0x60,0x60,0x60,0x00
+ .byte 0x3C,0x62,0x60,0x6E,0x66,0x66,0x3E,0x00
+ .byte 0x66,0x66,0x66,0x7E,0x66,0x66,0x66,0x00
+ .byte 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x00
+ .byte 0x06,0x06,0x06,0x06,0x06,0x46,0x3C,0x00
+ .byte 0x66,0x6C,0x78,0x70,0x78,0x6C,0x66,0x00
+ .byte 0x60,0x60,0x60,0x60,0x60,0x60,0x7C,0x00
+ .byte 0xFC,0xD6,0xD6,0xD6,0xD6,0xC6,0xC6,0x00
+ .byte 0x62,0x72,0x7A,0x5E,0x4E,0x46,0x42,0x00
+ .byte 0x3C,0x66,0x66,0x66,0x66,0x66,0x3C,0x00
+ .byte 0x7C,0x66,0x66,0x7C,0x60,0x60,0x60,0x00
+ .byte 0x3C,0x66,0x66,0x66,0x66,0x66,0x3C,0x06
+ .byte 0x7C,0x66,0x66,0x7C,0x66,0x66,0x66,0x00
+ .byte 0x3C,0x62,0x70,0x3C,0x0E,0x46,0x3C,0x00
+ .byte 0x7E,0x18,0x18,0x18,0x18,0x18,0x18,0x00
+ .byte 0x66,0x66,0x66,0x66,0x66,0x66,0x3C,0x00
+ .byte 0x66,0x66,0x66,0x66,0x66,0x64,0x78,0x00
+ .byte 0xC6,0xC6,0xC6,0xD6,0xD6,0xD6,0xFC,0x00
+ .byte 0x66,0x66,0x66,0x3C,0x66,0x66,0x66,0x00
+ .byte 0x66,0x66,0x66,0x3C,0x18,0x18,0x18,0x00
+ .byte 0x7E,0x0E,0x1C,0x38,0x70,0x60,0x7E,0x00
+ .byte 0x1E,0x18,0x18,0x18,0x18,0x18,0x1E,0x00
+ .byte 0x40,0x60,0x30,0x18,0x0C,0x06,0x02,0x00
+ .byte 0x78,0x18,0x18,0x18,0x18,0x18,0x78,0x00
+ .byte 0x10,0x38,0x6C,0x00,0x00,0x00,0x00,0x00
+ .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x00
+ .byte 0x00,0xC0,0xC0,0x60,0x00,0x00,0x00,0x00
+ .byte 0x00,0x3C,0x46,0x3E,0x66,0x66,0x3E,0x00
+ .byte 0x60,0x7C,0x66,0x66,0x66,0x66,0x7C,0x00
+ .byte 0x00,0x3C,0x62,0x60,0x60,0x62,0x3C,0x00
+ .byte 0x06,0x3E,0x66,0x66,0x66,0x66,0x3E,0x00
+ .byte 0x00,0x3C,0x66,0x7E,0x60,0x62,0x3C,0x00
+ .byte 0x1E,0x30,0x7C,0x30,0x30,0x30,0x30,0x00
+ .byte 0x00,0x3E,0x66,0x66,0x66,0x3E,0x46,0x3C
+ .byte 0x60,0x7C,0x66,0x66,0x66,0x66,0x66,0x00
+ .byte 0x18,0x00,0x18,0x18,0x18,0x18,0x18,0x00
+ .byte 0x00,0x08,0x18,0x18,0x18,0x18,0x58,0x30
+ .byte 0x60,0x64,0x68,0x70,0x78,0x6C,0x66,0x00
+ .byte 0x18,0x18,0x18,0x18,0x18,0x18,0x0C,0x00
+ .byte 0x00,0xFC,0xD6,0xD6,0xD6,0xD6,0xC6,0x00
+ .byte 0x00,0x7C,0x66,0x66,0x66,0x66,0x66,0x00
+ .byte 0x00,0x3C,0x66,0x66,0x66,0x66,0x3C,0x00
+ .byte 0x00,0x7C,0x66,0x66,0x66,0x7C,0x60,0x60
+ .byte 0x00,0x3E,0x66,0x66,0x66,0x66,0x3E,0x06
+ .byte 0x00,0x6C,0x70,0x60,0x60,0x60,0x60,0x00
+ .byte 0x00,0x3C,0x72,0x38,0x1C,0x4E,0x3C,0x00
+ .byte 0x18,0x3C,0x18,0x18,0x18,0x18,0x0C,0x00
+ .byte 0x00,0x66,0x66,0x66,0x66,0x66,0x3E,0x00
+ .byte 0x00,0x66,0x66,0x66,0x66,0x64,0x78,0x00
+ .byte 0x00,0xC6,0xC6,0xD6,0xD6,0xD6,0xFC,0x00
+ .byte 0x00,0x66,0x66,0x3C,0x66,0x66,0x66,0x00
+ .byte 0x00,0x66,0x66,0x66,0x26,0x1E,0x46,0x3C
+ .byte 0x00,0x7E,0x0E,0x1C,0x38,0x70,0x7E,0x00
+ .byte 0x0E,0x18,0x18,0x30,0x18,0x18,0x0E,0x00
+ .byte 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18
+ .byte 0x70,0x18,0x18,0x0C,0x18,0x18,0x70,0x00
+ .byte 0x00,0x60,0xF2,0x9E,0x0C,0x00,0x00,0x00
+ .byte 0x10,0x10,0x28,0x28,0x44,0x44,0x82,0xFE
+
+; Character: ? (0E)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b11111111 ; oooooooo
+ .db 0b11111111 ; oooooooo
+ .db 0b11111111 ; oooooooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (0F)
+ .db 0b00011100 ; ooo
+ .db 0b00011100 ; ooo
+ .db 0b00011100 ; ooo
+ .db 0b00011100 ; ooo
+ .db 0b00011100 ; ooo
+ .db 0b00011100 ; ooo
+ .db 0b00011100 ; ooo
+ .db 0b00011100 ; ooo
+
+; Character: ? (1C)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00011111 ; ooooo
+ .db 0b00011111 ; ooooo
+ .db 0b00011111 ; ooooo
+ .db 0b00011100 ; ooo
+ .db 0b00011100 ; ooo
+
+; Character: ? (1D)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b11111100 ; oooooo
+ .db 0b11111100 ; oooooo
+ .db 0b11111100 ; oooooo
+ .db 0b00011100 ; ooo
+ .db 0b00011100 ; ooo
+
+; Character: ? (1E)
+ .db 0b00011100 ; ooo
+ .db 0b00011100 ; ooo
+ .db 0b00011100 ; ooo
+ .db 0b00011111 ; ooooo
+ .db 0b00011111 ; ooooo
+ .db 0b00011111 ; ooooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (1F)
+ .db 0b00011100 ; ooo
+ .db 0b00011100 ; ooo
+ .db 0b00011100 ; ooo
+ .db 0b11111100 ; oooooo
+ .db 0b11111100 ; oooooo
+ .db 0b11111100 ; oooooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/f_italic.s b/gbdk/gbdk-lib/libc/targets/sm83/f_italic.s
new file mode 100644
index 00000000..75e9a81e
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/f_italic.s
@@ -0,0 +1,956 @@
+; font: italic
+
+ .area _HOME
+_font_italic::
+ .db 1+4 ; 128 char encoding, compressed
+ .db 93 ; Number of tiles
+
+; Encoding table
+
+ .db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+ .db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+ .db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+ .db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+ .db 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07
+ .db 0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F
+ .db 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17
+ .db 0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F
+ .db 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27
+ .db 0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F
+ .db 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37
+ .db 0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x00
+ .db 0x00,0x3F,0x40,0x41,0x42,0x43,0x44,0x45
+ .db 0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D
+ .db 0x4E,0x4F,0x50,0x51,0x52,0x53,0x54,0x55
+ .db 0x56,0x57,0x58,0x59,0x5A,0x5B,0x5C,0x00
+; Tile data
+; Default character (space)
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+
+; Character: ! (21)
+ .db 0b00000000 ;
+ .db 0b00001000 ; o
+ .db 0b00001000 ; o
+ .db 0b00001000 ; o
+ .db 0b00010000 ; o
+ .db 0b00010000 ; o
+ .db 0b00000000 ;
+ .db 0b00100000 ; o
+
+; Character: " (22)
+ .db 0b00000000 ;
+ .db 0b00100100 ; o o
+ .db 0b00100100 ; o o
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: # (23)
+ .db 0b00000000 ;
+ .db 0b00100100 ; o o
+ .db 0b01111110 ; oooooo
+ .db 0b00100100 ; o o
+ .db 0b00100100 ; o o
+ .db 0b01111110 ; oooooo
+ .db 0b00100100 ; o o
+ .db 0b00000000 ;
+
+; Character: $ (24)
+ .db 0b00000000 ;
+ .db 0b00001000 ; o
+ .db 0b00111110 ; ooooo
+ .db 0b00101000 ; o o
+ .db 0b00111110 ; ooooo
+ .db 0b00001010 ; o o
+ .db 0b00111110 ; ooooo
+ .db 0b00001000 ; o
+
+; Character: % (25)
+ .db 0b00000000 ;
+ .db 0b01100010 ; oo o
+ .db 0b01100100 ; oo o
+ .db 0b00001000 ; o
+ .db 0b00010000 ; o
+ .db 0b00100110 ; o oo
+ .db 0b01000110 ; o oo
+ .db 0b00000000 ;
+
+; Character: & (26)
+ .db 0b00000000 ;
+ .db 0b00010000 ; o
+ .db 0b00101000 ; o o
+ .db 0b00010000 ; o
+ .db 0b00101010 ; o o o
+ .db 0b01000100 ; o o
+ .db 0b00111010 ; ooo o
+ .db 0b00000000 ;
+
+; Character: ' (27)
+ .db 0b00000000 ;
+ .db 0b00001000 ; o
+ .db 0b00010000 ; o
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ( (28)
+ .db 0b00000000 ;
+ .db 0b00000100 ; o
+ .db 0b00001000 ; o
+ .db 0b00001000 ; o
+ .db 0b00001000 ; o
+ .db 0b00001000 ; o
+ .db 0b00000100 ; o
+ .db 0b00000000 ;
+
+; Character: ) (29)
+ .db 0b00000000 ;
+ .db 0b00100000 ; o
+ .db 0b00010000 ; o
+ .db 0b00010000 ; o
+ .db 0b00010000 ; o
+ .db 0b00010000 ; o
+ .db 0b00100000 ; o
+ .db 0b00000000 ;
+
+; Character: * (2A)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00100100 ; o o
+ .db 0b00011000 ; oo
+ .db 0b01111110 ; oooooo
+ .db 0b00011000 ; oo
+ .db 0b00100100 ; o o
+ .db 0b00000000 ;
+
+; Character: + (2B)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00001000 ; o
+ .db 0b00001000 ; o
+ .db 0b00111110 ; ooooo
+ .db 0b00001000 ; o
+ .db 0b00001000 ; o
+ .db 0b00000000 ;
+
+; Character: , (2C)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00001000 ; o
+ .db 0b00001000 ; o
+ .db 0b00010000 ; o
+
+; Character: - (2D)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00111110 ; ooooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: . (2E)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+
+; Character: / (2F)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000010 ; o
+ .db 0b00000100 ; o
+ .db 0b00001000 ; o
+ .db 0b00010000 ; o
+ .db 0b00100000 ; o
+ .db 0b00000000 ;
+
+; Character: 0 (30)
+ .db 0b00000000 ;
+ .db 0b00011100 ; ooo
+ .db 0b00100110 ; o oo
+ .db 0b01001010 ; o o o
+ .db 0b01010100 ; o o o
+ .db 0b10100100 ; o o o
+ .db 0b11001000 ; oo o
+ .db 0b01110000 ; ooo
+
+; Character: 1 (31)
+ .db 0b00000000 ;
+ .db 0b00011000 ; oo
+ .db 0b00101000 ; o o
+ .db 0b00001000 ; o
+ .db 0b00010000 ; o
+ .db 0b00100000 ; o
+ .db 0b00100000 ; o
+ .db 0b11111000 ; ooooo
+
+; Character: 2 (32)
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01000010 ; o o
+ .db 0b00000100 ; o
+ .db 0b00011000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b10000000 ; o
+ .db 0b11111100 ; oooooo
+
+; Character: 3 (33)
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01000010 ; o o
+ .db 0b00000010 ; o
+ .db 0b00001100 ; oo
+ .db 0b00000010 ; o
+ .db 0b10000100 ; o o
+ .db 0b01111000 ; oooo
+
+; Character: 4 (34)
+ .db 0b00000000 ;
+ .db 0b00001100 ; oo
+ .db 0b00110100 ; oo o
+ .db 0b01000100 ; o o
+ .db 0b10001000 ; o o
+ .db 0b11111110 ; ooooooo
+ .db 0b00010000 ; o
+ .db 0b00010000 ; o
+
+; Character: 5 (35)
+ .db 0b00000000 ;
+ .db 0b00111110 ; ooooo
+ .db 0b00100000 ; o
+ .db 0b01000000 ; o
+ .db 0b01111000 ; oooo
+ .db 0b00000100 ; o
+ .db 0b10000100 ; o o
+ .db 0b01111000 ; oooo
+
+; Character: 6 (36)
+ .db 0b00000000 ;
+ .db 0b00011100 ; ooo
+ .db 0b00100010 ; o o
+ .db 0b01000000 ; o
+ .db 0b01111000 ; oooo
+ .db 0b10000100 ; o o
+ .db 0b10000100 ; o o
+ .db 0b01111000 ; oooo
+
+; Character: 7 (37)
+ .db 0b00000000 ;
+ .db 0b00111110 ; ooooo
+ .db 0b00000010 ; o
+ .db 0b00000100 ; o
+ .db 0b00001000 ; o
+ .db 0b00010000 ; o
+ .db 0b00100000 ; o
+ .db 0b00100000 ; o
+
+; Character: 8 (38)
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01000010 ; o o
+ .db 0b00111100 ; oooo
+ .db 0b01000010 ; o o
+ .db 0b10000100 ; o o
+ .db 0b10000100 ; o o
+ .db 0b01111000 ; oooo
+
+; Character: 9 (39)
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01000010 ; o o
+ .db 0b01000010 ; o o
+ .db 0b00111100 ; oooo
+ .db 0b00000100 ; o
+ .db 0b00001000 ; o
+ .db 0b11110000 ; oooo
+
+; Character: : (3A)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00001000 ; o
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00010000 ; o
+ .db 0b00000000 ;
+
+; Character: ; (3B)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00010000 ; o
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00010000 ; o
+ .db 0b00010000 ; o
+ .db 0b00100000 ; o
+
+; Character: < (3C)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000100 ; o
+ .db 0b00001000 ; o
+ .db 0b00010000 ; o
+ .db 0b00001000 ; o
+ .db 0b00000100 ; o
+ .db 0b00000000 ;
+
+; Character: = (3D)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00111110 ; ooooo
+ .db 0b00000000 ;
+ .db 0b01111100 ; ooooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: > (3E)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00010000 ; o
+ .db 0b00001000 ; o
+ .db 0b00000100 ; o
+ .db 0b00001000 ; o
+ .db 0b00010000 ; o
+ .db 0b00000000 ;
+
+; Character: ? (3F)
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01000010 ; o o
+ .db 0b00000010 ; o
+ .db 0b00001100 ; oo
+ .db 0b00010000 ; o
+ .db 0b00000000 ;
+ .db 0b00110000 ; oo
+
+; Character: @ (40)
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01001010 ; o o o
+ .db 0b01010110 ; o o oo
+ .db 0b01011110 ; o oooo
+ .db 0b01000000 ; o
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: A (41)
+ .db 0b00000000 ;
+ .db 0b00011100 ; ooo
+ .db 0b00100010 ; o o
+ .db 0b00100010 ; o o
+ .db 0b01111100 ; ooooo
+ .db 0b01000100 ; o o
+ .db 0b10001000 ; o o
+ .db 0b10001000 ; o o
+
+; Character: B (42)
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b00100010 ; o o
+ .db 0b00111100 ; oooo
+ .db 0b01000010 ; o o
+ .db 0b01000010 ; o o
+ .db 0b10000100 ; o o
+ .db 0b11111000 ; ooooo
+
+; Character: C (43)
+ .db 0b00000000 ;
+ .db 0b00011100 ; ooo
+ .db 0b00100010 ; o o
+ .db 0b01000000 ; o
+ .db 0b01000000 ; o
+ .db 0b10000000 ; o
+ .db 0b10000100 ; o o
+ .db 0b01111000 ; oooo
+
+; Character: D (44)
+ .db 0b00000000 ;
+ .db 0b00111000 ; ooo
+ .db 0b00100100 ; o o
+ .db 0b00100010 ; o o
+ .db 0b01000010 ; o o
+ .db 0b01000100 ; o o
+ .db 0b10001000 ; o o
+ .db 0b11110000 ; oooo
+
+; Character: E (45)
+ .db 0b00000000 ;
+ .db 0b00111110 ; ooooo
+ .db 0b00100000 ; o
+ .db 0b01000000 ; o
+ .db 0b01111000 ; oooo
+ .db 0b01000000 ; o
+ .db 0b10000000 ; o
+ .db 0b11111000 ; ooooo
+
+; Character: F (46)
+ .db 0b00000000 ;
+ .db 0b00111110 ; ooooo
+ .db 0b00100000 ; o
+ .db 0b01000000 ; o
+ .db 0b01111000 ; oooo
+ .db 0b01000000 ; o
+ .db 0b10000000 ; o
+ .db 0b10000000 ; o
+
+; Character: G (47)
+ .db 0b00000000 ;
+ .db 0b00011100 ; ooo
+ .db 0b00100010 ; o o
+ .db 0b01000000 ; o
+ .db 0b01000000 ; o
+ .db 0b10001110 ; o ooo
+ .db 0b10000100 ; o o
+ .db 0b01111000 ; oooo
+
+; Character: H (48)
+ .db 0b00000000 ;
+ .db 0b00100010 ; o o
+ .db 0b00100010 ; o o
+ .db 0b01000100 ; o o
+ .db 0b01111100 ; ooooo
+ .db 0b01000100 ; o o
+ .db 0b10001000 ; o o
+ .db 0b10001000 ; o o
+
+; Character: I (49)
+ .db 0b00000000 ;
+ .db 0b00111110 ; ooooo
+ .db 0b00001000 ; o
+ .db 0b00001000 ; o
+ .db 0b00010000 ; o
+ .db 0b00100000 ; o
+ .db 0b00100000 ; o
+ .db 0b11111000 ; ooooo
+
+; Character: J (4A)
+ .db 0b00000000 ;
+ .db 0b00000010 ; o
+ .db 0b00000010 ; o
+ .db 0b00000100 ; o
+ .db 0b00000100 ; o
+ .db 0b10001000 ; o o
+ .db 0b10001000 ; o o
+ .db 0b01110000 ; ooo
+
+; Character: K (4B)
+ .db 0b00000000 ;
+ .db 0b00100010 ; o o
+ .db 0b00100100 ; o o
+ .db 0b01001000 ; o o
+ .db 0b01110000 ; ooo
+ .db 0b01001000 ; o o
+ .db 0b10001000 ; o o
+ .db 0b10000100 ; o o
+
+; Character: L (4C)
+ .db 0b00000000 ;
+ .db 0b00100000 ; o
+ .db 0b00100000 ; o
+ .db 0b01000000 ; o
+ .db 0b01000000 ; o
+ .db 0b01000000 ; o
+ .db 0b10000000 ; o
+ .db 0b11111100 ; oooooo
+
+; Character: M (4D)
+ .db 0b00000000 ;
+ .db 0b00110110 ; oo oo
+ .db 0b00101010 ; o o o
+ .db 0b01010100 ; o o o
+ .db 0b01010100 ; o o o
+ .db 0b01000100 ; o o
+ .db 0b10001000 ; o o
+ .db 0b10001000 ; o o
+
+; Character: N (4E)
+ .db 0b00000000 ;
+ .db 0b00100010 ; o o
+ .db 0b00110010 ; oo o
+ .db 0b01010100 ; o o o
+ .db 0b01010100 ; o o o
+ .db 0b01010100 ; o o o
+ .db 0b10011000 ; o oo
+ .db 0b10001000 ; o o
+
+; Character: O (4F)
+ .db 0b00000000 ;
+ .db 0b00011100 ; ooo
+ .db 0b00100010 ; o o
+ .db 0b01000010 ; o o
+ .db 0b01000100 ; o o
+ .db 0b10000100 ; o o
+ .db 0b10001000 ; o o
+ .db 0b01110000 ; ooo
+
+; Character: P (50)
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b00100010 ; o o
+ .db 0b01000010 ; o o
+ .db 0b01111100 ; ooooo
+ .db 0b01000000 ; o
+ .db 0b10000000 ; o
+ .db 0b10000000 ; o
+
+; Character: Q (51)
+ .db 0b00000000 ;
+ .db 0b00011100 ; ooo
+ .db 0b00100010 ; o o
+ .db 0b01000010 ; o o
+ .db 0b01000100 ; o o
+ .db 0b10010100 ; o o o
+ .db 0b10001000 ; o o
+ .db 0b01110100 ; ooo o
+
+; Character: R (52)
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b00100010 ; o o
+ .db 0b01000010 ; o o
+ .db 0b01111100 ; ooooo
+ .db 0b01001000 ; o o
+ .db 0b10000100 ; o o
+ .db 0b10000100 ; o o
+
+; Character: S (53)
+ .db 0b00000000 ;
+ .db 0b00011110 ; oooo
+ .db 0b00100000 ; o
+ .db 0b00100000 ; o
+ .db 0b00011000 ; oo
+ .db 0b00000100 ; o
+ .db 0b10000100 ; o o
+ .db 0b01111000 ; oooo
+
+; Character: T (54)
+ .db 0b00000000 ;
+ .db 0b11111110 ; ooooooo
+ .db 0b00010000 ; o
+ .db 0b00100000 ; o
+ .db 0b00100000 ; o
+ .db 0b00100000 ; o
+ .db 0b01000000 ; o
+ .db 0b01000000 ; o
+
+; Character: U (55)
+ .db 0b00000000 ;
+ .db 0b00100010 ; o o
+ .db 0b00100010 ; o o
+ .db 0b01000100 ; o o
+ .db 0b01000100 ; o o
+ .db 0b10001000 ; o o
+ .db 0b10001000 ; o o
+ .db 0b01110000 ; ooo
+
+; Character: V (56)
+ .db 0b00000000 ;
+ .db 0b01000010 ; o o
+ .db 0b01000010 ; o o
+ .db 0b01000100 ; o o
+ .db 0b01000100 ; o o
+ .db 0b10001000 ; o o
+ .db 0b10010000 ; o o
+ .db 0b11100000 ; ooo
+
+; Character: W (57)
+ .db 0b00000000 ;
+ .db 0b00100010 ; o o
+ .db 0b00100010 ; o o
+ .db 0b01000100 ; o o
+ .db 0b01010100 ; o o o
+ .db 0b10101000 ; o o o
+ .db 0b10101000 ; o o o
+ .db 0b01010000 ; o o
+
+; Character: X (58)
+ .db 0b00000000 ;
+ .db 0b01000010 ; o o
+ .db 0b00100100 ; o o
+ .db 0b00101000 ; o o
+ .db 0b00010000 ; o
+ .db 0b00101000 ; o o
+ .db 0b01001000 ; o o
+ .db 0b10000100 ; o o
+
+; Character: Y (59)
+ .db 0b00000000 ;
+ .db 0b01000010 ; o o
+ .db 0b00100100 ; o o
+ .db 0b00101000 ; o o
+ .db 0b00010000 ; o
+ .db 0b00010000 ; o
+ .db 0b00100000 ; o
+ .db 0b00100000 ; o
+
+; Character: Z (5A)
+ .db 0b00000000 ;
+ .db 0b01111110 ; oooooo
+ .db 0b00000100 ; o
+ .db 0b00001000 ; o
+ .db 0b00010000 ; o
+ .db 0b00100000 ; o
+ .db 0b01000000 ; o
+ .db 0b11111100 ; oooooo
+
+; Character: [ (5B)
+ .db 0b00000000 ;
+ .db 0b00001110 ; ooo
+ .db 0b00001000 ; o
+ .db 0b00001000 ; o
+ .db 0b00001000 ; o
+ .db 0b00001000 ; o
+ .db 0b00001110 ; ooo
+ .db 0b00000000 ;
+
+; Character: \ (5C)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b01000000 ; o
+ .db 0b00100000 ; o
+ .db 0b00010000 ; o
+ .db 0b00001000 ; o
+ .db 0b00000100 ; o
+ .db 0b00000000 ;
+
+; Character: ] (5D)
+ .db 0b00000000 ;
+ .db 0b01110000 ; ooo
+ .db 0b00010000 ; o
+ .db 0b00010000 ; o
+ .db 0b00010000 ; o
+ .db 0b00010000 ; o
+ .db 0b01110000 ; ooo
+ .db 0b00000000 ;
+
+; Character: ^ (5E)
+ .db 0b00000000 ;
+ .db 0b00010000 ; o
+ .db 0b00111000 ; ooo
+ .db 0b01010100 ; o o o
+ .db 0b00010000 ; o
+ .db 0b00010000 ; o
+ .db 0b00010000 ; o
+ .db 0b00000000 ;
+
+; Character: a (61)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00011100 ; ooo
+ .db 0b00000010 ; o
+ .db 0b00111110 ; ooooo
+ .db 0b01000100 ; o o
+ .db 0b00111100 ; oooo
+
+; Character: b (62)
+ .db 0b00000000 ;
+ .db 0b00010000 ; o
+ .db 0b00010000 ; o
+ .db 0b00100000 ; o
+ .db 0b00111100 ; oooo
+ .db 0b00100010 ; o o
+ .db 0b01000100 ; o o
+ .db 0b01111000 ; oooo
+
+; Character: c (63)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00011110 ; oooo
+ .db 0b00100000 ; o
+ .db 0b01000000 ; o
+ .db 0b01000000 ; o
+ .db 0b00111100 ; oooo
+
+; Character: d (64)
+ .db 0b00000000 ;
+ .db 0b00000010 ; o
+ .db 0b00000010 ; o
+ .db 0b00000100 ; o
+ .db 0b00111100 ; oooo
+ .db 0b01000100 ; o o
+ .db 0b01001000 ; o o
+ .db 0b00111000 ; ooo
+
+; Character: e (65)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00011100 ; ooo
+ .db 0b00100010 ; o o
+ .db 0b01111100 ; ooooo
+ .db 0b01000000 ; o
+ .db 0b00111000 ; ooo
+
+; Character: f (66)
+ .db 0b00000000 ;
+ .db 0b00001110 ; ooo
+ .db 0b00010000 ; o
+ .db 0b00010000 ; o
+ .db 0b00111000 ; ooo
+ .db 0b00100000 ; o
+ .db 0b01000000 ; o
+ .db 0b01000000 ; o
+
+; Character: g (67)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00011110 ; oooo
+ .db 0b00100010 ; o o
+ .db 0b01000100 ; o o
+ .db 0b00111100 ; oooo
+ .db 0b00000100 ; o
+ .db 0b01111000 ; oooo
+
+; Character: h (68)
+ .db 0b00000000 ;
+ .db 0b00010000 ; o
+ .db 0b00010000 ; o
+ .db 0b00100000 ; o
+ .db 0b00111100 ; oooo
+ .db 0b00100010 ; o o
+ .db 0b01000100 ; o o
+ .db 0b01000100 ; o o
+
+; Character: i (69)
+ .db 0b00000000 ;
+ .db 0b00001000 ; o
+ .db 0b00000000 ;
+ .db 0b00011000 ; oo
+ .db 0b00001000 ; o
+ .db 0b00010000 ; o
+ .db 0b00100000 ; o
+ .db 0b01110000 ; ooo
+
+; Character: j (6A)
+ .db 0b00000000 ;
+ .db 0b00000100 ; o
+ .db 0b00000000 ;
+ .db 0b00000100 ; o
+ .db 0b00000100 ; o
+ .db 0b01001000 ; o o
+ .db 0b01001000 ; o o
+ .db 0b00110000 ; oo
+
+; Character: k (6B)
+ .db 0b00000000 ;
+ .db 0b00010000 ; o
+ .db 0b00010000 ; o
+ .db 0b00100000 ; o
+ .db 0b00100100 ; o o
+ .db 0b00111000 ; ooo
+ .db 0b01000100 ; o o
+ .db 0b01000100 ; o o
+
+; Character: l (6C)
+ .db 0b00000000 ;
+ .db 0b00001000 ; o
+ .db 0b00001000 ; o
+ .db 0b00010000 ; o
+ .db 0b00010000 ; o
+ .db 0b00100000 ; o
+ .db 0b00100000 ; o
+ .db 0b00011000 ; oo
+
+; Character: m (6D)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00110100 ; oo o
+ .db 0b00101010 ; o o o
+ .db 0b00101010 ; o o o
+ .db 0b01010100 ; o o o
+ .db 0b01010100 ; o o o
+
+; Character: n (6E)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b00100010 ; o o
+ .db 0b00100010 ; o o
+ .db 0b01000100 ; o o
+ .db 0b01000100 ; o o
+
+; Character: o (6F)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00011100 ; ooo
+ .db 0b00100010 ; o o
+ .db 0b00100010 ; o o
+ .db 0b01000100 ; o o
+ .db 0b01000100 ; o o
+ .db 0b00111000 ; ooo
+
+; Character: p (70)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00011100 ; ooo
+ .db 0b00010010 ; o o
+ .db 0b00100010 ; o o
+ .db 0b00111100 ; oooo
+ .db 0b01000000 ; o
+ .db 0b01000000 ; o
+
+; Character: q (71)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00011110 ; oooo
+ .db 0b00100010 ; o o
+ .db 0b00100100 ; o o
+ .db 0b00011100 ; ooo
+ .db 0b00001000 ; o
+ .db 0b00001100 ; oo
+
+; Character: r (72)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00001110 ; ooo
+ .db 0b00010000 ; o
+ .db 0b00010000 ; o
+ .db 0b00100000 ; o
+ .db 0b00100000 ; o
+
+; Character: s (73)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00011110 ; oooo
+ .db 0b00100000 ; o
+ .db 0b00011000 ; oo
+ .db 0b00000100 ; o
+ .db 0b01111000 ; oooo
+
+; Character: t (74)
+ .db 0b00000000 ;
+ .db 0b00001000 ; o
+ .db 0b00001000 ; o
+ .db 0b00011100 ; ooo
+ .db 0b00001000 ; o
+ .db 0b00010000 ; o
+ .db 0b00010000 ; o
+ .db 0b00100000 ; o
+
+; Character: u (75)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00100010 ; o o
+ .db 0b00100010 ; o o
+ .db 0b01000100 ; o o
+ .db 0b01000100 ; o o
+ .db 0b00111000 ; ooo
+
+; Character: v (76)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00100010 ; o o
+ .db 0b00100010 ; o o
+ .db 0b01000100 ; o o
+ .db 0b01001000 ; o o
+ .db 0b00110000 ; oo
+
+; Character: w (77)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00100010 ; o o
+ .db 0b00101010 ; o o o
+ .db 0b01010100 ; o o o
+ .db 0b01010100 ; o o o
+ .db 0b00101000 ; o o
+
+; Character: x (78)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00100100 ; o o
+ .db 0b00101000 ; o o
+ .db 0b00011000 ; oo
+ .db 0b00100100 ; o o
+ .db 0b01000100 ; o o
+
+; Character: y (79)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00100010 ; o o
+ .db 0b00100010 ; o o
+ .db 0b00011100 ; ooo
+ .db 0b00000100 ; o
+ .db 0b01111000 ; oooo
+
+; Character: z (7A)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00111110 ; ooooo
+ .db 0b00000100 ; o
+ .db 0b00011000 ; oo
+ .db 0b00100000 ; o
+ .db 0b01111100 ; ooooo
+
+; Character: { (7B)
+ .db 0b00000000 ;
+ .db 0b00001110 ; ooo
+ .db 0b00001000 ; o
+ .db 0b00110000 ; oo
+ .db 0b00001000 ; o
+ .db 0b00001000 ; o
+ .db 0b00001110 ; ooo
+ .db 0b00000000 ;
+
+; Character: | (7C)
+ .db 0b00000000 ;
+ .db 0b00001000 ; o
+ .db 0b00001000 ; o
+ .db 0b00001000 ; o
+ .db 0b00001000 ; o
+ .db 0b00001000 ; o
+ .db 0b00001000 ; o
+ .db 0b00000000 ;
+
+; Character: } (7D)
+ .db 0b00000000 ;
+ .db 0b01110000 ; ooo
+ .db 0b00010000 ; o
+ .db 0b00001100 ; oo
+ .db 0b00010000 ; o
+ .db 0b00010000 ; o
+ .db 0b01110000 ; ooo
+ .db 0b00000000 ;
+
+; Character: ~ (7E)
+ .db 0b00000000 ;
+ .db 0b00010100 ; o o
+ .db 0b00101000 ; o o
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/f_min.s b/gbdk/gbdk-lib/libc/targets/sm83/f_min.s
new file mode 100644
index 00000000..1505dc07
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/f_min.s
@@ -0,0 +1,356 @@
+; font_min.s
+
+; Text font
+; Michael Hope, 1998
+; michaelh@earthling.net
+; Distrubuted under the Artistic License - see www.opensource.org
+;
+
+ .module font_min
+ .area _HOME
+
+_font_min::
+ .byte 1+4 ; 128 character encoding
+ .byte 37 ; Tiles required
+
+ .byte 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ; All map to space
+ .byte 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ; All map to space
+ .byte 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ; All map to space
+ .byte 01,02,03,04,05,06,07,08,09,10,00,00,00,00,00,00
+ .byte 00,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25
+ .byte 26,27,28,29,30,31,32,33,34,35,36,00,00,00,00,00
+ .byte 00,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25
+ .byte 26,27,28,29,30,31,32,33,34,35,36,00,00,00,00,00
+
+ .db 0
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+; Character: 0
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000110
+ .db 0b01001010
+ .db 0b01010010
+ .db 0b01100010
+ .db 0b00111100
+ .db 0b00000000
+; Character: 1
+ .db 0b00000000
+ .db 0b00011000
+ .db 0b00101000
+ .db 0b00001000
+ .db 0b00001000
+ .db 0b00001000
+ .db 0b00111110
+ .db 0b00000000
+; Character: 2
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000010
+ .db 0b00000010
+ .db 0b00111100
+ .db 0b01000000
+ .db 0b01111110
+ .db 0b00000000
+; Character: 3
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000010
+ .db 0b00001100
+ .db 0b00000010
+ .db 0b01000010
+ .db 0b00111100
+ .db 0b00000000
+; Character: 4
+ .db 0b00000000
+ .db 0b00001000
+ .db 0b00011000
+ .db 0b00101000
+ .db 0b01001000
+ .db 0b01111110
+ .db 0b00001000
+ .db 0b00000000
+; Character: 5
+ .db 0b00000000
+ .db 0b01111110
+ .db 0b01000000
+ .db 0b01111100
+ .db 0b00000010
+ .db 0b01000010
+ .db 0b00111100
+ .db 0b00000000
+; Character: 6
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000000
+ .db 0b01111100
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b00111100
+ .db 0b00000000
+; Character: 7
+ .db 0b00000000
+ .db 0b01111110
+ .db 0b00000010
+ .db 0b00000100
+ .db 0b00001000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00000000
+; Character: 8
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000010
+ .db 0b00111100
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b00111100
+ .db 0b00000000
+; Character: 9
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b00111110
+ .db 0b00000010
+ .db 0b00111100
+ .db 0b00000000
+; Character: A
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01111110
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b00000000
+; Character: B
+ .db 0b00000000
+ .db 0b01111100
+ .db 0b01000010
+ .db 0b01111100
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01111100
+ .db 0b00000000
+; Character: C
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000010
+ .db 0b01000000
+ .db 0b01000000
+ .db 0b01000010
+ .db 0b00111100
+ .db 0b00000000
+; Character: D
+ .db 0b00000000
+ .db 0b01111000
+ .db 0b01000100
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01000100
+ .db 0b01111000
+ .db 0b00000000
+; Character: E
+ .db 0b00000000
+ .db 0b01111110
+ .db 0b01000000
+ .db 0b01111100
+ .db 0b01000000
+ .db 0b01000000
+ .db 0b01111110
+ .db 0b00000000
+; Character: F
+ .db 0b00000000
+ .db 0b01111110
+ .db 0b01000000
+ .db 0b01111100
+ .db 0b01000000
+ .db 0b01000000
+ .db 0b01000000
+ .db 0b00000000
+; Character: G
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000010
+ .db 0b01000000
+ .db 0b01001110
+ .db 0b01000010
+ .db 0b00111100
+ .db 0b00000000
+; Character: H
+ .db 0b00000000
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01111110
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b00000000
+; Character: I
+ .db 0b00000000
+ .db 0b00111110
+ .db 0b00001000
+ .db 0b00001000
+ .db 0b00001000
+ .db 0b00001000
+ .db 0b00111110
+ .db 0b00000000
+; Character: J
+ .db 0b00000000
+ .db 0b00000010
+ .db 0b00000010
+ .db 0b00000010
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b00111100
+ .db 0b00000000
+; Character: K
+ .db 0b00000000
+ .db 0b01000100
+ .db 0b01001000
+ .db 0b01110000
+ .db 0b01001000
+ .db 0b01000100
+ .db 0b01000010
+ .db 0b00000000
+; Character: L
+ .db 0b00000000
+ .db 0b01000000
+ .db 0b01000000
+ .db 0b01000000
+ .db 0b01000000
+ .db 0b01000000
+ .db 0b01111110
+ .db 0b00000000
+; Character: M
+ .db 0b00000000
+ .db 0b01000010
+ .db 0b01100110
+ .db 0b01011010
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b00000000
+; Character: N
+ .db 0b00000000
+ .db 0b01000010
+ .db 0b01100010
+ .db 0b01010010
+ .db 0b01001010
+ .db 0b01000110
+ .db 0b01000010
+ .db 0b00000000
+; Character: O
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b00111100
+ .db 0b00000000
+; Character: P
+ .db 0b00000000
+ .db 0b01111100
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01111100
+ .db 0b01000000
+ .db 0b01000000
+ .db 0b00000000
+; Character: Q
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01010010
+ .db 0b01001010
+ .db 0b00111100
+ .db 0b00000000
+; Character: R
+ .db 0b00000000
+ .db 0b01111100
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01111100
+ .db 0b01000100
+ .db 0b01000010
+ .db 0b00000000
+; Character: S
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000000
+ .db 0b00111100
+ .db 0b00000010
+ .db 0b01000010
+ .db 0b00111100
+ .db 0b00000000
+; Character: T
+ .db 0b00000000
+ .db 0b11111110
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00000000
+; Character: U
+ .db 0b00000000
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b00111100
+ .db 0b00000000
+; Character: V
+ .db 0b00000000
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b00100100
+ .db 0b00011000
+ .db 0b00000000
+; Character: W
+ .db 0b00000000
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01011010
+ .db 0b00100100
+ .db 0b00000000
+; Character: X
+ .db 0b00000000
+ .db 0b01000010
+ .db 0b00100100
+ .db 0b00011000
+ .db 0b00011000
+ .db 0b00100100
+ .db 0b01000010
+ .db 0b00000000
+; Character: Y
+ .db 0b00000000
+ .db 0b10000010
+ .db 0b01000100
+ .db 0b00101000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00000000
+; Character: Z
+ .db 0b00000000
+ .db 0b01111110
+ .db 0b00000100
+ .db 0b00001000
+ .db 0b00010000
+ .db 0b00100000
+ .db 0b01111110
+ .db 0b00000000
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/f_spect.s b/gbdk/gbdk-lib/libc/targets/sm83/f_spect.s
new file mode 100644
index 00000000..0da22f4d
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/f_spect.s
@@ -0,0 +1,886 @@
+; font_spect.ms
+; Text font
+; Michael Hope, 1998
+; michaelh@earthling.net
+; Distrubuted under the Artistic License - see www.opensource.org
+;
+
+ .module font_spect
+ .area _HOME
+
+_font_spect::
+ .byte 1+4 ; 128 character encoding
+ .byte 128-32 ; Tiles required
+
+ .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ; All map to space
+ .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+ .byte 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 ; 0x20
+ .byte 16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31
+ .byte 32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47 ; 0x40
+ .byte 48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63
+ .byte 64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79 ; 0x60
+ .byte 80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95
+
+ .db 0
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+; Character: !
+ .db 0b00000000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00000000
+ .db 0b00010000
+ .db 0b00000000
+; Character: "
+ .db 0b00000000
+ .db 0b00100100
+ .db 0b00100100
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+; Character: #
+ .db 0b00000000
+ .db 0b00100100
+ .db 0b01111110
+ .db 0b00100100
+ .db 0b00100100
+ .db 0b01111110
+ .db 0b00100100
+ .db 0b00000000
+; Character: $
+ .db 0b00000000
+ .db 0b00001000
+ .db 0b00111110
+ .db 0b00101000
+ .db 0b00111110
+ .db 0b00001010
+ .db 0b00111110
+ .db 0b00001000
+; Character: %
+ .db 0b00000000
+ .db 0b01100010
+ .db 0b01100100
+ .db 0b00001000
+ .db 0b00010000
+ .db 0b00100110
+ .db 0b01000110
+ .db 0b00000000
+; Character: &
+ .db 0b00000000
+ .db 0b00010000
+ .db 0b00101000
+ .db 0b00010000
+ .db 0b00101010
+ .db 0b01000100
+ .db 0b00111010
+ .db 0b00000000
+; Character: '
+ .db 0b00000000
+ .db 0b00001000
+ .db 0b00010000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+; Character: (
+ .db 0b00000000
+ .db 0b00000100
+ .db 0b00001000
+ .db 0b00001000
+ .db 0b00001000
+ .db 0b00001000
+ .db 0b00000100
+ .db 0b00000000
+; Character: )
+ .db 0b00000000
+ .db 0b00100000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00100000
+ .db 0b00000000
+; Character: *
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00010100
+ .db 0b00001000
+ .db 0b00111110
+ .db 0b00001000
+ .db 0b00010100
+ .db 0b00000000
+; Character: +
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00001000
+ .db 0b00001000
+ .db 0b00111110
+ .db 0b00001000
+ .db 0b00001000
+ .db 0b00000000
+; Character: ,
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00001000
+ .db 0b00001000
+ .db 0b00010000
+; Character: -
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00111110
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+; Character: .
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00011000
+ .db 0b00011000
+ .db 0b00000000
+; Character: /
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000010
+ .db 0b00000100
+ .db 0b00001000
+ .db 0b00010000
+ .db 0b00100000
+ .db 0b00000000
+; Character: 0
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000110
+ .db 0b01001010
+ .db 0b01010010
+ .db 0b01100010
+ .db 0b00111100
+ .db 0b00000000
+; Character: 1
+ .db 0b00000000
+ .db 0b00011000
+ .db 0b00101000
+ .db 0b00001000
+ .db 0b00001000
+ .db 0b00001000
+ .db 0b00111110
+ .db 0b00000000
+; Character: 2
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000010
+ .db 0b00000010
+ .db 0b00111100
+ .db 0b01000000
+ .db 0b01111110
+ .db 0b00000000
+; Character: 3
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000010
+ .db 0b00001100
+ .db 0b00000010
+ .db 0b01000010
+ .db 0b00111100
+ .db 0b00000000
+; Character: 4
+ .db 0b00000000
+ .db 0b00001000
+ .db 0b00011000
+ .db 0b00101000
+ .db 0b01001000
+ .db 0b01111110
+ .db 0b00001000
+ .db 0b00000000
+; Character: 5
+ .db 0b00000000
+ .db 0b01111110
+ .db 0b01000000
+ .db 0b01111100
+ .db 0b00000010
+ .db 0b01000010
+ .db 0b00111100
+ .db 0b00000000
+; Character: 6
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000000
+ .db 0b01111100
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b00111100
+ .db 0b00000000
+; Character: 7
+ .db 0b00000000
+ .db 0b01111110
+ .db 0b00000010
+ .db 0b00000100
+ .db 0b00001000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00000000
+; Character: 8
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000010
+ .db 0b00111100
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b00111100
+ .db 0b00000000
+; Character: 9
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b00111110
+ .db 0b00000010
+ .db 0b00111100
+ .db 0b00000000
+; Character: :
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00010000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00010000
+ .db 0b00000000
+; Character: ;
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00010000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00100000
+; Character: <
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000100
+ .db 0b00001000
+ .db 0b00010000
+ .db 0b00001000
+ .db 0b00000100
+ .db 0b00000000
+; Character: =
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00111110
+ .db 0b00000000
+ .db 0b00111110
+ .db 0b00000000
+ .db 0b00000000
+; Character: >
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00010000
+ .db 0b00001000
+ .db 0b00000100
+ .db 0b00001000
+ .db 0b00010000
+ .db 0b00000000
+; Character: ?
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000010
+ .db 0b00000100
+ .db 0b00001000
+ .db 0b00000000
+ .db 0b00001000
+ .db 0b00000000
+; Character: @
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01001010
+ .db 0b01010110
+ .db 0b01011110
+ .db 0b01000000
+ .db 0b00111100
+ .db 0b00000000
+; Character: A
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01111110
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b00000000
+; Character: B
+ .db 0b00000000
+ .db 0b01111100
+ .db 0b01000010
+ .db 0b01111100
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01111100
+ .db 0b00000000
+; Character: C
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000010
+ .db 0b01000000
+ .db 0b01000000
+ .db 0b01000010
+ .db 0b00111100
+ .db 0b00000000
+; Character: D
+ .db 0b00000000
+ .db 0b01111000
+ .db 0b01000100
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01000100
+ .db 0b01111000
+ .db 0b00000000
+; Character: E
+ .db 0b00000000
+ .db 0b01111110
+ .db 0b01000000
+ .db 0b01111100
+ .db 0b01000000
+ .db 0b01000000
+ .db 0b01111110
+ .db 0b00000000
+; Character: F
+ .db 0b00000000
+ .db 0b01111110
+ .db 0b01000000
+ .db 0b01111100
+ .db 0b01000000
+ .db 0b01000000
+ .db 0b01000000
+ .db 0b00000000
+; Character: G
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000010
+ .db 0b01000000
+ .db 0b01001110
+ .db 0b01000010
+ .db 0b00111100
+ .db 0b00000000
+; Character: H
+ .db 0b00000000
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01111110
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b00000000
+; Character: I
+ .db 0b00000000
+ .db 0b00111110
+ .db 0b00001000
+ .db 0b00001000
+ .db 0b00001000
+ .db 0b00001000
+ .db 0b00111110
+ .db 0b00000000
+; Character: J
+ .db 0b00000000
+ .db 0b00000010
+ .db 0b00000010
+ .db 0b00000010
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b00111100
+ .db 0b00000000
+; Character: K
+ .db 0b00000000
+ .db 0b01000100
+ .db 0b01001000
+ .db 0b01110000
+ .db 0b01001000
+ .db 0b01000100
+ .db 0b01000010
+ .db 0b00000000
+; Character: L
+ .db 0b00000000
+ .db 0b01000000
+ .db 0b01000000
+ .db 0b01000000
+ .db 0b01000000
+ .db 0b01000000
+ .db 0b01111110
+ .db 0b00000000
+; Character: M
+ .db 0b00000000
+ .db 0b01000010
+ .db 0b01100110
+ .db 0b01011010
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b00000000
+; Character: N
+ .db 0b00000000
+ .db 0b01000010
+ .db 0b01100010
+ .db 0b01010010
+ .db 0b01001010
+ .db 0b01000110
+ .db 0b01000010
+ .db 0b00000000
+; Character: O
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b00111100
+ .db 0b00000000
+; Character: P
+ .db 0b00000000
+ .db 0b01111100
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01111100
+ .db 0b01000000
+ .db 0b01000000
+ .db 0b00000000
+; Character: Q
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01010010
+ .db 0b01001010
+ .db 0b00111100
+ .db 0b00000000
+; Character: R
+ .db 0b00000000
+ .db 0b01111100
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01111100
+ .db 0b01000100
+ .db 0b01000010
+ .db 0b00000000
+; Character: S
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000000
+ .db 0b00111100
+ .db 0b00000010
+ .db 0b01000010
+ .db 0b00111100
+ .db 0b00000000
+; Character: T
+ .db 0b00000000
+ .db 0b11111110
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00000000
+; Character: U
+ .db 0b00000000
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b00111100
+ .db 0b00000000
+; Character: V
+ .db 0b00000000
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b00100100
+ .db 0b00011000
+ .db 0b00000000
+; Character: W
+ .db 0b00000000
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01011010
+ .db 0b00100100
+ .db 0b00000000
+; Character: X
+ .db 0b00000000
+ .db 0b01000010
+ .db 0b00100100
+ .db 0b00011000
+ .db 0b00011000
+ .db 0b00100100
+ .db 0b01000010
+ .db 0b00000000
+; Character: Y
+ .db 0b00000000
+ .db 0b10000010
+ .db 0b01000100
+ .db 0b00101000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00000000
+; Character: Z
+ .db 0b00000000
+ .db 0b01111110
+ .db 0b00000100
+ .db 0b00001000
+ .db 0b00010000
+ .db 0b00100000
+ .db 0b01111110
+ .db 0b00000000
+; Character: [
+ .db 0b00000000
+ .db 0b00001110
+ .db 0b00001000
+ .db 0b00001000
+ .db 0b00001000
+ .db 0b00001000
+ .db 0b00001110
+ .db 0b00000000
+; Character: \
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b01000000
+ .db 0b00100000
+ .db 0b00010000
+ .db 0b00001000
+ .db 0b00000100
+ .db 0b00000000
+; Character: ]
+ .db 0b00000000
+ .db 0b01110000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b01110000
+ .db 0b00000000
+; Character: ^
+ .db 0b00000000
+ .db 0b00010000
+ .db 0b00111000
+ .db 0b01010100
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00000000
+; Character: _
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b11111111
+; Character: Pound
+ .db 0b00000000
+ .db 0b00011100
+ .db 0b00100010
+ .db 0b01111000
+ .db 0b00100000
+ .db 0b00100000
+ .db 0b01111110
+ .db 0b00000000
+; Character: a
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00111000
+ .db 0b00000100
+ .db 0b00111100
+ .db 0b01000100
+ .db 0b00111100
+ .db 0b00000000
+; Character: b
+ .db 0b00000000
+ .db 0b00100000
+ .db 0b00100000
+ .db 0b00111100
+ .db 0b00100010
+ .db 0b00100010
+ .db 0b00111100
+ .db 0b00000000
+; Character: c
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00011100
+ .db 0b00100000
+ .db 0b00100000
+ .db 0b00100000
+ .db 0b00011100
+ .db 0b00000000
+; Character: d
+ .db 0b00000000
+ .db 0b00000100
+ .db 0b00000100
+ .db 0b00111100
+ .db 0b01000100
+ .db 0b01000100
+ .db 0b00111100
+ .db 0b00000000
+; Character: e
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00111000
+ .db 0b01000100
+ .db 0b01111000
+ .db 0b01000000
+ .db 0b00111100
+ .db 0b00000000
+; Character: f
+ .db 0b00000000
+ .db 0b00001100
+ .db 0b00010000
+ .db 0b00011000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00000000
+; Character: g
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000100
+ .db 0b01000100
+ .db 0b00111100
+ .db 0b00000100
+ .db 0b00111000
+; Character: h
+ .db 0b00000000
+ .db 0b01000000
+ .db 0b01000000
+ .db 0b01111000
+ .db 0b01000100
+ .db 0b01000100
+ .db 0b01000100
+ .db 0b00000000
+; Character: i
+ .db 0b00000000
+ .db 0b00010000
+ .db 0b00000000
+ .db 0b00110000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00111000
+ .db 0b00000000
+; Character: j
+ .db 0b00000000
+ .db 0b00000100
+ .db 0b00000000
+ .db 0b00000100
+ .db 0b00000100
+ .db 0b00000100
+ .db 0b00100100
+ .db 0b00011000
+; Character: k
+ .db 0b00000000
+ .db 0b00100000
+ .db 0b00101000
+ .db 0b00110000
+ .db 0b00110000
+ .db 0b00101000
+ .db 0b00100100
+ .db 0b00000000
+; Character: l
+ .db 0b00000000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00001100
+ .db 0b00000000
+; Character: m
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b01101000
+ .db 0b01010100
+ .db 0b01010100
+ .db 0b01010100
+ .db 0b01010100
+ .db 0b00000000
+; Character: n
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b01111000
+ .db 0b01000100
+ .db 0b01000100
+ .db 0b01000100
+ .db 0b01000100
+ .db 0b00000000
+; Character: o
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00111000
+ .db 0b01000100
+ .db 0b01000100
+ .db 0b01000100
+ .db 0b00111000
+ .db 0b00000000
+; Character: p
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b01111000
+ .db 0b01000100
+ .db 0b01000100
+ .db 0b01111000
+ .db 0b01000000
+ .db 0b01000000
+; Character: q
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000100
+ .db 0b01000100
+ .db 0b00111100
+ .db 0b00000100
+ .db 0b00000110
+; Character: r
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00011100
+ .db 0b00100000
+ .db 0b00100000
+ .db 0b00100000
+ .db 0b00100000
+ .db 0b00000000
+; Character: s
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00111000
+ .db 0b01000000
+ .db 0b00111000
+ .db 0b00000100
+ .db 0b01111000
+ .db 0b00000000
+; Character: t
+ .db 0b00000000
+ .db 0b00010000
+ .db 0b00111000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00001100
+ .db 0b00000000
+; Character: u
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b01000100
+ .db 0b01000100
+ .db 0b01000100
+ .db 0b01000100
+ .db 0b00111000
+ .db 0b00000000
+; Character: v
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b01000100
+ .db 0b01000100
+ .db 0b00101000
+ .db 0b00101000
+ .db 0b00010000
+ .db 0b00000000
+; Character: w
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b01000100
+ .db 0b01010100
+ .db 0b01010100
+ .db 0b01010100
+ .db 0b00101000
+ .db 0b00000000
+; Character: x
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b01000100
+ .db 0b00101000
+ .db 0b00010000
+ .db 0b00101000
+ .db 0b01000100
+ .db 0b00000000
+; Character: y
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b01000100
+ .db 0b01000100
+ .db 0b01000100
+ .db 0b00111100
+ .db 0b00000100
+ .db 0b00111000
+; Character: z
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b01111100
+ .db 0b00001000
+ .db 0b00010000
+ .db 0b00100000
+ .db 0b01111100
+ .db 0b00000000
+; Character: {
+ .db 0b00000000
+ .db 0b00001110
+ .db 0b00001000
+ .db 0b00110000
+ .db 0b00001000
+ .db 0b00001000
+ .db 0b00001110
+ .db 0b00000000
+; Character: |
+ .db 0b00000000
+ .db 0b00001000
+ .db 0b00001000
+ .db 0b00001000
+ .db 0b00001000
+ .db 0b00001000
+ .db 0b00001000
+ .db 0b00000000
+; Character: }
+ .db 0b00000000
+ .db 0b01110000
+ .db 0b00010000
+ .db 0b00001100
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b01110000
+ .db 0b00000000
+; Character: ~
+ .db 0b00000000
+ .db 0b00010100
+ .db 0b00101000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+; Character: Copyright
+ .db 0b00111100
+ .db 0b01000010
+ .db 0b10011001
+ .db 0b10100001
+ .db 0b10100001
+ .db 0b10011001
+ .db 0b01000010
+ .db 0b00111100
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/far_ptr.s b/gbdk/gbdk-lib/libc/targets/sm83/far_ptr.s
new file mode 100644
index 00000000..1c3a1e57
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/far_ptr.s
@@ -0,0 +1,71 @@
+;--------------------------------------------------------------------------
+; far_ptr.s
+;
+; Copyright (C) 2020, Tony Pavlov
+;
+; This library is free software; you can redistribute it and/or modify it
+; under the terms of the GNU General Public License as published by the
+; Free Software Foundation; either version 2, or (at your option) any
+; later version.
+;
+; This library is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this library; see the file COPYING. If not, write to the
+; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+; MA 02110-1301, USA.
+;
+; As a special exception, if you link this library with other files,
+; some of which are compiled with SDCC, to produce an executable,
+; this library does not by itself cause the resulting executable to
+; be covered by the GNU General Public License. This exception does
+; not however invalidate any other reasons why the executable file
+; might be covered by the GNU General Public License.
+;--------------------------------------------------------------------------
+
+ .module far_ptr
+
+ .include "global.s"
+
+ .area _HOME
+
+___call__banked::
+ ldh A, (#__current_bank)
+ push AF
+ ld HL, #1$
+ push HL
+ ld HL, #___call_banked_addr
+ ld A, (HL+)
+ ld H, (HL)
+ ld L, A
+ ld A, (#___call_banked_bank)
+ ldh (#__current_bank), A
+ ld (.MBC_ROM_PAGE),A
+ jp (HL)
+1$:
+ pop AF
+ ldh (#__current_bank), A
+ ld (.MBC1_ROM_PAGE), A
+ ret
+
+_to_far_ptr::
+ lda HL, 2(SP)
+ ld A, (HL+)
+ ld E, A
+ ld A, (HL+)
+ ld D, A
+ ld A, (HL+)
+ ld H, (HL)
+ ld L, A
+ ret
+
+ .area _DATA
+
+___call_banked_ptr::
+___call_banked_addr::
+ .ds 0x02 ; far pointer offset
+___call_banked_bank::
+ .ds 0x02 ; far pointer segment
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/fill_rect.s b/gbdk/gbdk-lib/libc/targets/sm83/fill_rect.s
new file mode 100644
index 00000000..ce1740f9
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/fill_rect.s
@@ -0,0 +1,85 @@
+ .include "global.s"
+
+ .area _HOME
+
+.fill_rect_wtt::
+ PUSH HL
+ LDH A,(.LCDC)
+ AND #LCDCF_WIN9C00
+ JR Z,.is98
+ JR .is9c
+ ;; Initialize background tile table with B
+.fill_rect_btt::
+ PUSH HL
+ LDH A,(.LCDC)
+ AND #LCDCF_BG9C00
+ JR NZ,.is9c
+.is98:
+ LD HL,#0x9800 ; HL = origin
+ JR .fill_rect
+.is9c:
+ LD HL,#0x9C00 ; HL = origin
+
+ ;; fills rectangle area with tile B at XY = DE, size WH on stack, to vram from address (HL)
+.fill_rect:
+ PUSH BC ; Store source
+
+ SWAP E
+ RLC E
+ LD A,E
+ AND #0x03
+ ADD H
+ LD B,A
+ LD A,#0xE0
+ AND E
+ ADD D
+ LD C,A ; dest BC = HL + 0x20 * Y + X
+
+ POP HL ; H = Tile
+ POP DE ; DE = WH
+ PUSH DE ; store WH
+ PUSH BC ; store dest
+
+3$: ; Copy W tiles
+
+ WAIT_STAT
+ LD A, H
+ LD (BC), A
+
+ LD A, C ; inc dest and wrap around
+ AND #0xE0
+ LD E, A
+ LD A, C
+ INC A
+ AND #0x1F
+ OR E
+ LD C, A
+
+ DEC D
+ JR NZ, 3$
+
+ POP BC
+ POP DE
+
+ DEC E
+ RET Z
+
+ PUSH DE
+
+ LD A, B ; next row and wrap around
+ AND #0xFC
+ LD E, A ; save high bits
+
+ LD A,#0x20
+
+ ADD C
+ LD C, A
+ ADC B
+ SUB C
+ AND #0x03
+ OR E ; restore high bits
+ LD B, A
+
+ PUSH BC
+
+ JR 3$
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/fill_rect_bk.s b/gbdk/gbdk-lib/libc/targets/sm83/fill_rect_bk.s
new file mode 100644
index 00000000..2d4a051e
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/fill_rect_bk.s
@@ -0,0 +1,22 @@
+ .include "global.s"
+
+ .area _HOME
+
+_fill_bkg_rect::
+ PUSH BC
+
+ LDA HL,4(SP) ; Skip return address and registers
+ LD A,(HL+) ; D = x
+ LD D, A
+ LD E,(HL) ; E = y
+ LDA HL,8(SP)
+ LD A,(HL-) ; B = tile
+ LD B, A
+ LD A,(HL-) ; A = h
+ LD H,(HL) ; H = w
+ LD L,A ; L = h
+
+ CALL .fill_rect_btt
+
+ POP BC
+ RET
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/fill_rect_wi.s b/gbdk/gbdk-lib/libc/targets/sm83/fill_rect_wi.s
new file mode 100644
index 00000000..b0bd8312
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/fill_rect_wi.s
@@ -0,0 +1,22 @@
+ .include "global.s"
+
+ .area _HOME
+
+_fill_win_rect::
+ PUSH BC
+
+ LDA HL,4(SP) ; Skip return address and registers
+ LD A,(HL+) ; D = x
+ LD D, A
+ LD E,(HL) ; E = y
+ LDA HL,8(SP)
+ LD A,(HL-) ; B = tile
+ LD B, A
+ LD A,(HL-) ; A = h
+ LD H,(HL) ; H = w
+ LD L,A ; L = h
+
+ CALL .fill_rect_wtt
+
+ POP BC
+ RET
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/font.s b/gbdk/gbdk-lib/libc/targets/sm83/font.s
new file mode 100644
index 00000000..e973a24a
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/font.s
@@ -0,0 +1,558 @@
+; font.ms
+;
+; Michael Hope, 1999
+; michaelh@earthling.net
+; Distrubuted under the Artistic License - see www.opensource.org
+;
+ .include "global.s"
+
+ .globl .cr_curs
+ .globl .adv_curs
+ .globl .cury, .curx
+ .globl .display_off
+
+ ; Structure offsets
+ sfont_handle_sizeof = 3
+ sfont_handle_font = 1
+ sfont_handle_first_tile = 0
+
+ ; Encoding types - lower 2 bits of font
+ FONT_256ENCODING = 0
+ FONT_128ENCODING = 1
+ FONT_NOENCODING = 2
+
+ ; Other bits
+ FONT_BCOMPRESSED = 2
+
+ .CR = 0x0A ; Unix
+ .SPACE = 0x00
+
+ ; Maximum number of fonts
+ .MAX_FONTS = 6
+
+ .area _FONT_HEADER (ABS)
+
+ .org .MODE_TABLE+4*.T_MODE
+ JP .tmode
+
+ .module font.ms
+
+ .globl .fg_colour, .bg_colour
+
+ .globl .drawing_vbl, .drawing_lcd
+ .globl .int_0x40, .int_0x48
+ .globl .remove_int
+ .globl _set_bkg_1bpp_data, _set_bkg_data
+
+ .area _INITIALIZED
+.curx:: ; Cursor position
+ .ds 0x01
+.cury::
+ .ds 0x01
+
+ .area _INITIALIZER
+ .db 0x00 ; .curx
+ .db 0x00 ; .cury
+
+ .area _DATA
+ ; The current font
+
+font_current::
+ .ds sfont_handle_sizeof
+ ; Cached copy of the first free tile
+font_first_free_tile::
+ .ds 1
+ ; Table containing descriptors for all of the fonts
+font_table::
+ .ds sfont_handle_sizeof*.MAX_FONTS
+
+ .area _HOME
+
+_font_load_ibm::
+ ld hl,#_font_ibm
+ call font_load
+ ret
+
+; Load the font HL
+font_load::
+ call .display_off
+ push hl
+
+ ; Find the first free font entry
+ ld hl,#font_table+sfont_handle_font
+ ld b,#.MAX_FONTS
+font_load_find_slot:
+ ld a,(hl) ; Check to see if this entry is free
+ inc hl ; Free is 0000 for the font pointer
+ or (hl)
+ cp #0
+ jr z,font_load_found
+
+ inc hl
+ inc hl
+ dec b
+ jr nz,font_load_find_slot
+ pop hl
+ ld hl,#0
+ jr font_load_exit ; Couldn't find a free space
+font_load_found:
+ ; HL points to the end of the free font table entry
+ pop de
+ ld (hl),d ; Copy across the font struct pointer
+ dec hl
+ ld (hl),e
+
+ ld a,(font_first_free_tile)
+ dec hl
+ ld (hl),a
+
+ push hl
+ call font_set ; Set this new font to be the default
+
+ ; Only copy the tiles in if were in text mode
+ ld a,(.mode)
+ and #.T_MODE
+
+ call nz,font_copy_current
+
+ ; Increase the 'first free tile' counter
+ ld hl,#font_current+sfont_handle_font
+ ld a,(hl+)
+ ld h,(hl)
+ ld l,a
+
+ inc hl ; Number of tiles used
+ ld a,(font_first_free_tile)
+ add a,(hl)
+ ld (font_first_free_tile),a
+
+ pop hl ; Return font setup in HL
+font_load_exit:
+ ;; Turn the screen on
+ LDH A,(.LCDC)
+ OR #(LCDCF_ON | LCDCF_BGON)
+ AND #~(LCDCF_BG9C00 | LCDCF_BG8000)
+ LDH (.LCDC),A
+
+ RET
+
+ ; Copy the tiles from the current font into VRAM
+font_copy_current::
+ ; Find the current font data
+ ld hl,#font_current+sfont_handle_font
+ ld a,(hl+)
+ ld h,(hl)
+ ld l,a
+
+ ld a, (hl+)
+ ld e, a
+ ld a, (hl+)
+ ld d, a
+
+ ld a, e
+ ld c, #128
+ and #3
+ cp #FONT_128ENCODING
+ jr z, 1$
+ cp #FONT_NOENCODING
+ jr z, 2$
+ inc h
+ jr 2$
+1$:
+ ld a, c
+ add l
+ ld l, a
+ adc h
+ sub l
+ ld h, a
+2$:
+ push hl
+ ld c, e
+ ld a, (font_current+sfont_handle_first_tile)
+ ld e, a
+ push de
+ bit FONT_BCOMPRESSED, c
+ jr nz, 3$
+ call _set_bkg_data
+ jr 4$
+3$:
+ call _set_bkg_1bpp_data
+4$:
+ add sp, #4
+ ret
+
+ ; Set the current font to HL
+font_set::
+ ld a,(hl+)
+ ld (font_current),a
+ ld a,(hl+)
+ ld (font_current+1),a
+ ld a,(hl+)
+ ld (font_current+2),a
+ ret
+
+ ;; Print a character with interpretation
+.put_char::
+ ; See if it's a special char
+ cp #.CR
+ jr nz,1$
+
+ ; Now see if were checking special chars
+ push af
+ ld a,(.mode)
+ and #.M_NO_INTERP
+ jr nz,2$
+ call .cr_curs
+ pop af
+ ret
+2$:
+ pop af
+1$:
+ call .set_char
+ jp .adv_curs
+
+ ;; Print a character without interpretation
+.out_char::
+ call .set_char
+ jp .adv_curs
+
+ ;; Delete a character
+.del_char::
+ call .rew_curs
+ ld a,#.SPACE
+ jp .set_char
+
+ ;; Print the character in A
+.set_char:
+ push af
+ ld a,(font_current+2)
+ ; Must be non-zero if the font system is setup (cant have a font in page zero)
+ or a
+ jr nz,3$
+
+ ; Font system is not yet setup - init it and copy in the ibm font
+ ; Kind of a compatibility mode
+ call _font_init
+
+ ; Need all of the tiles
+ xor a
+ ld (font_first_free_tile),a
+
+ call _font_load_ibm
+3$:
+ pop af
+ push bc
+ push de
+ push hl
+ ; Compute which tile maps to this character
+ ld e,a
+ ld hl,#font_current+sfont_handle_font
+ ld a,(hl+)
+ ld h,(hl)
+ ld l,a
+ ld a,(hl+)
+ and #3
+ cp #FONT_NOENCODING
+ jr z,set_char_no_encoding
+ inc hl
+ ; Now at the base of the encoding table
+ ; E is set above
+ ld d,#0
+ add hl,de
+ ld e,(hl) ; That's the tile!
+set_char_no_encoding:
+ ld a,(font_current+0)
+ add a,e
+ ld e,a
+
+ LD A,(.cury) ; Y coordinate
+ LD L,A
+ LD H,#0x00
+ ADD HL,HL
+ ADD HL,HL
+ ADD HL,HL
+ ADD HL,HL
+ ADD HL,HL
+ LD A,(.curx) ; X coordinate
+ LD C,A
+ LD B,#0x00
+ ADD HL,BC
+ LD BC,#0x9800
+ ADD HL,BC
+
+ WAIT_STAT
+
+ LD (HL),E
+ POP HL
+ POP DE
+ POP BC
+ RET
+
+_putchar::
+ PUSH BC
+ LDA HL,4(SP) ; Skip return address
+ LD A,(HL) ; A = c
+ CALL .put_char
+ POP BC
+ RET
+
+_setchar::
+ PUSH BC
+ LDA HL,4(SP) ; Skip return address
+ LD A,(HL) ; A = c
+ CALL .set_char
+ POP BC
+ RET
+
+_font_load::
+ push bc
+ LDA HL,4(SP) ; Skip return address and bc
+ LD A,(HL) ; A = c
+ inc hl
+ ld h,(hl)
+ ld l,a
+ call font_load
+ push hl
+ pop de ; Return in DE
+ pop bc
+ ret
+
+_font_set::
+ push bc
+ LDA HL,4(SP) ; Skip return address
+ LD A,(HL) ; A = c
+ inc hl
+ ld h,(hl)
+ ld l,a
+ call font_set
+ pop bc
+ ld de,#0 ; Always good...
+ ret
+
+_font_init::
+ push bc
+ .globl .tmode
+
+ call .tmode
+
+ xor a
+ ld (font_first_free_tile),a
+
+ ; Clear the font table
+ ld hl,#font_table
+ ld b,#sfont_handle_sizeof*.MAX_FONTS
+1$:
+ ld (hl+),a
+ dec b
+ jr nz,1$
+ ld a,#3
+ ld (.fg_colour),a
+ xor a
+ ld (.bg_colour),a
+
+ call .cls_no_reset_pos
+ pop bc
+ ret
+
+_cls::
+.cls::
+ XOR A
+ LD (.curx), A
+ LD (.cury), A
+.cls_no_reset_pos:
+ PUSH DE
+ PUSH HL
+ LD HL,#0x9800
+ LD E,#0x20 ; E = height
+1$:
+ LD D,#0x20 ; D = width
+2$:
+ WAIT_STAT
+
+ LD (HL),#.SPACE ; Always clear
+ INC HL
+ DEC D
+ JR NZ,2$
+ DEC E
+ JR NZ,1$
+ POP HL
+ POP DE
+ RET
+
+ ; Support routines
+_gotoxy::
+ lda hl,2(sp)
+ ld a,(hl+)
+ ld (.curx),a
+ ld a,(hl)
+ ld (.cury),a
+ ret
+
+_posx::
+ LD A,(.mode)
+ AND #.T_MODE
+ JR NZ,1$
+ PUSH BC
+ CALL .tmode
+ POP BC
+1$:
+ LD A,(.curx)
+ LD E,A
+ RET
+
+_posy::
+ LD A,(.mode)
+ AND #.T_MODE
+ JR NZ,1$
+ PUSH BC
+ CALL .tmode
+ POP BC
+1$:
+ LD A,(.cury)
+ LD E,A
+ RET
+
+ ;; Rewind the cursor
+.rew_curs:
+ PUSH HL
+ LD HL,#.curx ; X coordinate
+ XOR A
+ CP (HL)
+ JR Z,1$
+ DEC (HL)
+ JR 99$
+1$:
+ LD (HL),#.MAXCURSPOSX
+ LD HL,#.cury ; Y coordinate
+ XOR A
+ CP (HL)
+ JR Z,99$
+ DEC (HL)
+99$:
+ POP HL
+ RET
+
+.cr_curs::
+ PUSH HL
+ XOR A
+ LD (.curx),A
+ LD HL,#.cury ; Y coordinate
+ LD A,#.MAXCURSPOSY
+ CP (HL)
+ JR Z,2$
+ INC (HL)
+ JR 99$
+2$:
+ CALL .scroll
+99$:
+ POP HL
+ RET
+
+.adv_curs::
+ PUSH HL
+ LD HL,#.curx ; X coordinate
+ LD A,#.MAXCURSPOSX
+ CP (HL)
+ JR Z,1$
+ INC (HL)
+ JR 99$
+1$:
+ LD (HL),#0x00
+ LD HL,#.cury ; Y coordinate
+ LD A,#.MAXCURSPOSY
+ CP (HL)
+ JR Z,2$
+ INC (HL)
+ JR 99$
+2$:
+ ;; See if scrolling is disabled
+ LD A,(.mode)
+ AND #.M_NO_SCROLL
+ JR Z,3$
+ ;; Nope - reset the cursor to (0,0)
+ XOR A
+ LD (.cury),A
+ LD (.curx),A
+ JR 99$
+3$:
+ CALL .scroll
+99$:
+ POP HL
+ RET
+
+ ;; Scroll the whole screen
+.scroll:
+ PUSH BC
+ PUSH DE
+ PUSH HL
+ LD HL,#0x9800
+ LD BC,#0x9800+0x20 ; BC = next line
+ LD E,#0x20-0x01 ; E = height - 1
+1$:
+ LD D,#0x20 ; D = width
+2$:
+ WAIT_STAT
+ LD A,(BC)
+ LD (HL+),A
+ INC BC
+
+ DEC D
+ JR NZ,2$
+ DEC E
+ JR NZ,1$
+
+ LD D,#0x20
+3$:
+ WAIT_STAT
+ LD A,#.SPACE
+ LD (HL+),A
+ DEC D
+ JR NZ,3$
+
+ POP HL
+ POP DE
+ POP BC
+ RET
+
+ ;; Enter text mode
+.tmode::
+ DI ; Disable interrupts
+
+ ;; Turn the screen off
+ LDH A,(.LCDC)
+ AND #LCDCF_ON
+ JR Z,1$
+
+ ;; Turn the screen off
+ CALL .display_off
+
+ ;; Remove any interrupts setup by the drawing routine
+ LD BC,#.drawing_vbl
+ LD HL,#.int_0x40
+ CALL .remove_int
+ LD BC,#.drawing_lcd
+ LD HL,#.int_0x48
+ CALL .remove_int
+1$:
+
+ CALL .tmode_out
+
+ ;; Turn the screen on
+ LDH A,(.LCDC)
+ OR #(LCDCF_ON | LCDCF_BGON)
+ AND #~(LCDCF_BG9C00 | LCDCF_BG8000)
+ LDH (.LCDC),A
+
+ EI ; Enable interrupts
+
+ RET
+
+ ;; Text mode (out only)
+.tmode_out::
+ ;; Clear screen
+ CALL .cls_no_reset_pos
+
+ LD A,#.T_MODE
+ LD (.mode),A
+
+ RET
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/font_color.s b/gbdk/gbdk-lib/libc/targets/sm83/font_color.s
new file mode 100644
index 00000000..df14149e
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/font_color.s
@@ -0,0 +1,12 @@
+ .include "global.s"
+
+ .globl .fg_colour, .bg_colour
+
+ .area _HOME
+_font_color::
+ LDA HL,2(SP) ; Skip return address and registers
+ LD A,(HL+) ; A = Foreground
+ LD (.fg_colour),a
+ LD A,(HL)
+ LD (.bg_colour),a
+ RET
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/gb/Makefile b/gbdk/gbdk-lib/libc/targets/sm83/gb/Makefile
new file mode 100644
index 00000000..393ff679
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/gb/Makefile
@@ -0,0 +1,47 @@
+# GB specific Makefile
+
+TOPDIR = ../../../..
+
+THIS = gb
+PORT = sm83
+
+CSRC = crlf.c digits.c gprint.c gprintf.c gprintln.c gprintn.c
+
+ASSRC = cgb.s cgb_palettes.s cgb_compat.s \
+ cpy_data.s \
+ drawing.s drawing_isr.s color.s \
+ f_ibm_full.s f_ibm_sh.s f_italic.s f_min.s f_spect.s \
+ get_bk_t.s get_data.s get_tile.s \
+ get_wi_t.s get_xy_t.s \
+ get_addr.s \
+ hiramcpy.s init_tt.s input.s \
+ pad.s \
+ serial.s set_bk_t.s set_tile.s \
+ set_data.s set_prop.s set_spr.s set_wi_t.s set_xy_t.s \
+ set_1bit_data.s \
+ sgb.s font.s font_color.s delay.s \
+ emu_debug.s emu_debug_printf.s \
+ nowait.s far_ptr.s \
+ lcd.s joy.s tim.s tim.s tim_nested.s tim_common.s \
+ crash_handler.s \
+ ___sdcc_bcall_ehl.s ___sdcc_bcall.s \
+ mv_spr.s \
+ pad_ex.s \
+ mode.s clock.s \
+ get_t.s set_t.s init_vram.s \
+ fill_rect.s fill_rect_bk.s fill_rect_wi.s \
+ metasprites.s metasprites_flip.s metasprites_hide.s metasprites_hide_spr.s \
+ set_tile_submap.s set_win_tile_submap.s \
+ gb_decompress.s gb_decompress_tiles.s \
+ rle_decompress.s \
+ heap.s \
+ sfr.s \
+ crt0.s
+
+CRT0 = crt0.s
+
+include $(TOPDIR)/Makefile.common
+
+AS = $(AS_SM83)
+
+include ../../../Makefile.platform
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/gb/crash_handler.s b/gbdk/gbdk-lib/libc/targets/sm83/gb/crash_handler.s
new file mode 100644
index 00000000..ec08a7f8
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/gb/crash_handler.s
@@ -0,0 +1,481 @@
+; Crash handler support
+; Original code by ISSOtm
+; Adapted by Toxa from gb-starter-kit: https://github.com/ISSOtm/gb-starter-kit
+
+ .include "global.s"
+
+ .globl _font_ibm
+
+ SCRN_X = 160 ; Width of screen in pixels
+ SCRN_Y = 144 ; Height of screen in pixels
+ SCRN_X_B = 20 ; Width of screen in bytes
+ SCRN_Y_B = 18 ; Height of screen in bytes
+
+ SCRN_VX = 256 ; Virtual width of screen in pixels
+ SCRN_VY = 256 ; Virtual height of screen in pixels
+ SCRN_VX_B = 32 ; Virtual width of screen in bytes
+ SCRN_VY_B = 32 ; Virtual height of screen in bytes
+
+
+ .area _CRASH_HEADER(ABS)
+
+ .org 0x00
+ nop
+ nop
+ rst 0x38
+
+ .org 0x38
+ di
+ jp ___HandleCrash
+
+
+ .area _HOME
+
+___HandleCrash::
+
+ ; We will use VRAM as scratch, since we are going to overwrite it for
+ ; screen output anyways. The thing is, we need to turn the LCD off
+ ; *without* affecting flags... fun task, eh?
+
+ ; Note: it's assumed that this was jumped to with IME off.
+ ; Don't call this directly, use `rst Crash`.
+
+ ld (wCrashA), a ; We need to have at least one working register, so...
+ ldh a, (.IE) ; We're also going to overwrite this
+ ld (wCrashIE), a
+ ldh a, (.LCDC)
+ ld (wCrashLCDC), a
+ ld a, #LCDCF_ON ; LCDCF_ON Make sure the LCD is turned on to avoid waiting infinitely
+ ldh (.LCDC), a
+ ld a, #IEF_VBLANK ; IEF_VBLANK
+ ld (.IE), a
+ ld a, #0 ; `xor a` would overwrite flags
+ ld (.IF), a ; No point in backing up that register, it's always changing
+ halt ; With interrupts disabled, this will exit when `IE & IF != 0`
+ nop ; Handle hardware bug if it becomes true *before* starting to execute the instruction (1-cycle window)
+
+ ; We're now in VBlank! So we can now use VRAM as scratch for some cycles
+ ld a, #0
+ ldh (.LCDC), a ; Turn off LCD so VRAM can always be safely accessed
+ ; Save regs
+ ld (vCrashSP), sp
+ ld sp, #vCrashSP
+ push hl
+ push de
+ push bc
+ ld a, (wCrashA)
+ push af
+
+ ; We need to have all the data in bank 0, but we can't guarantee we were there
+ ldh a, (.VBK)
+ ld e, a
+ bit #0, a
+ jr z, .bank0
+ ; Oh noes. We need to copy the data across banks!
+ ld hl, #vCrashAF
+ ld c, #(5 * 2)
+.copyAcross:
+ ld b, (hl)
+ xor a
+ ldh (.VBK), a
+ ld (hl), b
+ inc l ; inc hl
+ inc a ; ld a, 1
+ ldh (.VBK), a
+ dec c
+ jr nz, .copyAcross
+.bank0:
+ xor a
+ ldh (.NR52), a ; Kill sound for this screen
+
+ ldh (.VBK), a
+ ld a, e
+ ld (vCrashVBK), a ; copy vCrashVBK across banks
+
+ ld a, #1
+ ldh (.VBK), a
+ ld hl, #vCrashDumpScreen
+ ld b, #SCRN_Y_B
+.writeAttrRow:
+ xor a
+ ld c, #(SCRN_X_B + 1)
+ rst #0x28 ; .MemsetSmall
+ ld a, l
+ add a, #(SCRN_VX_B - SCRN_X_B - 1)
+ ld l, a
+ dec b
+ jr nz, .writeAttrRow
+ xor a
+ ldh (.VBK), a
+
+ ; Load palettes
+ ld a, #0x03
+ ldh (.BGP), a
+ ld a, #0x80
+ ldh (.BCPS), a
+ xor a
+ ld c, #.BCPD
+ ldh (c), a
+ ldh (c), a
+ dec a ; ld a, $FF
+ ldh (c), a
+ ldh (c), a
+ ldh (c), a
+ ldh (c), a
+ ldh (c), a
+ ldh (c), a
+
+ ld a, #(SCRN_VY - SCRN_Y)
+ ldh (.SCY), a
+ ld a, #(SCRN_VX - SCRN_X - 4)
+ ldh (.SCX), a
+
+ call loadfont
+
+ ; Copy the registers to the dump viewers
+ ld hl, #vDumpHL
+ ld de, #vCrashHL
+ ld c, #4
+ rst #0x30 ; .MemcpySmall
+
+ ; We're now going to draw the screen, top to bottom
+ ld hl, #vCrashDumpScreen
+
+ ; First 3 lines of text
+ ld de, #.header
+ ld b, #3
+.writeHeaderLine:
+ ld a, #0x20 ; " "
+ ld (hl+), a
+ ld c, #19
+ rst #0x30 ; .MemcpySmall
+ ld a, #0x20 ; " "
+ ld (hl+), a
+ ld a, l
+ add a, #(SCRN_VX_B - SCRN_X_B - 1)
+ ld l, a
+ dec b
+ jr nz, .writeHeaderLine
+
+ ; Blank line
+ ld a, #0x20 ; " "
+ ld c, #(SCRN_X_B + 1)
+ rst #0x28 ; .MemsetSmall
+
+ ; AF and console model
+ ld l, #<vCrashDumpScreenRow4
+ ld c, #4
+ rst #0x30 ; .MemcpySmall
+ pop bc
+ call .printHexBC
+ ld c, #8
+ rst #0x30 ; .MemcpySmall
+ ld a, (__cpu)
+ call .printHexA
+ ld a, #0x20 ; " "
+ ld (hl+), a
+ ld (hl+), a
+ ld (hl+), a
+
+ ; BC and DE
+ ld l, #<vCrashDumpScreenRow5
+ ld c, #4
+ rst #0x30 ; .MemcpySmall
+ pop bc
+ call .printHexBC
+ ld c, #6
+ rst #0x30 ; .MemcpySmall
+ pop bc
+ call .printHexBC
+ ld a, #0x20
+ ld (hl+), a
+ ld (hl+), a
+ ld (hl+), a
+
+ ; Now, the two memory dumps
+.writeDump:
+ ld a, l
+ add a, #(SCRN_VX_B - SCRN_X_B - 1)
+ ld l, a
+ ld c, #4
+ rst #0x30 ; .MemcpySmall
+ pop bc
+ push bc
+ call .printHexBC
+ ld de, #.viewStr
+ ld c, #7
+ rst #0x30 ; .MemcpySmall
+ pop de
+ call .printDump
+ ld de, #.spStr
+ bit #7, l
+ jr z, .writeDump
+
+ ld de, #.hwRegsStrs
+ ld l, #<vCrashDumpScreenRow14
+ ld c, #6
+ rst #0x30 ; .MemcpySmall
+ ld a, (wCrashLCDC)
+ call .printHexA
+ ld c, #4
+ rst #0x30 ; .MemcpySmall
+ ldh a, (.KEY1)
+ call .printHexA
+ ld c, #4
+ rst #0x30 ; .MemcpySmall
+ ld a, (wCrashIE)
+ call .printHexA
+ ld (hl), #0x20 ; " "
+
+ ld l, #<vCrashDumpScreenRow15
+ ld c, #7
+ rst #0x30 ; .MemcpySmall
+.writeBank:
+ ld a, #0x20 ; " "
+ ld (hl+), a
+ ld a, (de)
+ inc de
+ ld (hl+), a
+ cp #0x20 ; " "
+ jr z, .banksDone
+ ld a, (de)
+ inc de
+ ld c, a
+ ld a, (de)
+ inc de
+ ld b, a
+ ld a, (bc)
+ call .printHexA
+ jr .writeBank
+.banksDone:
+
+ ; Start displaying
+ ld a, #(LCDCF_ON | LCDCF_BG9C00 | LCDCF_BGON)
+ ldh (.LCDC), a
+
+.loop:
+ ; The code never lags, and IE is equal to IEF_VBLANK
+ xor a
+ ldh (.IF), a
+ halt
+
+ jr .loop
+
+.printHexBC:
+ call .printHexB
+ ld a, c
+.printHexA:
+ ld b, a
+.printHexB:
+ ld a, b
+ and #0xF0
+ swap a
+ add a, #0x30
+ cp #0x3a
+ jr c, 1$
+ add a, #(0x41 - 0x3a)
+1$: ld (hl+), a
+ ld a, b
+ and #0x0F
+ add a, #0x30
+ cp #0x3a
+ jr c, 2$
+ add a, #(0x41 - 0x3a)
+2$: ld (hl+), a
+ ret
+
+.printDump:
+ ld b, d
+ ld c, e
+ call .printHexBC
+ ld a, #0x20 ; " "
+ ld (hl+), a
+ ld (hl+), a
+ ld a, e
+ sub #8
+ ld e, a
+ ld a, d
+ sbc #0
+ ld d, a
+.writeDumpLine:
+ ld a, l
+ add a, #(SCRN_VX_B - SCRN_X_B - 1)
+ ld l, a
+ ld a, #0x20 ; " "
+ ld (hl+), a
+.writeDumpWord:
+ ld a, (de)
+ inc de
+ call .printHexA
+ ld a, (de)
+ inc de
+ call .printHexA
+ ld a, #0x20 ; " "
+ ld (hl+), a
+ bit 4, l
+ jr nz, .writeDumpWord
+ ld a, l
+ and #0x7F
+ jr nz, .writeDumpLine
+ ret
+
+loadfont:
+ xor a
+ cpl
+ ld hl, #0x9000
+ ld c, #16
+ rst #0x28 ; .MemsetSmall
+ ld hl, #(0x9000 + ' ' * 16)
+ ld c, #16
+ rst #0x28 ; .MemsetSmall
+
+ ld de, #(_font_ibm + 2 + '0') ; recode table
+ ld hl, #(0x9000 + '0' * 16) ; destination
+ push hl
+ ld c, #(16 * 3)
+1$:
+ ld a, (de)
+ inc de
+ push de
+
+ swap a
+ ld l, a
+ and #0x0f
+ ld h, a
+ ld a, l
+ and #0xf0
+ srl h
+ rra
+ ld l, a
+ ld de, #(_font_ibm + 2 + 128)
+ add hl, de
+
+ ld d, h
+ ld e, l
+
+ ldhl sp, #2
+ ld a, (hl+)
+ ld h, (hl)
+ ld l, a
+
+ ld b, #8
+2$:
+ ld a, (de)
+ cpl
+ inc de
+ ld (hl+), a
+ ld (hl+), a
+
+ dec b
+ jr nz, 2$
+
+ ld d, h
+ ld a, l
+ ldhl sp, #2
+ ld (hl+), a
+ ld (hl), d
+
+ pop de
+
+ dec c
+ jr nz, 1$
+
+ add sp, #2
+ ret
+
+.header:
+ ; 0123456789ABCDEFGHI 19 chars
+ .ascii "KERNEL PANIC PLEASE"
+ .ascii "SEND A CLEAR PIC OF"
+ .ascii "THIS SCREEN TO DEVS"
+ .ascii " AF:"
+ .ascii " MODEL:"
+ .ascii " BC:"
+ .ascii " DE:"
+ .ascii " HL:"
+.viewStr:
+ .ascii " VIEW:"
+.spStr:
+ .ascii " SP:"
+.hwRegsStrs:
+ .ascii " LCDC:"
+ .ascii " K1:"
+ .ascii " IE:"
+ .ascii " BANK:"
+ .ascii "R"
+ .dw __current_bank
+ .ascii "V"
+ .dw vCrashVBK
+ .ascii "W"
+ .db .SVBK, 0xff
+ .ascii " "
+
+
+ .area _DATA
+
+wCrashA:
+ .ds 1 ; We need at least one working register, and A allows accessing memory
+wCrashIE:
+ .ds 1
+wCrashLCDC:
+ .ds 1
+
+
+ .area _CRASH_SCRATCH(ABS)
+
+ .org 0x9C00
+
+ ; Put the crash dump screen at the bottom-right of the 9C00 tilemap, since that tends to be unused space
+ .ds SCRN_VX_B * (SCRN_VY_B - SCRN_Y_B - 2) ; 2 rows reserved as scratch space
+
+ .ds SCRN_X_B ; Try not to overwrite the window area
+ .ds 2 * 1 ; Free stack entries (we spill into the above by 1 entry, though :/)
+ ; These are the initial values of the registers
+ ; They are popped off the stack when printed, freeing up stack space
+
+vCrashAF:
+ .ds 2
+vCrashBC:
+ .ds 2
+vCrashDE:
+ .ds 2
+vCrashHL:
+ .ds 2
+vCrashSP:
+ .ds 2
+
+ .ds SCRN_X_B
+vHeldKeys:
+ .ds 1 ; Keys held on previous frame
+vUnlockCounter:
+ .ds 1 ; How many frames until dumps are "unlocked"
+vWhichDump:
+ .ds 1
+vDumpHL:
+ .ds 2
+vDumpSP:
+ .ds 2
+vCrashVBK:
+ .ds 1
+ .ds 4 ; Unused
+
+ .ds SCRN_VX_B - SCRN_X_B - 1
+vCrashDumpScreen:
+vCrashDumpScreenRow0 = vCrashDumpScreen + 1 * SCRN_VX_B
+vCrashDumpScreenRow1 = vCrashDumpScreen + 2 * SCRN_VX_B
+vCrashDumpScreenRow2 = vCrashDumpScreen + 3 * SCRN_VX_B
+vCrashDumpScreenRow3 = vCrashDumpScreen + 4 * SCRN_VX_B
+vCrashDumpScreenRow4 = vCrashDumpScreen + 5 * SCRN_VX_B
+vCrashDumpScreenRow5 = vCrashDumpScreen + 6 * SCRN_VX_B
+vCrashDumpScreenRow6 = vCrashDumpScreen + 7 * SCRN_VX_B
+vCrashDumpScreenRow7 = vCrashDumpScreen + 8 * SCRN_VX_B
+vCrashDumpScreenRow8 = vCrashDumpScreen + 9 * SCRN_VX_B
+vCrashDumpScreenRow9 = vCrashDumpScreen + 10 * SCRN_VX_B
+vCrashDumpScreenRow10 = vCrashDumpScreen + 11 * SCRN_VX_B
+vCrashDumpScreenRow11 = vCrashDumpScreen + 12 * SCRN_VX_B
+vCrashDumpScreenRow12 = vCrashDumpScreen + 13 * SCRN_VX_B
+vCrashDumpScreenRow13 = vCrashDumpScreen + 14 * SCRN_VX_B
+vCrashDumpScreenRow14 = vCrashDumpScreen + 15 * SCRN_VX_B
+vCrashDumpScreenRow15 = vCrashDumpScreen + 16 * SCRN_VX_B
+vCrashDumpScreenRow16 = vCrashDumpScreen + 17 * SCRN_VX_B
+vCrashDumpScreenRow17 = vCrashDumpScreen + 18 * SCRN_VX_B
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/gb/crt0.s b/gbdk/gbdk-lib/libc/targets/sm83/gb/crt0.s
new file mode 100644
index 00000000..31dff00b
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/gb/crt0.s
@@ -0,0 +1,538 @@
+ .include "global.s"
+
+ ;; ****************************************
+ ;; Beginning of module
+ ;; BANKED: checked
+ .title "Runtime"
+ .module Runtime
+ .area _HEADER (ABS)
+
+ ;; RST vectors
+; .org 0x00 ; Trap, utilized by crash_handler.h
+
+; .org 0x08 ; --profile handler utilized by emu_debug.h
+
+; .org 0x10 ; empty
+
+; .org 0x18 ; empty
+
+ .org 0x20 ; RST 0x20 == call HL
+.call_hl::
+ JP (HL)
+
+ .org 0x28 ; zero up to 256 bytes in C pointed by HL
+.MemsetSmall::
+ LD (HL+),A
+ DEC C
+ JR NZ,.MemsetSmall
+ ret
+
+ .org 0x30 ; copy up to 256 bytes in C from DE to HL
+.MemcpySmall::
+ LD A, (DE)
+ LD (HL+), A
+ INC DE
+ DEC C
+ JR NZ,.MemcpySmall
+ RET
+
+; .org 0x38 ; crash handler utilized by crash_handler.h
+
+ ;; Hardware interrupt vectors
+ .org 0x40 ; VBL
+.int_VBL:
+ PUSH AF
+ PUSH HL
+ LD HL,#.int_0x40
+ JP .int
+
+; .org 0x48 ; LCD
+
+; .org 0x50 ; TIM
+
+; .org 0x58 ; SIO
+
+; .org 0x60 ; JOY
+
+; .org 0x70
+ ;; space for drawing.s bit table
+
+ .org 0x80
+.int::
+ PUSH BC
+ PUSH DE
+1$:
+ LD A,(HL+)
+ OR (HL)
+ JR Z,.int_tail
+ PUSH HL
+ LD A,(HL-)
+ LD L,(HL)
+ LD H,A
+ RST 0x20 ; .call_hl
+ POP HL
+ INC HL
+ JR 1$
+_wait_int_handler::
+ ADD SP,#4
+.int_tail:
+ POP DE
+ POP BC
+ POP HL
+
+ ;; we return at least at the beginning of mode 2
+ WAIT_STAT
+
+ POP AF
+ RETI
+
+ ;; VBlank default interrupt routine
+__standard_VBL_handler::
+.std_vbl:
+ LD HL,#.sys_time
+ INC (HL)
+ JR NZ,2$
+ INC HL
+ INC (HL)
+2$:
+ CALL .refresh_OAM
+
+ LD A, #1
+ LDH (.vbl_done),A
+ RET
+
+_refresh_OAM::
+ WAIT_STAT
+ LD A, #>_shadow_OAM
+ JP .refresh_OAM + (.refresh_OAM_DMA - .start_refresh_OAM)
+
+.clear_WRAM:
+ PUSH DE
+ XOR A
+ LD BC, #l__DATA
+ LD HL, #s__DATA
+ CALL .memset_simple
+
+ LD A, #>_shadow_OAM
+ LDH (__shadow_OAM_base), A
+ LD H, A
+ XOR A
+ LD L, A
+ LD C, #(40 << 2) ; 40 entries 4 bytes each
+ RST 0x28
+ POP DE
+ RET
+
+ ;; GameBoy Header
+
+ ;; DO NOT CHANGE...
+ .org 0x100
+.header:
+ JR .code_start
+
+ ;; Nintendo logo
+ .org 0x104
+ .byte 0xCE,0xED,0x66,0x66
+ .byte 0xCC,0x0D,0x00,0x0B
+ .byte 0x03,0x73,0x00,0x83
+ .byte 0x00,0x0C,0x00,0x0D
+ .byte 0x00,0x08,0x11,0x1F
+ .byte 0x88,0x89,0x00,0x0E
+ .byte 0xDC,0xCC,0x6E,0xE6
+ .byte 0xDD,0xDD,0xD9,0x99
+ .byte 0xBB,0xBB,0x67,0x63
+ .byte 0x6E,0x0E,0xEC,0xCC
+ .byte 0xDD,0xDC,0x99,0x9F
+ .byte 0xBB,0xB9,0x33,0x3E
+
+ ;; Title of the game
+ .org 0x134
+ .asciz "Title"
+
+ .org 0x144
+ .byte 0,0,0
+
+ ;; Cartridge type is ROM only
+ .org 0x147
+ .byte 0
+
+ ;; ROM size is 32kB
+ .org 0x148
+ .byte 0
+
+ ;; RAM size is 0kB
+ .org 0x149
+ .byte 0
+
+ ;; Maker ID
+ .org 0x14A
+ .byte 0x00,0x00
+
+ ;; Version number
+ .org 0x14C
+ .byte 0x01
+
+ ;; Complement check
+ .org 0x14D
+ .byte 0x00
+
+ ;; Checksum
+ .org 0x14E
+ .byte 0x00,0x00
+
+ ;; ****************************************
+ .org 0x150
+
+ ;; soft reset: falldown to .code_start
+.reset::
+_reset::
+ LD A, (__is_GBA)
+ LD B, A
+ LD A, (__cpu)
+
+ ;; Initialization code
+.code_start::
+ DI ; Disable interrupts
+ LD D, A ; Store CPU type in D
+ LD E, B ; Store GBA flag in E
+ ;; Initialize the stack
+ LD SP, #.STACK
+
+ CALL .clear_WRAM
+
+; LD (.mode),A ; Clearing (.mode) is performed when clearing RAM
+
+ ;; Store CPU type
+ LD A, D
+ LD (__cpu), A
+ CP #.CGB_TYPE
+ JR NZ, 1$
+ XOR A
+ SRL E
+ RLA
+ LD (__is_GBA), A
+1$:
+ ;; Turn the screen off
+ CALL .display_off
+
+ XOR A
+ ;; Initialize the display
+ LDH (.SCY),A
+ LDH (.SCX),A
+ LDH (.STAT),A
+ LDH (.WY),A
+ LD A,#0x07
+ LDH (.WX),A
+
+ ;; Copy refresh_OAM routine to HRAM
+ LD DE,#.start_refresh_OAM ; source
+ LD HL,#.refresh_OAM ; dest
+ LD C,#(.end_refresh_OAM - .start_refresh_OAM) ; size
+ RST 0x30 ; call .MemcpySmall
+
+ ;; Clear the OAM by calling refresh_OAM
+ CALL .refresh_OAM
+
+ ;; Install interrupt routines
+ LD BC,#.std_vbl
+ CALL .add_VBL
+
+ ;; Standard color palettes
+ LD A,#0b11100100 ; Grey 3 = 11 (Black)
+ ; Grey 2 = 10 (Dark grey)
+ ; Grey 1 = 01 (Light grey)
+ ; Grey 0 = 00 (Transparent)
+ LDH (.BGP),A
+ LDH (.OBP0),A
+ LD A,#0b00011011
+ LDH (.OBP1),A
+
+ ;; Turn the screen on
+ LD A,#(LCDCF_ON | LCDCF_WIN9C00 | LCDCF_WINOFF | LCDCF_BG8800 | LCDCF_BG9800 | LCDCF_OBJ8 | LCDCF_OBJOFF | LCDCF_BGOFF)
+ LDH (.LCDC),A
+ XOR A
+ LDH (.IF),A
+ LD A,#.VBL_IFLAG ; switch on VBlank interrupt only
+ LDH (.IE),A
+
+ LDH (__current_bank),A ; current bank is 1 at startup
+
+ XOR A
+
+ LD HL,#.sys_time
+ LD (HL+),A
+ LD (HL),A
+
+ LDH (.NR52),A ; Turn sound off
+
+ CALL gsinit
+
+ EI ; Enable interrupts
+
+ ;; Call the main function
+ CALL _main
+_exit::
+99$:
+ HALT
+ NOP
+ JR 99$ ; Wait forever
+
+_set_interrupts::
+ DI
+ LDA HL,2(SP) ; Skip return address
+ XOR A
+ LDH (.IF),A ; Clear pending interrupts
+ LD A,(HL)
+ EI ; Enable interrupts
+ LDH (.IE),A ; interrupts are still disabled here
+ RET
+
+ ;; Copy OAM data to OAM RAM
+.start_refresh_OAM:
+ LDH A,(__shadow_OAM_base)
+ OR A
+ RET Z
+.refresh_OAM_DMA:
+ LDH (.DMA),A ; Put A into DMA registers
+ LD A,#0x28 ; We need to wait 160 ns
+1$:
+ DEC A
+ JR NZ,1$
+ RET
+.end_refresh_OAM:
+
+ .org .MODE_TABLE
+ ;; Jump table for modes
+ RET
+
+ ;; ****************************************
+
+ ;; Ordering of segments for the linker
+ ;; Code that really needs to be in bank 0
+ .area _HOME
+ ;; Similar to _HOME
+ .area _BASE
+ ;; Code
+ .area _CODE
+ ;; #pragma bank 0 workaround
+ .area _CODE_0
+ ;; Constant data
+ .area _LIT
+; ;; since _CODE_1 area base address is pre-defined in the linker from 0x4000,
+; ;; that moves initializer code and tables out of bank 0
+; .area _CODE_1
+ ;; Constant data, used to init _DATA
+ .area _INITIALIZER
+ ;; Code, used to init _DATA
+ .area _GSINIT
+ .area _GSFINAL
+ ;; Uninitialised ram data
+ .area _DATA
+ .area _BSS
+ ;; Initialised in ram data
+ .area _INITIALIZED
+ ;; For malloc
+ .area _HEAP
+ .area _HEAP_END
+
+ .area _DATA
+.start_crt_globals:
+
+__cpu::
+ .ds 0x01 ; GB type (GB, PGB, CGB)
+__is_GBA::
+ .ds 0x01 ; detect GBA
+.mode::
+ .ds 0x01 ; Current mode
+.sys_time::
+_sys_time::
+ .ds 0x02 ; System time in VBL units
+.int_0x40::
+ .blkw 0x0A ; 4 interrupt handlers (built-in + user-defined)
+
+.end_crt_globals:
+
+ .area _HRAM (ABS)
+
+ .org 0xFF90
+__current_bank:: ; Current bank
+ .ds 0x01
+.vbl_done:
+ .ds 0x01 ; Is VBL interrupt finished?
+__shadow_OAM_base::
+ .ds 0x01
+
+ ;; Runtime library
+ .area _GSINIT
+gsinit::
+ ;; initialize static storage variables
+ LD BC, #l__INITIALIZER
+ LD HL, #s__INITIALIZER
+ LD DE, #s__INITIALIZED
+ call .memcpy_simple
+
+ .area _GSFINAL
+ ret
+
+ .area _HOME
+
+ ;; fills memory at HL of length BC with A, clobbers DE
+.memset_simple::
+ LD E, A
+ LD A, B
+ OR C
+ RET Z
+ LD (HL), E
+ DEC BC
+ LD D, H
+ LD E, L
+ INC DE
+
+ ;; copies BC bytes from HL into DE
+.memcpy_simple::
+ LD A, B
+ OR C
+ RET Z
+
+ SRL B
+ RR C
+ JR NC,3$
+ LD A, (HL+)
+ LD (DE), A
+ INC DE
+3$:
+ INC B
+ INC C
+ JR 2$
+1$:
+ LD A, (HL+)
+ LD (DE), A
+ INC DE
+ LD A, (HL+)
+ LD (DE), A
+ INC DE
+2$:
+ DEC C
+ JR NZ,1$
+ DEC B
+ JR NZ,1$
+4$:
+ RET
+
+ ;; Remove interrupt routine in BC from the VBL interrupt list
+ ;; falldown to .remove_int
+.remove_VBL::
+ LD HL,#.int_0x40
+
+ ;; Remove interrupt BC from interrupt list HL if it exists
+ ;; Abort if a 0000 is found (end of list)
+.remove_int::
+1$:
+ LD A,(HL+)
+ LD E,A
+ LD D,(HL)
+ INC HL
+ OR D
+ RET Z ; No interrupt found
+
+ LD A,E
+ CP C
+ JR NZ,1$
+ LD A,D
+ CP B
+ JR NZ,1$
+
+ LD D,H
+ LD E,L
+ DEC DE
+ DEC DE
+
+ ;; Now do a memcpy from here until the end of the list
+2$:
+ LD A,(HL+)
+ LD (DE),A
+ LD B,A
+ INC DE
+ LD A,(HL+)
+ LD (DE),A
+ INC DE
+ OR B
+ RET Z
+ JR 2$
+
+ ;; Add interrupt routine in BC to the VBL interrupt list
+ ;; falldown to .add_int
+.add_VBL::
+ LD HL,#.int_0x40
+
+ ;; Add interrupt routine in BC to the interrupt list in HL
+.add_int::
+1$:
+ LD A,(HL+)
+ OR (HL)
+ JR Z,2$
+ INC HL
+ JR 1$
+2$:
+ LD A,B
+ LD (HL-),A
+ LD (HL),C
+ RET
+
+ ;; Wait for VBL interrupt to be finished
+.wait_vbl_done::
+_wait_vbl_done::
+ ;; Check if the screen is on
+ LDH A,(.LCDC)
+ AND #LCDCF_ON
+ RET Z ; Return if screen is off
+ XOR A
+ LDH (.vbl_done),A ; Clear any previous sets of vbl_done
+1$:
+ HALT ; Wait for any interrupt
+ NOP ; HALT sometimes skips the next instruction
+ LDH A,(.vbl_done) ; Was it a VBlank interrupt?
+ ;; Warning: we may lose a VBlank interrupt, if it occurs now
+ OR A
+ JR Z,1$ ; No: back to sleep!
+ RET
+
+.display_off::
+_display_off::
+ ;; Check if the screen is on
+ LDH A,(.LCDC)
+ AND #LCDCF_ON
+ RET Z ; Return if screen is off
+1$: ; We wait for the *NEXT* VBL
+ LDH A,(.LY)
+ CP #0x92 ; Smaller than or equal to 0x91?
+ JR NC,1$ ; Loop until smaller than or equal to 0x91
+2$:
+ LDH A,(.LY)
+ CP #0x91 ; Bigger than 0x90?
+ JR C,2$ ; Loop until bigger than 0x90
+
+ LDH A,(.LCDC)
+ AND #~LCDCF_ON
+ LDH (.LCDC),A ; Turn off screen
+ RET
+
+_remove_VBL::
+ PUSH BC
+ LDA HL,4(SP) ; Skip return address and registers
+ LD A,(HL+)
+ LD C,A
+ LD B,(HL)
+ CALL .remove_VBL
+ POP BC
+ RET
+
+_add_VBL::
+ PUSH BC
+ LDA HL, 4(SP) ; Skip return address and registers
+ LD A,(HL+)
+ LD C,A
+ LD B,(HL)
+ CALL .add_VBL
+ POP BC
+ RET
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/gb/global.s b/gbdk/gbdk-lib/libc/targets/sm83/gb/global.s
new file mode 100644
index 00000000..c9f30ecd
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/gb/global.s
@@ -0,0 +1,532 @@
+ .NEAR_CALLS = 1 ; <near_calls> - tag so that sed can change this
+
+ _VRAM = 0x8000 ; $8000->$9FFF
+ _VRAM8000 = 0x8000
+ _VRAM8800 = 0x8800
+ _VRAM9000 = 0x9000
+ _SCRN0 = 0x9800 ; $9800->$9BFF
+ _SCRN1 = 0x9C00 ; $9C00->$9FFF
+ _SRAM = 0xA000 ; $A000->$BFFF
+ _RAM = 0xC000 ; $C000->$CFFF / $C000->$DFFF
+ _RAMBANK = 0xD000 ; $D000->$DFFF
+ _OAMRAM = 0xFE00 ; $FE00->$FE9F
+ _IO = 0xFF00 ; $FF00->$FF7F,$FFFF
+ _AUD3WAVERAM = 0xFF30 ; $FF30->$FF3F
+ _HRAM = 0xFF80 ; $FF80->$FFFE
+
+ ;; MBC Equates
+
+ .MBC1_ROM_PAGE = 0x2000 ; Address to write to for MBC1 switching
+ .MBC_ROM_PAGE = 0x2000 ; Default platform MBC rom switching address
+
+ rRAMG = 0x0000 ; $0000->$1fff
+ rROMB0 = 0x2000 ; $2000->$2fff
+ rROMB1 = 0x3000 ; $3000->$3fff - If more than 256 ROM banks are present.
+ rRAMB = 0x4000 ; $4000->$5fff - Bit 3 enables rumble (if present)
+
+ ;; Keypad
+ .UP = 0x04
+ .DOWN = 0x08
+ .LEFT = 0x02
+ .RIGHT = 0x01
+ .A = 0x10
+ .B = 0x20
+ .SELECT = 0x40
+ .START = 0x80
+
+ .P14 = 0x10
+ .P15 = 0x20
+
+ ;; Screen dimensions
+ .MAXCURSPOSX = 0x13 ; In tiles
+ .MAXCURSPOSY = 0x11
+
+ .SCREENWIDTH = 0xA0
+ .SCREENHEIGHT = 0x90
+ .MINWNDPOSX = 0x07
+ .MINWNDPOSY = 0x00
+ .MAXWNDPOSX = 0xA6
+ .MAXWNDPOSY = 0x8F
+
+ ;; Hardware registers
+
+ .P1 = 0x00 ; Joystick: 1.1.P15.P14.P13.P12.P11.P10
+ rP1 = 0xFF00
+
+ P1F_5 = 0b00100000 ; P15 out port, set to 0 to get buttons
+ P1F_4 = 0b00010000 ; P14 out port, set to 0 to get dpad
+ P1F_3 = 0b00001000 ; P13 in port
+ P1F_2 = 0b00000100 ; P12 in port
+ P1F_1 = 0b00000010 ; P11 in port
+ P1F_0 = 0b00000001 ; P10 in port
+
+ P1F_GET_DPAD = 0b00100000
+ P1F_GET_BTN = 0b00010000
+ P1F_GET_NONE = 0b00110000
+
+ .SB = 0x01 ; Serial IO data buffer
+ rSB = 0xFF01
+
+ .SC = 0x02 ; Serial IO control register
+ rSC = 0xFF02
+
+ .DIV = 0x04 ; Divider register
+ rDIV = 0xFF04
+
+ .TIMA = 0x05 ; Timer counter
+ rTIMA = 0xFF05
+
+ .TMA = 0x06 ; Timer modulo
+ rTMA = 0xFF06
+
+ .TAC = 0x07 ; Timer control
+ rTAC = 0xFF07
+
+ TACF_START = 0b00000100
+ TACF_STOP = 0b00000000
+ TACF_4KHZ = 0b00000000
+ TACF_16KHZ = 0b00000011
+ TACF_65KHZ = 0b00000010
+ TACF_262KHZ = 0b00000001
+
+ .IF = 0x0F ; Interrupt flags: 0.0.0.JST.SIO.TIM.LCD.VBL
+ rIF = 0xFF0F
+
+ .NR10 = 0x10 ; Sound register
+ rNR10 = 0xFF10
+ rAUD1SWEEP = 0xFF10
+
+ AUD1SWEEP_UP = 0b00000000
+ AUD1SWEEP_DOWN = 0b00001000
+
+ .NR11 = 0x11 ; Sound register
+ rNR11 = 0xFF11
+ rAUD1LEN = 0xFF11
+
+ .NR12 = 0x12 ; Sound register
+ rNR12 = 0xFF12
+ rAUD1ENV = 0xFF12
+
+ .NR13 = 0x13 ; Sound register
+ rNR13 = 0xFF13
+ rAUD1LOW = 0xFF13
+
+ .NR14 = 0x14 ; Sound register
+ rNR14 = 0xFF14
+ rAUD1HIGH = 0xFF14
+
+ .NR21 = 0x16 ; Sound register
+ rNR21 = 0xFF16
+ rAUD2LEN = 0xFF16
+
+ .NR22 = 0x17 ; Sound register
+ rNR22 = 0xFF17
+ rAUD2ENV = 0xFF17
+
+ .NR23 = 0x18 ; Sound register
+ rNR23 = 0xFF18
+ rAUD2LOW = 0xFF18
+
+ .NR24 = 0x19 ; Sound register
+ rNR24 = 0xFF19
+ rAUD2HIGH = 0xFF19
+
+ .NR30 = 0x1A ; Sound register
+ rNR30 = 0xFF1A
+ rAUD3ENA = 0xFF1A
+
+ .NR31 = 0x1B ; Sound register
+ rNR31 = 0xFF1B
+ rAUD3LEN = 0xFF1B
+
+ .NR32 = 0x1C ; Sound register
+ rNR32 = 0xFF1C
+ rAUD3LEVEL = 0xFF1C
+
+ .NR33 = 0x1D ; Sound register
+ rNR33 = 0xFF1D
+ rAUD3LOW = 0xFF1D
+
+ .NR34 = 0x1E ; Sound register
+ rNR34 = 0xFF1E
+ rAUD3HIGH = 0xFF1E
+
+ .NR41 = 0x20 ; Sound register
+ rNR41 = 0xFF20
+ rAUD4LEN = 0xFF20
+
+ .NR42 = 0x21 ; Sound register
+ rNR42 = 0xFF21
+ rAUD4ENV = 0xFF21
+
+ .NR43 = 0x22 ; Sound register
+ rNR43 = 0xFF22
+ rAUD4POLY = 0xFF22
+
+ .NR44 = 0x23 ; Sound register
+ rNR44 = 0xFF23
+ rAUD4GO = 0xFF23
+
+ .NR50 = 0x24 ; Sound register
+ rNR50 = 0xFF24
+ rAUDVOL = 0xFF24
+
+ AUDVOL_VIN_LEFT = 0b10000000 ; SO2
+ AUDVOL_VIN_RIGHT = 0b00001000 ; SO1
+
+ .NR51 = 0x25 ; Sound register
+ rNR51 = 0xFF25
+ rAUDTERM = 0xFF25
+
+ AUDTERM_4_LEFT = 0b10000000
+ AUDTERM_3_LEFT = 0b01000000
+ AUDTERM_2_LEFT = 0b00100000
+ AUDTERM_1_LEFT = 0b00010000
+ AUDTERM_4_RIGHT = 0b00001000
+ AUDTERM_3_RIGHT = 0b00000100
+ AUDTERM_2_RIGHT = 0b00000010
+ AUDTERM_1_RIGHT = 0b00000001
+
+ .NR52 = 0x26 ; Sound register
+ rNR52 = 0xFF26
+ rAUDENA = 0xFF26
+
+ AUDENA_ON = 0b10000000
+ AUDENA_OFF = 0b00000000 ; sets all audio regs to 0!
+
+ .LCDC = 0x40 ; LCD control
+ rLCDC = 0xFF40
+
+ LCDCF_OFF = 0b00000000 ; LCD Control Operation
+ LCDCF_ON = 0b10000000 ; LCD Control Operation
+ LCDCF_WIN9800 = 0b00000000 ; Window Tile Map Display Select
+ LCDCF_WIN9C00 = 0b01000000 ; Window Tile Map Display Select
+ LCDCF_WINOFF = 0b00000000 ; Window Display
+ LCDCF_WINON = 0b00100000 ; Window Display
+ LCDCF_BG8800 = 0b00000000 ; BG & Window Tile Data Select
+ LCDCF_BG8000 = 0b00010000 ; BG & Window Tile Data Select
+ LCDCF_BG9800 = 0b00000000 ; BG Tile Map Display Select
+ LCDCF_BG9C00 = 0b00001000 ; BG Tile Map Display Select
+ LCDCF_OBJ8 = 0b00000000 ; OBJ Construction
+ LCDCF_OBJ16 = 0b00000100 ; OBJ Construction
+ LCDCF_OBJOFF = 0b00000000 ; OBJ Display
+ LCDCF_OBJON = 0b00000010 ; OBJ Display
+ LCDCF_BGOFF = 0b00000000 ; BG Display
+ LCDCF_BGON = 0b00000001 ; BG Display
+ LCDCF_B_ON = 7
+ LCDCF_B_WIN9C00 = 6
+ LCDCF_B_WINON = 5
+ LCDCF_B_BG8000 = 4
+ LCDCF_B_BG9C00 = 3
+ LCDCF_B_OBJ16 = 2
+ LCDCF_B_OBJON = 1
+ LCDCF_B_BGON = 0
+
+ .STAT = 0x41 ; LCD status
+ rSTAT = 0xFF41
+
+ STATF_LYC = 0b01000000 ; LYC=LY Coincidence (Selectable)
+ STATF_MODE10 = 0b00100000 ; Mode 10
+ STATF_MODE01 = 0b00010000 ; Mode 01 (V-Blank)
+ STATF_MODE00 = 0b00001000 ; Mode 00 (H-Blank)
+ STATF_LYCF = 0b00000100 ; Coincidence Flag
+ STATF_HBL = 0b00000000 ; H-Blank
+ STATF_VBL = 0b00000001 ; V-Blank
+ STATF_OAM = 0b00000010 ; OAM-RAM is used by system
+ STATF_LCD = 0b00000011 ; Both OAM and VRAM used by system
+ STATF_BUSY = 0b00000010 ; When set, VRAM access is unsafe
+ STATF_B_LYC = 6
+ STATF_B_MODE10 = 5
+ STATF_B_MODE01 = 4
+ STATF_B_MODE00 = 3
+ STATF_B_LYCF = 2
+ STATF_B_VBL = 0
+ STATF_B_OAM = 1
+ STATF_B_BUSY = 1
+
+ .SCY = 0x42 ; Scroll Y
+ rSCY = 0xFF42
+
+ .SCX = 0x43 ; Scroll X
+ rSCX = 0xFF43
+
+ .LY = 0x44 ; LCDC Y-coordinate
+ rLY = 0xFF44
+
+ .LYC = 0x45 ; LY compare
+ rLYC = 0xFF45
+
+ .DMA = 0x46 ; DMA transfer
+ rDMA = 0xFF46
+
+ .BGP = 0x47 ; BG palette data
+ rBGP = 0xFF47
+
+ .OBP0 = 0x48 ; OBJ palette 0 data
+ rOBP0 = 0xFF48
+
+ .OBP1 = 0x49 ; OBJ palette 1 data
+ rOBP1 = 0xFF49
+
+ .WY = 0x4A ; Window Y coordinate
+ rWY = 0xFF4A
+
+ .WX = 0x4B ; Window X coordinate
+ rWX = 0xFF4B
+
+ .KEY1 = 0x4D ; CPU speed
+ rKEY1 = 0xFF4D
+ rSPD = 0xFF4D
+
+ KEY1F_DBLSPEED = 0b10000000 ; 0=Normal Speed, 1=Double Speed (R)
+ KEY1F_PREPARE = 0b00000001 ; 0=No, 1=Prepare (R/W)
+
+ .VBK = 0x4F ; VRAM bank
+ rVBK = 0xFF4F
+
+ .HDMA1 = 0x51 ; DMA control 1
+ rHDMA1 = 0xFF51
+
+ .HDMA2 = 0x52 ; DMA control 2
+ rHDMA2 = 0xFF52
+
+ .HDMA3 = 0x53 ; DMA control 3
+ rHDMA3 = 0xFF53
+
+ .HDMA4 = 0x54 ; DMA control 4
+ rHDMA4 = 0xFF54
+
+ .HDMA5 = 0x55 ; DMA control 5
+ rHDMA5 = 0xFF55
+
+ HDMA5F_MODE_GP = 0b00000000 ; General Purpose DMA (W)
+ HDMA5F_MODE_HBL = 0b10000000 ; HBlank DMA (W)
+
+ HDMA5F_BUSY = 0b10000000 ; 0=Busy (DMA still in progress), 1=Transfer complete (R)
+
+ .RP = 0x56 ; IR port
+ rRP = 0xFF56
+
+ RPF_ENREAD = 0b11000000
+ RPF_DATAIN = 0b00000010 ; 0=Receiving IR Signal, 1=Normal
+ RPF_WRITE_HI = 0b00000001
+ RPF_WRITE_LO = 0b00000000
+
+ .BCPS = 0x68 ; BG color palette specification
+ rBCPS = 0xFF68
+
+ BCPSF_AUTOINC = 0b10000000 ; Auto Increment (0=Disabled, 1=Increment after Writing)
+
+ .BCPD = 0x69 ; BG color palette data
+ rBCPD = 0xFF69
+
+ .OCPS = 0x6A ; OBJ color palette specification
+ rOCPS = 0xFF6A
+
+ OCPSF_AUTOINC = 0b10000000 ; Auto Increment (0=Disabled, 1=Increment after Writing)
+
+ .OCPD = 0x6B ; OBJ color palette data
+ rOCPD = 0xFF6B
+
+ .SVBK = 0x70 ; WRAM bank
+ rSVBK = 0xFF70
+ rSMBK = 0xFF70
+
+ rPCM12 = 0xFF76
+
+ rPCM34 = 0xFF77
+
+ .IE = 0xFF ; Interrupt enable
+ rIE = 0xFFFF
+
+ .VBL_IFLAG = 0x01
+ .LCD_IFLAG = 0x02
+ .TIM_IFLAG = 0x04
+ .SIO_IFLAG = 0x08
+ .JOY_IFLAG = 0x10
+
+ IEF_HILO = 0b00010000 ; Transition from High to Low of Pin number P10-P13
+ IEF_SERIAL = 0b00001000 ; Serial I/O transfer end
+ IEF_TIMER = 0b00000100 ; Timer Overflow
+ IEF_STAT = 0b00000010 ; STAT
+ IEF_VBLANK = 0b00000001 ; V-Blank
+
+ ;; Flags common to multiple sound channels
+
+ AUDLEN_DUTY_12_5 = 0b00000000 ; 12.5%
+ AUDLEN_DUTY_25 = 0b01000000 ; 25%
+ AUDLEN_DUTY_50 = 0b10000000 ; 50%
+ AUDLEN_DUTY_75 = 0b11000000 ; 75%
+
+ AUDENV_UP = 0b00001000
+ AUDENV_DOWN = 0b00000000
+
+ AUDHIGH_RESTART = 0b10000000
+ AUDHIGH_LENGTH_ON = 0b01000000
+ AUDHIGH_LENGTH_OFF = 0b00000000
+
+ ;; OAM related constants
+
+ OAM_COUNT = 40 ; number of OAM entries in OAM RAM
+
+ OAMF_PRI = 0b10000000 ; Priority
+ OAMF_YFLIP = 0b01000000 ; Y flip
+ OAMF_XFLIP = 0b00100000 ; X flip
+ OAMF_PAL0 = 0b00000000 ; Palette number; 0,1 (DMG)
+ OAMF_PAL1 = 0b00010000 ; Palette number; 0,1 (DMG)
+ OAMF_BANK0 = 0b00000000 ; Bank number; 0,1 (GBC)
+ OAMF_BANK1 = 0b00001000 ; Bank number; 0,1 (GBC)
+
+ OAMF_PALMASK = 0b00000111 ; Palette (GBC)
+
+ OAMB_PRI = 7 ; Priority
+ OAMB_YFLIP = 6 ; Y flip
+ OAMB_XFLIP = 5 ; X flip
+ OAMB_PAL1 = 4 ; Palette number; 0,1 (DMG)
+ OAMB_BANK1 = 3 ; Bank number; 0,1 (GBC)
+
+ ;; SGB packets
+ .PAL_01 = 0x00
+ .PAL_23 = 0x01
+ .PAL_03 = 0x02
+ .PAL_12 = 0x03
+ .ATTR_BLK = 0x04
+ .ATTR_LIN = 0x05
+ .ATTR_DIV = 0x06
+ .ATTR_CHR = 0x07
+ .SOUND = 0x08
+ .SOU_TRN = 0x09
+ .PAL_SET = 0x0A
+ .PAL_TRN = 0x0B
+ .ATRC_EN = 0x0C
+ .TEST_EN = 0x0D
+ .ICON_EN = 0x0E
+ .DATA_SND = 0x0F
+ .DATA_TRN = 0x10
+ .MLT_REQ = 0x11
+ .JUMP = 0x12
+ .CHR_TRN = 0x13
+ .PCT_TRN = 0x14
+ .ATTR_TRN = 0x15
+ .ATTR_SET = 0x16
+ .MASK_EN = 0x17
+ .OBJ_TRN = 0x18
+
+ ;; CPU detection
+ .DMG_TYPE = 0x01 ; Original GB or Super GB
+ .MGB_TYPE = 0xFF ; Pocket GB or Super GB 2
+ .CGB_TYPE = 0x11 ; Color GB
+
+ ;; GBDK library screen modes
+
+ .G_MODE = 0x01 ; Graphic mode
+ .T_MODE = 0x02 ; Text mode (bit 2)
+ .T_MODE_OUT = 0x02 ; Text mode output only
+ .T_MODE_INOUT = 0x03 ; Text mode with input
+ .M_NO_SCROLL = 0x04 ; Disables scrolling of the screen in text mode
+ .M_NO_INTERP = 0x08 ; Disables special character interpretation
+
+ ;; Status codes for IO
+ .IO_IDLE = 0x00
+ .IO_SENDING = 0x01
+ .IO_RECEIVING = 0x02
+ .IO_ERROR = 0x04
+
+ ;; Type of IO data
+ .DT_IDLE = 0x66
+ .DT_RECEIVING = 0x55
+
+ ;; Table of routines for modes
+ .MODE_TABLE = 0x01E0
+
+ ;; C related
+ ;; Overheap of a banked call. Used for parameters
+ ;; = ret + real ret + bank
+
+ .if .NEAR_CALLS
+ .BANKOV = 2
+
+ .else
+ .BANKOV = 6
+
+ .endif
+
+ .globl __current_bank
+ .globl __shadow_OAM_base
+
+ ;; Global variables
+ .globl .mode
+
+ .globl __cpu
+ .globl __is_GBA
+
+ ;; Global routines
+; .globl .set_mode ;; don't link mode.o by default
+
+ .globl .reset
+
+ .globl .display_off
+
+ .globl .wait_vbl_done
+
+ ;; Interrupt routines
+ .globl .add_VBL
+; .globl .add_LCD ;; don't link LCD.o by default
+; .globl .add_TIM ;; don't link TIM.o by default
+; .globl .add_SIO ;; don't link serial.o by default
+; .globl .add_JOY ;; don't link JOY.o by default
+
+ ;; Symbols defined at link time
+ .globl .STACK
+ .globl _shadow_OAM
+ .globl .refresh_OAM
+
+ ;; Main user routine
+ .globl _main
+
+ ;; Macro definitions
+
+.macro WAIT_STAT ?lbl
+lbl: LDH A, (.STAT)
+ AND #STATF_BUSY ; Check if in LCD modes 0 or 1
+ JR NZ, lbl
+.endm
+
+.macro ADD_A_REG16 regH regL
+ ADD regL
+ LD regL, A
+ ADC regH
+ SUB regL
+ LD regH, A
+.endm
+
+.macro SIGNED_ADD_A_REG16 regH regL ?lbl
+ ; If A is negative, we need to subtract 1 from upper byte of 16-bit value
+ BIT 7, A ; set z if a signed bit is 0
+ JR Z, lbl ; if z is set jump to positive
+ dec regH ; if negative decrement upper byte
+lbl:
+ ADD_A_REG16 regH, regL
+.endm
+
+.macro SIGNED_SUB_A_REG16 regH regL ?lbl
+ ; negate A then add to 16-bit value
+ CPL
+ INC A
+ SIGNED_ADD_A_REG16 regH, regL
+.endm
+
+.macro MUL_DE_BY_A_RET_HL ?lbl1 ?lbl2
+ ; Multiply DE by A, return result in HL; preserves: BC
+ LD HL, #0
+lbl1:
+ SRL A
+ JR NC, lbl2
+ ADD HL, DE
+lbl2:
+ SLA E
+ RL D
+ OR A
+ JR NZ, lbl1
+.endm
+
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/gb/sfr.s b/gbdk/gbdk-lib/libc/targets/sm83/gb/sfr.s
new file mode 100644
index 00000000..64febc7a
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/gb/sfr.s
@@ -0,0 +1,111 @@
+__VRAM = 0x8000
+__VRAM8000 = 0x8000
+__VRAM8800 = 0x8800
+__VRAM9000 = 0x9000
+__SCRN0 = 0x9800
+__SCRN1 = 0x9C00
+__SRAM = 0xA000
+__RAM = 0xC000
+__RAMBANK = 0xD000
+__OAMRAM = 0xFE00
+__IO = 0xFF00
+__AUD3WAVERAM = 0xFF30
+__HRAM = 0xFF80
+
+.globl __VRAM, __VRAM8000, __VRAM8800, __VRAM9000, __SCRN0, __SCRN1, __SRAM, __RAM, __RAMBANK, __OAMRAM, __IO, __AUD3WAVERAM, __HRAM
+
+_rRAMG = 0x0000
+_rROMB0 = 0x2000
+_rROMB1 = 0x3000
+_rRAMB = 0x4000
+
+.globl _rRAMG, _rROMB0, _rROMB1, _rRAMB
+
+_P1_REG = 0xFF00 ; Joystick: 1.1.P15.P14.P13.P12.P11.P10
+_SB_REG = 0xFF01 ; Serial IO data buffer
+_SC_REG = 0xFF02 ; Serial IO control register
+_DIV_REG = 0xFF04 ; Divider register
+_TIMA_REG = 0xFF05 ; Timer counter
+_TMA_REG = 0xFF06 ; Timer modulo
+_TAC_REG = 0xFF07 ; Timer control
+_IF_REG = 0xFF0F ; Interrupt flags: 0.0.0.JOY.SIO.TIM.LCD.VBL
+_NR10_REG = 0xFF10 ; Sound register
+_NR11_REG = 0xFF11 ; Sound register
+_NR12_REG = 0xFF12 ; Sound register
+_NR13_REG = 0xFF13 ; Sound register
+_NR14_REG = 0xFF14 ; Sound register
+_NR21_REG = 0xFF16 ; Sound register
+_NR22_REG = 0xFF17 ; Sound register
+_NR23_REG = 0xFF18 ; Sound register
+_NR24_REG = 0xFF19 ; Sound register
+_NR30_REG = 0xFF1A ; Sound register
+_NR31_REG = 0xFF1B ; Sound register
+_NR32_REG = 0xFF1C ; Sound register
+_NR33_REG = 0xFF1D ; Sound register
+_NR34_REG = 0xFF1E ; Sound register
+_NR41_REG = 0xFF20 ; Sound register
+_NR42_REG = 0xFF21 ; Sound register
+_NR43_REG = 0xFF22 ; Sound register
+_NR44_REG = 0xFF23 ; Sound register
+_NR50_REG = 0xFF24 ; Sound register
+_NR51_REG = 0xFF25 ; Sound register
+_NR52_REG = 0xFF26 ; Sound register
+_PCM_SAMPLE = 0xFF30 ; PCM wave pattern
+_AUD3WAVE = 0xFF30 ; PCM wave pattern
+_LCDC_REG = 0xFF40 ; LCD control
+_STAT_REG = 0xFF41 ; LCD status
+_SCY_REG = 0xFF42 ; Scroll Y
+_SCX_REG = 0xFF43 ; Scroll X
+_LY_REG = 0xFF44 ; LCDC Y-coordinate
+_LYC_REG = 0xFF45 ; LY compare
+_DMA_REG = 0xFF46 ; DMA transfer
+_BGP_REG = 0xFF47 ; BG palette data
+_OBP0_REG = 0xFF48 ; OBJ palette 0 data
+_OBP1_REG = 0xFF49 ; OBJ palette 1 data
+_WY_REG = 0xFF4A ; Window Y coordinate
+_WX_REG = 0xFF4B ; Window X coordinate
+_KEY1_REG = 0xFF4D ; CPU speed
+_VBK_REG = 0xFF4F ; VRAM bank
+_HDMA1_REG = 0xFF51 ; DMA control 1
+_HDMA2_REG = 0xFF52 ; DMA control 2
+_HDMA3_REG = 0xFF53 ; DMA control 3
+_HDMA4_REG = 0xFF54 ; DMA control 4
+_HDMA5_REG = 0xFF55 ; DMA control 5
+_RP_REG = 0xFF56 ; IR port
+_BCPS_REG = 0xFF68 ; BG color palette specification
+_BCPD_REG = 0xFF69 ; BG color palette data
+_OCPS_REG = 0xFF6A ; OBJ color palette specification
+_OCPD_REG = 0xFF6B ; OBJ color palette data
+_SVBK_REG = 0xFF70 ; WRAM bank
+_PCM12_REG = 0xFF76 ; Sound channel 1&2 PCM amplitude (R)
+_PCM34_REG = 0xFF77 ; Sound channel 3&4 PCM amplitude (R)
+_IE_REG = 0xFFFF ; Interrupt enable
+
+.globl _P1_REG
+.globl _SB_REG, _SC_REG
+.globl _DIV_REG
+.globl _TIMA_REG, _TMA_REG, _TAC_REG
+.globl _IF_REG
+.globl _NR10_REG, _NR11_REG, _NR12_REG, _NR13_REG, _NR14_REG
+.globl _NR21_REG, _NR22_REG, _NR23_REG, _NR24_REG
+.globl _NR30_REG, _NR31_REG, _NR32_REG, _NR33_REG, _NR34_REG
+.globl _NR41_REG, _NR42_REG, _NR43_REG, _NR44_REG
+.globl _NR50_REG, _NR51_REG, _NR52_REG
+.globl _PCM_SAMPLE, _AUD3WAVE
+.globl _LCDC_REG
+.globl _STAT_REG
+.globl _SCY_REG, _SCX_REG
+.globl _LY_REG, _LYC_REG
+.globl _DMA_REG
+.globl _BGP_REG
+.globl _OBP0_REG, _OBP1_REG
+.globl _WY_REG, _WX_REG
+.globl _KEY1_REG
+.globl _VBK_REG
+.globl _HDMA1_REG, _HDMA2_REG, _HDMA3_REG, _HDMA4_REG, _HDMA5_REG
+.globl _RP_REG
+.globl _BCPS_REG, _BCPD_REG
+.globl _OCPS_REG, _OCPD_REG
+.globl _SVBK_REG
+.globl _PCM12_REG, _PCM34_REG
+.globl _IE_REG \ No newline at end of file
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/gb_decompress.s b/gbdk/gbdk-lib/libc/targets/sm83/gb_decompress.s
new file mode 100644
index 00000000..72fd7aef
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/gb_decompress.s
@@ -0,0 +1,108 @@
+; GB-Deompress routine
+; Compatible with GBTD
+
+ .include "global.s"
+
+ .title "GB Decompress"
+ .module GBDecompress
+
+ .area _CODE
+
+_gb_decompress::
+ lda hl,5(SP)
+ ld a,(hl-)
+ ld d,a
+ ld a,(hl-)
+ ld e,a
+ ld a,(hl-)
+ ld l,(hl)
+ ld h,a
+
+; hl = source; de = dest
+gb_decompress::
+ push bc
+ push de
+1$:
+ ld a,(hl+) ; load command
+ or a
+ jr z,9$ ; exit, if last byte
+ bit 7,a
+ jr nz,5$ ; string functions
+ bit 6,a
+ jr nz,3$
+ ; RLE byte
+ and #63 ; calc counter
+ inc a
+ ld b,a
+ ld a,(hl+)
+2$:
+ ld (de),a
+ inc de
+ dec b
+ jr nz,2$
+ jr 1$ ; next command
+3$: ; RLE word
+ and #63
+ inc a
+ ld b,(hl) ; load word into bc
+ inc hl
+ ld c,(hl)
+ inc hl
+4$:
+ push af
+ ld a,b ; store word
+ ld (de),a
+ inc de
+ ld a,c
+ ld (de),a
+ inc de
+ pop af
+ dec a
+ jr nz,4$
+ jr 1$ ; next command
+5$:
+ bit 6,a
+ jr nz,7$
+ ; string repeat
+ and a,#63
+ inc a
+ push hl
+ ld c,(hl)
+ inc hl
+ ld b,(hl)
+ ld h,d
+ ld l,e
+ add hl,bc
+ ld b,a
+6$:
+ ld a,(hl+)
+ ld (de),a
+ inc de
+ dec b
+ jr nz,6$
+ pop hl
+ inc hl
+ inc hl
+ jr 1$ ; next command
+7$: ; string copy
+ and #63
+ inc a
+ ld b,a
+8$:
+ ld a,(hl+)
+ ld (de),a
+ inc de
+ dec b
+ jr nz,8$
+ jr 1$ ; next command
+9$:
+ pop hl
+ ld a, e
+ sub l
+ ld e, a
+ ld a, d
+ sbc h
+ ld d, a
+ pop bc
+
+ ret
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/gb_decompress_tiles.s b/gbdk/gbdk-lib/libc/targets/sm83/gb_decompress_tiles.s
new file mode 100644
index 00000000..63bb79a5
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/gb_decompress_tiles.s
@@ -0,0 +1,165 @@
+; GB-Decompress tiledata directly to VRAM
+; Compatible with GBTD
+
+ .include "global.s"
+
+ .title "GB Decompress"
+ .module GBDecompress
+
+.macro WRAP_VRAM regH, ?loc
+ bit 3, regH
+ jr z, loc
+ res 4, regH
+loc:
+.endm
+
+.macro UNWRAP_VRAM regH, ?loc
+ bit 3, regH
+ jr nz, loc
+ set 4, regH
+loc:
+.endm
+
+
+ .area _CODE
+
+_gb_decompress_bkg_data::
+_gb_decompress_win_data::
+ ld d, #0x90
+ ldh a, (.LCDC)
+ and #LCDCF_BG8000
+ jr z, .load_params
+_gb_decompress_sprite_data::
+ ld d, #0x80
+
+.load_params:
+ ldhl sp, #2
+ ld a, (hl+)
+
+ ; Compute dest ptr
+ swap a ; *16 (size of a tile)
+ ld e, a
+ and #0x0F ; Get high bits
+ add d ; Add base offset of target tile "block"
+ ld d, a
+ ld a, e
+ and #0xF0 ; Get low bits only
+ ld e, a
+ WRAP_VRAM d
+
+ ld a, (hl+)
+ ld h, (hl)
+ ld l, a
+
+; hl = source; de = dest
+gb_decompress_vram::
+ push bc
+ push de
+1$:
+ ld a,(hl+) ; load command
+ or a
+ jp z,9$ ; exit, if last byte
+ bit 7,a
+ jr nz,5$ ; string functions
+ bit 6,a
+ jr nz,3$
+ ; RLE byte
+ and #63 ; calc counter
+ inc a
+ ld c,a
+ ld a,(hl+)
+ ld b,a
+2$:
+ WAIT_STAT
+ ld a,b
+ ld (de),a
+ inc de
+ WRAP_VRAM d
+ dec c
+ jr nz,2$
+ jr 1$ ; next command
+
+3$: ; RLE word
+ and #63
+ inc a
+ ld c, a
+ ld a,(hl+)
+ ld b, a
+4$:
+ WAIT_STAT
+ ld a,b ; store word
+ ld (de),a
+ inc de
+ WRAP_VRAM d
+ WAIT_STAT
+ ld a,(hl)
+ ld (de),a
+ inc de
+ WRAP_VRAM d
+ dec c
+ jr nz,4$
+ inc hl
+ jr 1$ ; next command
+
+5$:
+ bit 6,a
+ jr nz,7$
+
+6$: ; string repeat
+ and a,#63
+ inc a
+ push hl
+
+ ld c,(hl)
+ inc hl
+ ld b,(hl)
+
+ ldhl sp,#3
+ bit 4,(hl) ; check start address was above 0x9000
+ jr z, 11$
+
+ ld h,d
+ ld l,e
+ add hl,bc
+ UNWRAP_VRAM h
+ jr 12$
+11$:
+ ld h,d
+ ld l,e
+ add hl,bc
+12$:
+ ld c,a
+
+14$:
+ WAIT_STAT
+ ld a,(hl+)
+ ld (de),a
+ WRAP_VRAM h
+ inc de
+ WRAP_VRAM d
+ dec c
+ jr nz, 14$
+
+ pop hl
+ inc hl
+ inc hl
+ jp 1$ ; next command
+
+7$: ; string copy
+ and #63
+ inc a
+ ld c,a
+15$:
+ WAIT_STAT
+ ld a,(hl+)
+ ld (de),a
+ inc de
+ WRAP_VRAM d
+ dec c
+ jr nz, 15$
+
+ jp 1$ ; next command
+9$:
+ pop de
+ pop bc
+ ret
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/get_addr.s b/gbdk/gbdk-lib/libc/targets/sm83/get_addr.s
new file mode 100644
index 00000000..c234ee4a
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/get_addr.s
@@ -0,0 +1,39 @@
+.include "global.s"
+
+.area _CODE
+
+_get_win_xy_addr::
+ ldh a, (.LCDC)
+ and #LCDCF_WIN9C00
+ jr z, .is98
+ jr .is9c
+
+_get_bkg_xy_addr::
+ ldh a, (.LCDC)
+ and #LCDCF_BG9C00
+ jr nz, .is9c
+.is98:
+ ld d, #0x98 ; DE = origin
+ jr .calculate_ofs
+.is9c:
+ ld d, #0x9C ; DE = origin
+
+.calculate_ofs:
+ ldhl sp, #3
+
+ ld a, (hl-)
+ ld l, (hl)
+
+ ld e, d
+ swap a
+ rlca
+ ld h, a
+ and #0x03
+ add e
+ ld d, a
+ ld a, #0xE0
+ and h
+ add l
+ ld e, a ; dest DE = BASE + 0x20 * Y + X
+
+ ret
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/get_bk_t.s b/gbdk/gbdk-lib/libc/targets/sm83/get_bk_t.s
new file mode 100644
index 00000000..2e80eb21
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/get_bk_t.s
@@ -0,0 +1,24 @@
+ .include "global.s"
+
+ .area _HOME
+
+_get_bkg_tiles::
+ PUSH BC
+
+ LDA HL,4(SP) ; Skip return address and registers
+ LD A,(HL+) ; D = x
+ LD D, A
+ LD E,(HL) ; E = y
+ LDA HL,9(SP)
+ LD A,(HL-) ; BC = tiles
+ LD B, A
+ LD A,(HL-)
+ LD C, A
+ LD A,(HL-) ; A = h
+ LD H,(HL) ; H = w
+ LD L,A ; L = h
+
+ CALL .get_xy_btt
+
+ POP BC
+ RET
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/get_data.s b/gbdk/gbdk-lib/libc/targets/sm83/get_data.s
new file mode 100644
index 00000000..6a62c606
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/get_data.s
@@ -0,0 +1,120 @@
+ .include "global.s"
+
+ .globl .copy_vram
+
+ .area _HOME
+
+_get_bkg_data::
+_get_win_data::
+ LDH A,(.LCDC)
+ AND #LCDCF_BG8000
+ JP NZ,_get_sprite_data
+
+ PUSH BC
+
+ LDA HL,7(SP) ; Skip return address and registers
+ LD A,(HL-) ; BC = data
+ LD B, A
+ LD A,(HL-)
+ LD C, A
+ LD A,(HL-) ; E = nb_tiles
+ LD E, A
+ LD L,(HL) ; L = first_tile
+ PUSH HL
+
+ XOR A
+ OR E ; Is nb_tiles == 0?
+ JR NZ,1$
+ LD DE,#0x1000 ; DE = nb_tiles = 256
+ JR 2$
+1$:
+ LD H,#0x00 ; HL = nb_tiles
+ LD L,E
+ ADD HL,HL ; HL *= 16
+ ADD HL,HL
+ ADD HL,HL
+ ADD HL,HL
+ LD D,H ; DE = nb_tiles
+ LD E,L
+2$:
+ POP HL ; HL = first_tile
+ LD A,L
+ RLCA ; Sign extend (patterns have signed numbers)
+ SBC A
+ LD H,A
+ ADD HL,HL ; HL *= 16
+ ADD HL,HL
+ ADD HL,HL
+ ADD HL,HL
+
+ PUSH BC
+ LD BC,#0x9000
+ ADD HL,BC
+ POP BC
+
+3$: ; Special version of '.copy_vram'
+ BIT 3,H ; Bigger than 0x9800
+ JR Z,4$
+ BIT 4,H
+ JR Z,4$
+ RES 4,H ; Switch to 0x8800
+4$:
+ WAIT_STAT
+
+ LD A,(HL+)
+ LD (BC),A
+ INC BC
+ DEC DE
+ LD A,D
+ OR E
+ JR NZ,3$
+
+ POP BC
+ RET
+
+_get_sprite_data::
+ PUSH BC
+
+ LDA HL,7(SP) ; Skip return address and registers
+ LD A,(HL-) ; BC = data
+ LD B, A
+ LD A,(HL-)
+ LD C, A
+ LD A,(HL-) ; E = nb_tiles
+ LD E, A
+ LD L,(HL) ; L = first_tile
+ PUSH HL
+
+ XOR A
+ OR E ; Is nb_tiles == 0?
+ JR NZ,1$
+ LD DE,#0x1000 ; DE = nb_tiles = 256
+ JR 2$
+1$:
+ LD H,#0x00 ; HL = nb_tiles
+ LD L,E
+ ADD HL,HL ; HL *= 16
+ ADD HL,HL
+ ADD HL,HL
+ ADD HL,HL
+ LD D,H ; DE = nb_tiles
+ LD E,L
+2$:
+ POP HL ; HL = first_tile
+ LD L,A
+ ADD HL,HL ; HL *= 16
+ ADD HL,HL
+ ADD HL,HL
+ ADD HL,HL
+
+ PUSH BC
+ LD BC,#0x8000
+ ADD HL,BC
+ LD B,H
+ LD C,L
+ POP HL
+
+ CALL .copy_vram
+
+ POP BC
+ RET
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/get_t.s b/gbdk/gbdk-lib/libc/targets/sm83/get_t.s
new file mode 100644
index 00000000..455f07be
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/get_t.s
@@ -0,0 +1,26 @@
+ .include "global.s"
+
+ .area _HOME
+
+; void get_tiles(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t *vram_addr, uint8_t *tiles);
+
+_get_tiles::
+ LDHL SP, #5
+ LD A, (HL-)
+ LD E, A
+ LD A, (HL-)
+ LD D, A
+ PUSH DE
+ LD A, (HL-)
+ LD E, A
+ LD D, (HL)
+ LDHL SP, #11
+ LD A, (HL-)
+ LD B, A
+ LD A, (HL-)
+ LD C, A
+ LD A, (HL-)
+ LD L, (HL)
+ LD H, A
+
+ JP .get_xy_tt ;; Store background tile table into (BC) at XY = DE, size WH on stack, from vram from address (HL)
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/get_tile.s b/gbdk/gbdk-lib/libc/targets/sm83/get_tile.s
new file mode 100644
index 00000000..1f0b5ce8
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/get_tile.s
@@ -0,0 +1,51 @@
+.include "global.s"
+
+.area _CODE
+
+_get_vram_byte::
+ ldhl sp,#2
+ ld a,(hl+)
+ ld h,(hl)
+ ld l,a
+ WAIT_STAT
+ ld e,(hl)
+ ret
+
+_get_win_tile_xy::
+ ldh a,(.LCDC)
+ and #LCDCF_WIN9C00
+ jr z,.is98
+ jr .is9c
+_get_bkg_tile_xy::
+ ldh a,(.LCDC)
+ and #LCDCF_BG9C00
+ jr nz,.is9c
+.is98:
+ ld d,#0x98 ; DE = origin
+ jr .get_tile_xy
+.is9c:
+ ld d,#0x9C ; DE = origin
+
+.get_tile_xy:
+ ldhl sp,#3
+
+ ld a, (hl-)
+ ld l, (hl)
+
+ ld e, d
+ swap a
+ rlca
+ ld h, a
+ and #0x03
+ add e
+ ld d, a
+ ld a, #0xE0
+ and h
+ add l
+ ld l, a
+ ld h, d ; dest DE = BASE + 0x20 * Y + X
+
+ WAIT_STAT
+ ld e, (hl)
+
+ ret
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/get_wi_t.s b/gbdk/gbdk-lib/libc/targets/sm83/get_wi_t.s
new file mode 100644
index 00000000..a17fd459
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/get_wi_t.s
@@ -0,0 +1,26 @@
+ .include "global.s"
+
+ .globl .get_xy_wtt
+
+ .area _HOME
+
+_get_win_tiles::
+ PUSH BC
+
+ LDA HL,4(SP) ; Skip return address and registers
+ LD A,(HL+) ; D = x
+ LD D, A
+ LD E,(HL) ; E = y
+ LDA HL,9(SP)
+ LD A,(HL-) ; BC = tiles
+ LD B, A
+ LD A,(HL-)
+ LD C, A
+ LD A,(HL-) ; A = h
+ LD H,(HL) ; H = w
+ LD L,A ; L = h
+
+ CALL .get_xy_wtt
+
+ POP BC
+ RET
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/get_xy_t.s b/gbdk/gbdk-lib/libc/targets/sm83/get_xy_t.s
new file mode 100644
index 00000000..29739a19
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/get_xy_t.s
@@ -0,0 +1,86 @@
+ .include "global.s"
+
+ .area _HOME
+
+ ;; Store window tile table into (BC) at xy = DE of size WH = HL
+.get_xy_wtt::
+ PUSH HL ; Store WH
+ LDH A,(.LCDC)
+ AND #LCDCF_WIN9C00
+ JR Z,.is98
+ JR .is9c
+ ;; Store background tile table into (BC) at XY = DE of size WH = HL
+.get_xy_btt::
+ PUSH HL ; Store WH
+ LDH A,(.LCDC)
+ AND #LCDCF_BG9C00
+ JR NZ,.is9c
+.is98:
+ LD HL,#0x9800
+ JR .get_xy_tt
+.is9c:
+ LD HL,#0x9C00
+
+ ;; Store background tile table into (BC) at XY = DE, size WH on stack, from vram from address (HL)
+.get_xy_tt::
+ PUSH BC ; Store source
+
+ SWAP E
+ RLC E
+ LD A,E
+ AND #0x03
+ ADD H
+ LD B,A
+ LD A,#0xE0
+ AND E
+ ADD D
+ LD C,A ; dest BC = HL + 0x20 * Y + X
+
+ POP HL ; HL = source
+ POP DE ; DE = WH
+ PUSH DE ; store WH
+ PUSH BC ; store dest
+
+3$: ; Copy W tiles
+
+ WAIT_STAT
+ LD A, (BC)
+ LD (HL+), A
+
+ LD A, C ; inc dest and wrap around
+ AND #0xE0
+ LD E, A
+ LD A, C
+ INC A
+ AND #0x1F
+ OR E
+ LD C, A
+
+ DEC D
+ JR NZ, 3$
+
+ POP BC
+ POP DE
+
+ DEC E
+ RET Z
+
+ PUSH DE
+
+ LD A, B ; next row and wrap around
+ AND #0xFC
+ LD E, A ; save high bits
+
+ LD A,#0x20
+
+ ADD C
+ LD C, A
+ ADC B
+ SUB C
+ AND #0x03
+ OR E ; restore high bits
+ LD B, A
+
+ PUSH BC
+
+ JR 3$
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/gprint.c b/gbdk/gbdk-lib/libc/targets/sm83/gprint.c
new file mode 100644
index 00000000..556dbd24
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/gprint.c
@@ -0,0 +1,7 @@
+#include <gb/drawing.h>
+
+void gprint(char *str) NONBANKED
+{
+ while(*str)
+ wrtchr(*str++);
+}
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/gprintf.c b/gbdk/gbdk-lib/libc/targets/sm83/gprintf.c
new file mode 100644
index 00000000..560ad396
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/gprintf.c
@@ -0,0 +1,86 @@
+#include <stdint.h>
+#include <stdarg.h>
+#include <gb/drawing.h>
+
+int8_t gprintf(char *fmt, ...) NONBANKED
+{
+ va_list ap;
+ int8_t nb = 0;
+
+ va_start(ap, fmt);
+ for(; *fmt; fmt++)
+ if(*fmt == '%') {
+ switch(*++fmt) {
+ case 'c': {
+ /* char */
+ char c = va_arg(ap, char);
+ wrtchr(c);
+ break;
+ }
+ case 'd': {
+ /* decimal int */
+ int8_t b = va_arg(ap, int8_t);
+ gprintn(b, 10, SIGNED);
+ break;
+ }
+ case 'u': {
+ /* unsigned int */
+ int8_t b = (int8_t)va_arg(ap, int);
+ gprintn(b, 10, UNSIGNED);
+ break;
+ }
+ case 'o': {
+ /* octal int */
+ int8_t b = va_arg(ap, int8_t);
+ gprintn(b, 8, UNSIGNED);
+ break;
+ }
+ case 'x': {
+ /* hexadecimal int */
+ int8_t b = va_arg(ap, int8_t);
+ gprintn(b, 16, UNSIGNED);
+ break;
+ }
+ case 's': {
+ /* string */
+ char *s = va_arg(ap, char *);
+ gprint(s);
+ break;
+ }
+#if 0
+ case 'l':
+ /* long */
+ switch(*++fmt) {
+ case 'd':
+ /* decimal long */
+ gprintln(va_arg(ap, int16_t), 10, SIGNED);
+ break;
+ case 'u':
+ /* unsigned long */
+ gprintln(va_arg(ap, int16_t), 10, UNSIGNED);
+ break;
+ case 'o':
+ /* octal long */
+ gprintln(va_arg(ap, int16_t), 8, UNSIGNED);
+ break;
+ case 'x':
+ /* hexadecimal long */
+ gprintln(va_arg(ap, int16_t), 16, UNSIGNED);
+ break;
+ }
+ break;
+#endif
+ case '%':
+ /* % */
+ wrtchr(*fmt);
+ break;
+ default:
+ return -1;
+ }
+ nb++;
+ } else
+ wrtchr(*fmt);
+ va_end(ap);
+
+ return nb;
+}
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/gprintln.c b/gbdk/gbdk-lib/libc/targets/sm83/gprintln.c
new file mode 100644
index 00000000..a6ed1459
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/gprintln.c
@@ -0,0 +1,19 @@
+#include <stdint.h>
+#include <gb/drawing.h>
+
+/* Print a long number in any radix */
+
+extern char *digits;
+
+void gprintln(int16_t number, int8_t radix, int8_t signed_value) NONBANKED
+{
+ uint16_t l;
+
+ if(number < 0 && signed_value) {
+ wrtchr('-');
+ number = -number;
+ }
+ if((l = (uint16_t)number / (uint16_t)radix) != 0)
+ gprintln(l, radix, UNSIGNED);
+ wrtchr(digits[(uint16_t)number % (uint16_t)radix]);
+}
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/gprintn.c b/gbdk/gbdk-lib/libc/targets/sm83/gprintn.c
new file mode 100644
index 00000000..cee919b5
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/gprintn.c
@@ -0,0 +1,19 @@
+#include <stdint.h>
+#include <gb/drawing.h>
+
+/* Print a number in any radix */
+
+extern char *digits;
+
+void gprintn(int8_t number, int8_t radix, int8_t signed_value) NONBANKED
+{
+ uint8_t i;
+
+ if(number < 0 && signed_value) {
+ wrtchr('-');
+ number = -number;
+ }
+ if((i = (uint8_t)number / (uint8_t)radix) != 0)
+ gprintn(i, radix, UNSIGNED);
+ wrtchr(digits[(uint8_t)number % (uint8_t)radix]);
+}
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/heap.s b/gbdk/gbdk-lib/libc/targets/sm83/heap.s
new file mode 100644
index 00000000..991df234
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/heap.s
@@ -0,0 +1,44 @@
+;--------------------------------------------------------------------------
+; heap.s
+;
+; Copyright (C) 2001, Michael Hope
+;
+; This library is free software; you can redistribute it and/or modify it
+; under the terms of the GNU General Public License as published by the
+; Free Software Foundation; either version 2, or (at your option) any
+; later version.
+;
+; This library is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this library; see the file COPYING. If not, write to the
+; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+; MA 02110-1301, USA.
+;
+; As a special exception, if you link this library with other files,
+; some of which are compiled with SDCC, to produce an executable,
+; this library does not by itself cause the resulting executable to
+; be covered by the GNU General Public License. This exception does
+; not however invalidate any other reasons why the executable file
+; might be covered by the GNU General Public License.
+;--------------------------------------------------------------------------
+
+; Just stubs - not copyrightable
+
+ ;; Stubs that hook the heap in
+ .globl ___sdcc_heap_init
+
+ .area _GSINIT
+ call ___sdcc_heap_init
+
+ .area _HEAP
+___sdcc_heap::
+ ;; For now just allocate 2k of heap.
+ .ds 2047
+
+ .area _HEAP_END
+___sdcc_heap_end::
+ .ds 1
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/hiramcpy.s b/gbdk/gbdk-lib/libc/targets/sm83/hiramcpy.s
new file mode 100644
index 00000000..c43b1b07
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/hiramcpy.s
@@ -0,0 +1,34 @@
+ .include "global.s"
+
+ .area _HOME
+
+_hiramcpy::
+ LDA HL,2(SP) ; Skip return address and registers
+ LD E,(HL) ; E = dst
+ LDA HL,5(SP)
+ LD A,(HL-)
+ LD D, A ; D = n
+ LD A,(HL-) ; HL = src
+ LD L,(HL)
+ LD H,A
+
+ ;; Copy memory zone to HIRAM
+ ;;
+ ;; Entry conditions
+ ;; E = destination
+ ;; D = length
+ ;; HL = source
+ ;;
+ ;; Preserves: BC
+.hiramcpy::
+ LD A,E
+ LD E,C
+ LD C,A
+1$:
+ LD A,(HL+)
+ LDH (C),A
+ INC C
+ DEC D
+ JR NZ,1$
+ LD C,E
+ RET
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/init_tt.s b/gbdk/gbdk-lib/libc/targets/sm83/init_tt.s
new file mode 100644
index 00000000..ccc5a395
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/init_tt.s
@@ -0,0 +1,52 @@
+ .include "global.s"
+
+ .area _HOME
+
+ ;; Initialize window tile table with B
+.init_wtt::
+ LDH A,(.LCDC)
+ AND #LCDCF_WIN9C00
+ JR Z,.is98
+ JR .is9c
+ ;; Initialize background tile table with B
+.init_btt::
+ LDH A,(.LCDC)
+ AND #LCDCF_BG9C00
+ JR NZ,.is9c
+.is98:
+ LD HL,#0x9800 ; HL = origin
+ JR .init_tt
+.is9c:
+ LD HL,#0x9C00 ; HL = origin
+
+.init_tt::
+ LD DE,#0x0400 ; One whole GB Screen
+
+.init_vram::
+ SRL D
+ RR E
+ JR NC, 1$
+
+ WAIT_STAT
+ LD A, B
+ LD (HL+),A
+1$:
+ LD A, D
+ OR E
+ RET Z
+
+ INC D
+ INC E
+ JR 2$
+3$:
+ WAIT_STAT
+ LD A, B
+ LD (HL+),A
+ LD (HL+),A
+2$:
+ DEC E
+ JR NZ, 3$
+ DEC D
+ JR NZ, 3$
+
+ RET
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/init_vram.s b/gbdk/gbdk-lib/libc/targets/sm83/init_vram.s
new file mode 100644
index 00000000..bfe49ade
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/init_vram.s
@@ -0,0 +1,44 @@
+ .include "global.s"
+
+ .area _HOME
+
+ .globl .init_wtt, .init_btt, .init_vram
+
+
+ ;; Initialize window tile table
+ ;; void init_win(char c);
+_init_win::
+ PUSH BC
+ LDA HL, 4(SP)
+ LD B, (HL)
+ CALL .init_wtt
+ POP BC
+ RET
+
+ ;; Initialize background tile table
+ ;; void init_bkg(char c);
+_init_bkg::
+ PUSH BC
+ LDA HL, 4(SP)
+ LD B, (HL)
+ CALL .init_btt
+ POP BC
+ RET
+
+ ;; Fills the VRAM memory region s of size n with c
+ ;; void _vmemset (void *s, char c, size_t n);
+_vmemset::
+ PUSH BC
+ LDA HL, 8(SP)
+ LD A, (HL-)
+ LD D, A
+ LD A, (HL-)
+ LD E, A
+ LD A, (HL-)
+ LD B, A
+ LD A, (HL-)
+ LD L, (HL)
+ LD H, A
+ CALL .init_vram
+ POP BC
+ RET \ No newline at end of file
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/input.s b/gbdk/gbdk-lib/libc/targets/sm83/input.s
new file mode 100644
index 00000000..b282b908
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/input.s
@@ -0,0 +1,639 @@
+ .include "global.s"
+
+ ;; Note that while gets uses a pointer, the pointer had better
+ ;; be in non-banked RAM else bad things will happen.
+
+ .globl .copy_vram
+ .globl .set_xy_wtt
+ .globl .mv_sprite
+ .globl .set_sprite_prop
+ .globl .set_sprite_tile
+ .globl .jpad
+ .globl .padup
+
+ .MINMSPOSX = 0x02 ; In tiles
+ .MINMSPOSY = 0x0A
+ .MAXMSPOSX = 0x11
+ .MAXMSPOSY = 0x0F
+ .INIMSPOSX = .MINMSPOSX
+ .INIMSPOSY = .MINMSPOSY
+
+ .KBDWINPOSY = 0x08 ; In tiles
+ .KBDSIZE = 0x1006
+
+ .MSOFFSETX = 0x0C ; In pixels
+ .MSOFFSETY = 0x14
+
+ .MINACCEL = 0x0800
+ .MAXACCEL = 0x0100
+
+ .CR = 0x0A ; Unix
+; .CR = 0x0D ; Dos
+
+ .globl .tmode_out ; From 'output.s'
+ .globl .put_char
+ .globl .del_char
+ .globl .cury
+
+ .area _INPUT_HEADER (ABS)
+
+ .org .MODE_TABLE+4*.T_MODE_INOUT
+ JP .tmode_inout
+
+ .module Terminal
+
+ .area _DATA
+
+.msx: ; Mouse position
+ .ds 0x01
+.msy:
+ .ds 0x01
+.msacc: ; Mouse acceleration
+ .ds 0x02
+.msstate: ; Mouse state
+ .ds 0x01
+.mschanged: ; Did the mouse move?
+ .ds 0x01
+.string_len: ; Used length of input buffer
+ .ds 0x01
+
+ .area _HOME
+
+ ;; Enter text mode with input
+.tmode_inout::
+ DI ; Disable interrupts
+
+ ;; Turn the screen off
+ LDH A,(.LCDC)
+ AND #LCDCF_ON
+ JR Z,1$
+
+ ;; Turn the screen off
+ CALL .display_off
+1$:
+
+ LD A,(.mode)
+ AND #.T_MODE
+ CALL Z,.tmode_out
+
+ LD BC,#.tp1 ; Move pointer
+ LD HL,#0x8000
+ LD DE,#.endtp1-.tp1
+ CALL .copy_vram
+
+ LD A,#<.MINACCEL ; Acceleration
+ LD (.msacc),A
+ LD A,#>.MINACCEL
+ LD (.msacc+1),A
+
+ ;; Initialize window
+ LD BC,#.frame_tiles
+ LD DE,#0x140A ; 0x140A
+ LD HL,#0
+ CALL set_recoded_win_tiles
+
+ LD BC,#.kbdtable
+ LD DE,#.KBDSIZE
+ LD HL,#(0x20 * 2 + 2) ; X=2, Y=2
+ CALL set_recoded_win_tiles
+
+ LD A,#.MINWNDPOSX
+ LDH (.WX),A
+ LD A,#.MAXWNDPOSY ; Hide window
+ LDH (.WY),A
+
+ XOR A
+ ;; Initialize sprite
+ LD C,A ; Sprite 0x00
+ LD D,A ; Default sprite properties
+ CALL .set_sprite_prop
+ XOR A
+ LD C,A ; Sprite 0x00
+ LD D,A ; Tile 0x00
+ CALL .set_sprite_tile
+ LD A,#0b00101100
+ LDH (.OBP0),A
+
+ ;; Turn the screen on
+ LD A,#(LCDCF_ON | LCDCF_WIN9C00 | LCDCF_WINOFF | LCDCF_BG8800 | LCDCF_BG9800 | LCDCF_OBJ8 | LCDCF_OBJOFF | LCDCF_BGON)
+ LDH (.LCDC),A
+
+ LD A,#.T_MODE_INOUT
+ LD (.mode),A
+
+ EI ; Enable interrupts
+
+ RET
+
+set_recoded_win_tiles::
+ LDH A,(.LCDC)
+ AND #LCDCF_WIN9C00
+ JR Z,2$
+ LD A,#0x9C
+ JR 3$
+2$:
+ LD A,#0x98
+3$:
+ ADD H
+ LD H,A
+ PUSH DE
+ PUSH HL
+4$:
+ LD A,(BC)
+ INC BC
+ PUSH BC
+ PUSH HL
+
+ LD C,A
+ LD HL,#(font_current+1) ; font_current+sfont_handle_font
+ LD A,(HL+)
+ LD H,(HL)
+ LD L,A
+ LD A,(HL+)
+ AND #3
+ CP #2 ; FONT_NOENCODING
+ JR Z,5$
+ INC HL
+ LD B,#0
+ ADD HL,BC
+ LD C,(HL)
+5$:
+ POP HL
+
+ WAIT_STAT
+ LD A,C
+ LD (HL+),A
+
+ POP BC
+
+ DEC D
+ JR NZ,4$
+
+ POP HL
+ POP DE
+
+ LD A,L
+ ADD #0x20
+ LD L,A
+ ADC H
+ SUB L
+ LD H,A
+ DEC E
+
+ PUSH DE
+ PUSH HL
+ JR NZ,4$
+
+ ADD SP,#4
+ RET
+
+ ;; Prompt the user for a char and return it in A
+.get_char:
+ PUSH BC
+ PUSH DE
+ PUSH HL
+ CALL .show_kbd
+ CALL .show_mouse
+1$:
+ CALL .track_mouse
+ CALL .update_mouse
+ CALL .jpad
+ LD D,A
+ AND #.A ; Is A pressed ?
+ JP Z,1$
+
+ LD A,(.msy) ; Look for char under the mouse
+ SUB #.MINMSPOSY
+ JR Z,12$
+ LD E,A
+ XOR A
+11$:
+ ADD #.MAXMSPOSX-.MINMSPOSX+1
+ DEC E
+ JR NZ,11$
+12$:
+ LD E,A
+ LD A,(.msx)
+ SUB #.MINMSPOSX
+ ADD E
+ LD HL,#.kbdtable
+ LD B,#0x00
+ LD C,A
+ ADD HL,BC
+ LD B,(HL)
+
+ CALL .hide_mouse
+ CALL .hide_kbd
+ LD A,B
+
+ POP HL
+ POP DE
+ POP BC
+ RET
+
+ ;; Prompt the user for a string and store it in (HL)
+.get_string:
+ PUSH BC
+ PUSH DE
+ PUSH HL
+ CALL .show_kbd
+ CALL .show_bkg
+ CALL .show_mouse
+ XOR A
+ LD (.string_len),A
+1$:
+ CALL .track_mouse
+ CALL .update_mouse
+ CALL .jpad
+ LD D,A
+ AND #.A ; Is A pressed ?
+ JP NZ,10$
+ LD A,D
+ AND #.B ; Is B pressed ?
+ JP NZ,20$
+ LD A,D
+ AND #.SELECT ; Is SELECT pressed ?
+ JP NZ,30$
+ LD A,D
+ AND #.START ; Is START pressed ?
+ JR Z,1$
+ CALL .padup ; Wait for button to be depressed
+
+ LD A,#.CR
+ CALL .put_char
+ LD (HL),#0x00
+ CALL .hide_mouse
+ CALL .hide_bkg
+ CALL .hide_kbd
+ POP HL
+ POP DE
+ POP BC
+ RET
+
+10$:
+ ;; Insert a character at cursor position
+ LD A,(.string_len) ; Check buffer length
+; CP #.BUFLEN-1 ; Keep 1 char for EOS
+; JR Z,13$
+ INC A
+ LD (.string_len),A ; Update it
+ LD A,(.msy) ; Look for char under the mouse
+ SUB #.MINMSPOSY
+ JR Z,12$
+ LD E,A
+ XOR A
+11$:
+ ADD #.MAXMSPOSX-.MINMSPOSX+1
+ DEC E
+ JR NZ,11$
+12$:
+ LD E,A
+ LD A,(.msx)
+ SUB #.MINMSPOSX
+ ADD E
+ PUSH HL
+ LD HL,#.kbdtable
+ LD B,#0x00
+ LD C,A
+ ADD HL,BC
+ LD A,(HL)
+ POP HL
+ LD (HL+),A ; Add it into input buffer
+ CALL .put_char ; Print it
+ CALL .show_bkg ; Ensure the text is not hidden
+13$:
+ CALL .padup ; Wait for button to be depressed
+ JP 1$
+
+20$:
+ ;; Delete a character at cursor position
+ LD A,(.string_len) ; Is there any char in the buffer ?
+ OR A
+ JR Z,21$
+ DEC A ; Yes
+ LD (.string_len),A ; Update buffer length
+ DEC HL
+ CALL .del_char
+21$:
+ CALL .padup ; Wait for button to be depressed
+ JP 1$
+
+30$:
+ CALL .hide_mouse
+ CALL .hide_bkg
+ CALL .hide_kbd
+ CALL .padup ; Wait for button to be depressed
+ CALL .show_kbd
+ CALL .show_bkg
+ CALL .show_mouse
+ JP 1$
+
+.show_kbd:
+ PUSH BC
+ PUSH DE
+ LDH A,(.LCDC)
+ OR #LCDCF_WINON ; Window = On
+ LDH (.LCDC),A
+ LD A,#.MAXWNDPOSY ; Show window
+1$:
+ BIT 0,A ; Wait for VBL every 2 pixels (slow down)
+ JR NZ,2$
+ LD B,A
+ CALL .wait_vbl_done
+ LD A,B
+2$:
+ LDH (.WY),A
+ CP #.KBDWINPOSY*0x08
+ JR Z,99$
+ DEC A
+ JR 1$
+99$:
+ POP DE
+ POP BC
+ RET
+
+.hide_kbd:
+ PUSH BC
+ PUSH DE
+ LD A,#.KBDWINPOSY*0x08+1
+1$: ; Hide window
+ BIT 0,A ; Wait for VBL every 2 pixels (slow down)
+ JR Z,2$
+ LD B,A
+ CALL .wait_vbl_done
+ LD A,B
+2$:
+ LDH (.WY),A
+ CP #.MAXWNDPOSY
+ JR Z,3$
+ INC A
+ JR 1$
+3$:
+ LDH A,(.LCDC)
+ AND #~LCDCF_WINON ; Window = Off
+ LDH (.LCDC),A
+ POP DE
+ POP BC
+ RET
+
+.show_bkg:
+ PUSH BC
+ PUSH DE
+ LDH A,(.SCY)
+ LD D,A
+ LD A,(.cury)
+ SUB #.KBDWINPOSY-1
+ JR C,99$
+ JR Z,99$
+ SLA A ; A = A * 8
+ SLA A
+ SLA A
+ SUB D
+ JR C,99$
+ JR Z,99$
+ LD C,A
+ LDH A,(.SCY)
+1$:
+ BIT 0,A ; Wait for VBL every 2 pixels (slow down)
+ JR Z,2$
+ LD B,A
+ CALL .wait_vbl_done
+ LD A,B
+2$:
+ INC A
+ LDH (.SCY),A
+ DEC C
+ JR Z,99$
+ JR 1$
+99$:
+ POP DE
+ POP BC
+ RET
+
+.hide_bkg:
+ LDH A,(.SCY)
+ OR A
+ RET Z
+ PUSH BC
+ PUSH DE
+1$:
+ BIT 0,A ; Wait for VBL every 2 pixels (slow down)
+ JR Z,2$
+ LD B,A
+ CALL .wait_vbl_done
+ LD A,B
+2$:
+ DEC A
+ LDH (.SCY),A
+ JR Z,99$
+ JR 1$
+99$:
+ POP DE
+ POP BC
+ RET
+
+.show_mouse:
+ LD A,#.INIMSPOSX
+ LD (.msx),A
+ LD A,#.INIMSPOSY
+ LD (.msy),A
+ CALL .set_mouse
+ LDH A,(.LCDC)
+ OR #LCDCF_OBJON ; OBJ = On
+ LDH (.LCDC),A
+ RET
+
+.hide_mouse:
+ LDH A,(.LCDC)
+ AND #~LCDCF_OBJON ; OBJ = Off
+ LDH (.LCDC),A
+ RET
+
+.track_mouse:
+ PUSH BC
+ PUSH DE
+ PUSH HL
+ XOR A
+ LD (.mschanged),A ; Default to no change
+ CALL .jpad
+ LD D,A
+
+ LD HL,#.msstate
+ AND #.UP+.DOWN+.LEFT+.RIGHT
+ JR NZ,1$
+ LD (HL),#0x00 ; Reset state
+ JP 99$
+1$:
+ LD A,(HL)
+ LD (HL),#0x01 ; Set state
+ OR A ; Was it 0 ?
+ LD HL,#.msacc ; Acceleration
+ JR NZ,2$
+ ; Yes
+ LD (HL),#<.MINACCEL
+ INC HL
+ LD (HL),#>.MINACCEL
+ JR 4$ ; Update position
+2$:
+ LD A,(HL+)
+ LD C, A
+ LD B,(HL)
+ DEC BC
+ LD A,B
+ OR C
+ JR Z,3$
+ LD (HL),B
+ DEC HL
+ LD (HL),C
+ JP 99$
+3$: ; Set new acceleration to maximum
+ LD (HL),#>.MAXACCEL
+ DEC HL
+ LD (HL),#<.MAXACCEL
+4$: ; Update position
+ LD A,#0x01
+ LD (.mschanged),A
+ LD A,D
+ AND #.UP ; Is UP pressed ?
+ JR Z,6$
+ LD A,(.msy)
+ CP #.MINMSPOSY
+ JR Z,5$
+ DEC A
+ LD (.msy),A
+ JR 6$
+5$:
+ LD A,#.MAXMSPOSY
+ LD (.msy),A
+6$:
+ LD A,D
+ AND #.DOWN ; Is DOWN pressed ?
+ JR Z,8$
+ LD A,(.msy)
+ CP #.MAXMSPOSY
+ JR Z,7$
+ INC A
+ LD (.msy),A
+ JR 8$
+7$:
+ LD A,#.MINMSPOSY
+ LD (.msy),A
+8$:
+ LD A,D
+ AND #.LEFT ; Is LEFT pressed ?
+ JR Z,10$
+ LD A,(.msx)
+ CP #.MINMSPOSX
+ JR Z,9$
+ DEC A
+ LD (.msx),A
+ JR 10$
+9$:
+ LD A,#.MAXMSPOSX
+ LD (.msx),A
+10$:
+ LD A,D
+ AND #.RIGHT ; Is RIGHT pressed ?
+ JR Z,99$
+ LD A,(.msx)
+ CP #.MAXMSPOSX
+ JR Z,11$
+ INC A
+ LD (.msx),A
+ JR 99$
+11$:
+ LD A,#.MINMSPOSX
+ LD (.msx),A
+99$:
+ POP HL
+ POP DE
+ POP BC
+ RET
+
+.update_mouse:
+ LD A,(.mschanged) ; Did it change ?
+ OR A
+ RET Z ; No
+.set_mouse:
+ PUSH BC
+ PUSH DE
+ PUSH HL
+ LD C,#0x00 ; Sprite 0x00
+ LD A,(.msx)
+ SLA A ; A = A * 8
+ SLA A
+ SLA A
+ ADD #.MSOFFSETX
+ LD D,A
+ LD A,(.msy)
+ SLA A ; A = A * 8
+ SLA A
+ SLA A
+ ADD #.MSOFFSETY
+ LD E,A
+ CALL .mv_sprite
+ POP HL
+ POP DE
+ POP BC
+ RET
+
+_getchar::
+ LD A,(.mode)
+ CP #.T_MODE_INOUT
+ JR Z,1$
+ PUSH BC
+ CALL .tmode_inout
+ POP BC
+1$:
+ CALL .get_char
+ LD E,A
+ RET
+
+_gets::
+ LD A,(.mode)
+ CP #.T_MODE_INOUT
+ JR Z,1$
+ PUSH BC
+ CALL .tmode_inout
+ POP BC
+1$:
+ LDA HL,2(SP) ; Skip return address
+ LD A,(HL+)
+ LD H,(HL) ; HL = s
+ LD L,A
+ PUSH HL
+ CALL .get_string
+ POP DE
+ RET
+
+.tp1:
+
+.pointers:
+
+ ; Tile 0x00
+ .byte 0xFF,0xFF,0xFE,0x82,0xFC,0x84,0xFC,0x84,0xFE,0x82,0xFF,0xB1,0xCF,0xC9,0x87,0x87
+
+.endtp1:
+
+.frame_tiles:
+ .byte 0x1C,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x1D
+ .byte 0x0F,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x0F
+ .byte 0x0F,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x0F
+ .byte 0x0F,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x0F
+ .byte 0x0F,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x0F
+ .byte 0x0F,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x0F
+ .byte 0x0F,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x0F
+ .byte 0x0F,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x0F
+ .byte 0x0F,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x0F
+ .byte 0x1E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x1F
+
+.kbdtable:
+ .db 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27
+ .db 0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F
+ .ascii "0123456789:"
+ .db 0x3B
+ .ascii "<=>?"
+ .ascii "@ABCDEFGHIJKLMNO"
+ .ascii "PQRSTUVWXYZ[\]^_"
+ .ascii "`abcdefghijklmno"
+ .ascii "pqrstuvwxyz{|}~ "
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/joy.s b/gbdk/gbdk-lib/libc/targets/sm83/joy.s
new file mode 100644
index 00000000..7dbbfbae
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/joy.s
@@ -0,0 +1,47 @@
+ .include "global.s"
+
+ .globl .int
+
+ .area _HEADER_JOY (ABS)
+
+ .org 0x60 ; JOY
+.int_JOY:
+ PUSH AF
+ PUSH HL
+ LD HL,#.int_0x60
+ JP .int
+
+ .area _HOME
+
+_add_JOY::
+ PUSH BC
+ LDA HL,4(SP) ; Skip return address and registers
+ LD C,(HL)
+ INC HL
+ LD B,(HL)
+ CALL .add_JOY
+ POP BC
+ RET
+
+.add_JOY::
+ LD HL,#.int_0x60
+ JP .add_int
+
+_remove_JOY::
+ PUSH BC
+ LDA HL,4(SP) ; Skip return address and registers
+ LD C,(HL)
+ INC HL
+ LD B,(HL)
+ CALL .remove_JOY
+ POP BC
+ RET
+
+.remove_JOY::
+ LD HL,#.int_0x60
+ JP .remove_int
+
+ .area _DATA
+
+.int_0x60::
+ .blkw 0x08
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/lcd.s b/gbdk/gbdk-lib/libc/targets/sm83/lcd.s
new file mode 100644
index 00000000..5270e2c3
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/lcd.s
@@ -0,0 +1,81 @@
+ .include "global.s"
+
+
+ .area _HEADER_LCD (ABS)
+
+ .org 0x48 ; LCD
+.int_LCD:
+ JP .int_lcd_handler
+
+ .area _HOME
+
+.int_lcd_handler:
+ PUSH AF
+ PUSH HL
+ PUSH BC
+ PUSH DE
+ LD HL, #.int_0x48 + 0
+ PUSH HL ; for stack compatibility with std handler only!
+ LD A,(HL+)
+ LD H,(HL)
+ LD L,A
+ OR H
+ JR Z, 1$
+ RST 0x20 ; .call_hl
+ LD HL, #.int_0x48 + 2
+ LD A,(HL+)
+ LD H,(HL)
+ LD L,A
+ OR H
+ JR Z, 1$
+ RST 0x20 ; .call_hl
+ LD HL, #.int_0x48 + 4
+ LD A,(HL+)
+ LD H,(HL)
+ LD L,A
+ OR H
+ CALL NZ, .call_hl
+1$:
+ POP HL
+ POP DE
+ POP BC
+ POP HL
+
+ ;; we return at least at the beginning of mode 2
+ WAIT_STAT
+
+ POP AF
+ RETI
+
+_add_LCD::
+ PUSH BC
+ LDA HL,4(SP) ; Skip return address and registers
+ LD C,(HL)
+ INC HL
+ LD B,(HL)
+ CALL .add_LCD
+ POP BC
+ RET
+
+.add_LCD::
+ LD HL,#.int_0x48
+ JP .add_int
+
+_remove_LCD::
+ PUSH BC
+ LDA HL,4(SP) ; Skip return address and registers
+ LD C,(HL)
+ INC HL
+ LD B,(HL)
+ CALL .remove_LCD
+ POP BC
+ RET
+
+.remove_LCD::
+ LD HL,#.int_0x48
+ JP .remove_int
+
+ .area _DATA
+
+.int_0x48::
+ .blkw 0x08
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/metasprites.s b/gbdk/gbdk-lib/libc/targets/sm83/metasprites.s
new file mode 100644
index 00000000..6bc50b1c
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/metasprites.s
@@ -0,0 +1,82 @@
+ .include "global.s"
+
+ .title "Metasprites"
+ .module Metasprites
+
+ .area _DATA
+
+___current_metasprite::
+ .ds 0x02
+___current_base_tile::
+ .ds 0x01
+
+ .area _INITIALIZED
+___render_shadow_OAM::
+ .ds 0x01
+
+ .area _INITIALIZER
+ .db #>_shadow_OAM
+
+ .area _CODE
+
+; uint8_t __move_metasprite(uint8_t id, uint8_t x, uint8_t y)
+
+___move_metasprite::
+ ldhl sp, #4
+ ld a, (hl-)
+ ld b, a
+ ld a, (hl-)
+ ld c, a
+ ld a, (hl)
+ cp #40
+ jr nc, 3$
+
+ add a
+ add a
+ ld e, a
+
+ ld hl, #___current_metasprite
+ ld a, (hl+)
+ ld h, (hl)
+ ld l, a
+
+ ld a, (___render_shadow_OAM)
+ ld d, a
+1$:
+ ld a, (hl+) ; dy
+ cp #0x80
+ jr z, 2$
+ add b
+ ld b, a
+ ld (de), a
+ inc e
+
+ ld a, (hl+) ; dx
+ add c
+ ld c, a
+ ld (de), a
+ inc e
+
+ ld a, (___current_base_tile)
+ add (hl) ; tile
+ inc hl
+ ld (de), a
+ inc e
+
+ ld a, (hl+) ; props
+ ld (de), a
+ inc e
+
+ ld a, e
+ cp #160
+ jr c, 1$
+2$:
+ ld a, e
+ srl a
+ srl a
+ ldhl sp, #2
+3$:
+ sub (hl)
+ ld e, a
+
+ ret
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/metasprites_flip.s b/gbdk/gbdk-lib/libc/targets/sm83/metasprites_flip.s
new file mode 100644
index 00000000..9a86edea
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/metasprites_flip.s
@@ -0,0 +1,203 @@
+ .include "global.s"
+
+ .title "Metasprites"
+ .module Metasprites
+
+ .area _DATA
+
+ .globl ___current_metasprite, ___current_base_tile, ___render_shadow_OAM
+
+ .area _CODE
+
+; uint8_t __move_metasprite(uint8_t id, uint8_t x, uint8_t y)
+
+___move_metasprite_hflip::
+ ldhl sp, #4
+ ld a, (hl-)
+ ld b, a
+ ld a, (hl-)
+ ld c, a
+ ld a, (hl)
+ cp #40
+ jr nc, 3$
+
+ add a
+ add a
+ ld e, a
+
+ ld hl, #___current_metasprite
+ ld a, (hl+)
+ ld h, (hl)
+ ld l, a
+
+ ld a, (___render_shadow_OAM)
+ ld d, a
+1$:
+ ld a, (hl+)
+ cp #0x80
+ jr z, 2$
+ cpl
+ inc a
+ add b
+ ld b, a
+ ld (de), a
+ inc e
+
+ ld a, (hl+) ; dx
+ add c
+ ld c, a
+ ld (de), a
+ inc e
+
+ ld a, (___current_base_tile)
+ add (hl) ; tile
+ inc hl
+ ld (de), a
+ inc e
+
+ ld a, (hl+) ; props
+ xor #0x40
+ ld (de), a
+ inc e
+
+ ld a, e
+ cp #160
+ jr c, 1$
+2$:
+ ld a, e
+ srl a
+ srl a
+ ldhl sp, #2
+3$:
+ sub (hl)
+ ld e, a
+
+ ret
+
+___move_metasprite_vflip::
+ ldhl sp, #4
+ ld a, (hl-)
+ ld b, a
+ ld a, (hl-)
+ ld c, a
+ ld a, (hl)
+ cp #40
+ jr nc, 3$
+
+ add a
+ add a
+ ld e, a
+
+ ld hl, #___current_metasprite
+ ld a, (hl+)
+ ld h, (hl)
+ ld l, a
+
+ ld a, (___render_shadow_OAM)
+ ld d, a
+1$:
+ ld a, (hl+) ; dy
+ cp #0x80
+ jr z, 2$
+ add b
+ ld b, a
+ ld (de), a
+ inc e
+
+ ld a, (hl+) ; dx
+ cpl
+ inc a
+ add c
+ ld c, a
+ ld (de), a
+ inc e
+
+ ld a, (___current_base_tile)
+ add (hl) ; tile
+ inc hl
+ ld (de), a
+ inc e
+
+ ld a, (hl+) ; props
+ xor #0x20
+ ld (de), a
+ inc e
+
+ ld a, e
+ cp #160
+ jr c, 1$
+2$:
+ ld a, e
+ srl a
+ srl a
+ ldhl sp, #2
+3$:
+ sub (hl)
+ ld e, a
+
+ ret
+
+___move_metasprite_hvflip::
+ ldhl sp, #4
+ ld a, (hl-)
+ ld b, a
+ ld a, (hl-)
+ ld c, a
+ ld a, (hl)
+ cp #40
+ jr nc, 3$
+
+ add a
+ add a
+ ld e, a
+
+ ld hl, #___current_metasprite
+ ld a, (hl+)
+ ld h, (hl)
+ ld l, a
+
+ ld a, (___render_shadow_OAM)
+ ld d, a
+1$:
+ ld a, (hl+)
+ cp #0x80
+ jr z, 2$
+ cpl
+ inc a
+ add b
+ ld b, a
+ ld (de), a
+ inc e
+
+ ld a, (hl+) ; dx
+ cpl
+ inc a
+ add c
+ ld c, a
+ ld (de), a
+ inc e
+
+ ld a, (___current_base_tile)
+ add (hl) ; tile
+ inc hl
+ ld (de), a
+ inc e
+
+ ld a, (hl+) ; props
+ xor #0x60
+ ld (de), a
+ inc e
+
+ ld a, e
+ cp #160
+ jr c, 1$
+2$:
+ ld a, e
+ srl a
+ srl a
+ ldhl sp, #2
+3$:
+ sub (hl)
+ ld e, a
+
+ ret
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/metasprites_hide.s b/gbdk/gbdk-lib/libc/targets/sm83/metasprites_hide.s
new file mode 100644
index 00000000..0762e9e1
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/metasprites_hide.s
@@ -0,0 +1,52 @@
+ .include "global.s"
+
+ .title "Metasprites"
+ .module Metasprites
+
+ .globl ___current_metasprite, ___render_shadow_OAM
+
+ .area _CODE
+
+
+; void __hide_metasprite(uint8_t id)
+
+___hide_metasprite::
+ ldhl sp, #2
+ ld a, (hl)
+ cp #40
+ ret nc
+
+ add a
+ add a
+ ld e, a
+
+ ld hl, #___current_metasprite
+ ld a, (hl+)
+ ld h, (hl)
+ ld l, a
+
+ ld bc, #3
+
+ ld a, (___render_shadow_OAM)
+ ld d, a
+1$:
+ ld a, (hl+)
+ cp #0x80
+ ret z
+
+ add hl, bc
+
+ xor a
+ ld (de), a
+
+ inc e
+ inc e
+ inc e
+ inc e
+
+ ld a, e
+ cp #160
+
+ jr c, 1$
+
+ ret \ No newline at end of file
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/metasprites_hide_spr.s b/gbdk/gbdk-lib/libc/targets/sm83/metasprites_hide_spr.s
new file mode 100644
index 00000000..54a3d57f
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/metasprites_hide_spr.s
@@ -0,0 +1,71 @@
+ .include "global.s"
+
+ .title "Metasprites"
+ .module Metasprites
+
+ .globl ___render_shadow_OAM
+
+ .area _CODE
+
+; void hide_sprites_range(UINT8 from, UINT8 to)
+
+_hide_sprites_range::
+ ldhl sp, #2
+ ld a, (hl+)
+
+ cp #40
+ ret nc
+
+ add a
+ add a
+ ld e, a
+
+ ld a, (hl-)
+ sub (hl)
+
+ ret c
+ ret z
+
+ ld hl, #___render_shadow_OAM
+ ld h, (hl)
+ ld l, e
+
+ ld de, #4
+
+ rra ; carry is never set here, because of ret c above
+ jr nc, 0$
+
+ ld (hl), d
+ add hl, de ; carry is reset here because hl can't overflow
+
+ ret z ; z is not affected by 16-bit add
+
+0$:
+ srl a
+ jr nc, 1$
+
+ ld (hl), d
+ add hl, de
+
+ ld (hl), d
+ add hl, de
+
+ ret z ; z is not affected by 16-bit add
+
+1$:
+ ld (hl), d
+ add hl, de
+
+ ld (hl), d
+ add hl, de
+
+ ld (hl), d
+ add hl, de
+
+ ld (hl), d
+ add hl, de
+
+ dec a
+ jr nz, 1$
+
+ ret
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/mode.s b/gbdk/gbdk-lib/libc/targets/sm83/mode.s
new file mode 100644
index 00000000..2634bd88
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/mode.s
@@ -0,0 +1,30 @@
+ .include "global.s"
+
+ .title "screen modes"
+ .module Modes
+
+ ;; BANKED: checked
+ .area _HOME
+
+_mode::
+ LDA HL,2(SP) ; Skip return address
+ LD L,(HL)
+ LD H,#0x00
+
+.set_mode::
+ LD A,L
+ LD (.mode),A
+
+ ;; AND to get rid of the extra flags
+ AND #0x03
+ LD L,A
+ LD BC,#.MODE_TABLE
+ SLA L ; Multiply mode by 4
+ SLA L
+ ADD HL,BC
+ JP (HL) ; Jump to initialization routine
+
+_get_mode::
+ LD HL,#.mode
+ LD E,(HL)
+ RET
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/mv_spr.s b/gbdk/gbdk-lib/libc/targets/sm83/mv_spr.s
new file mode 100644
index 00000000..f4fb9259
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/mv_spr.s
@@ -0,0 +1,18 @@
+ .include "global.s"
+
+ .area _HOME
+
+ ;; Move sprite number C at XY = DE
+.mv_sprite::
+ LD HL,#_shadow_OAM ; Calculate origin of sprite info
+ SLA C ; Multiply C by 4
+ SLA C
+ LD B,#0x00
+ ADD HL,BC
+
+ LD A,E ; Set Y
+ LD (HL+),A
+
+ LD A,D ; Set X
+ LD (HL+),A
+ RET
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/nowait.s b/gbdk/gbdk-lib/libc/targets/sm83/nowait.s
new file mode 100644
index 00000000..7b19152b
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/nowait.s
@@ -0,0 +1,10 @@
+ ;; interrupt handler that does not wait for .STAT
+ ;; must be the last one in chain
+_nowait_int_handler::
+ ADD SP,#4
+
+ POP DE
+ POP BC
+ POP HL
+ POP AF
+ RETI
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/pad.s b/gbdk/gbdk-lib/libc/targets/sm83/pad.s
new file mode 100644
index 00000000..917cc46c
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/pad.s
@@ -0,0 +1,68 @@
+ .include "global.s"
+
+ .area _HOME
+
+ ;; Wait until all buttons have been released
+.padup::
+_waitpadup::
+ PUSH AF ; Save modified registers
+ PUSH DE
+1$:
+ LD D,#0x7F ; wait for .jpad return zero 127 times in a row
+2$:
+ CALL .jpad
+ OR A ; Have all buttons been released?
+ JR NZ,1$ ; Not yet
+
+ DEC D
+ JR NZ,2$
+
+ POP DE
+ POP AF
+ RET
+
+ ;; Get Keypad Button Status
+ ;; The following bits are set if pressed:
+ ;; 0x80 - Start 0x08 - Down
+ ;; 0x40 - Select 0x04 - Up
+ ;; 0x20 - B 0x02 - Left
+ ;; 0x10 - A 0x01 - Right
+_joypad::
+.jpad::
+ LD A,#.P15
+ LDH (.P1),A ; Turn on P15
+
+ LDH A,(.P1) ; Delay
+ LDH A,(.P1)
+ AND #0x0F
+ LD E,A
+ LD A,#.P14
+ LDH (.P1),A ; Turn on P14
+ LDH A,(.P1) ; Delay
+ LDH A,(.P1)
+ LDH A,(.P1)
+ LDH A,(.P1)
+ LDH A,(.P1)
+ LDH A,(.P1)
+ AND #0x0F
+ SWAP A
+ OR E
+ CPL
+ LD E,A
+ LD A,#(.P14 | .P15)
+ LDH (.P1),A ; Turn off P14 and P15 (reset joypad)
+ LD A,E
+ RET
+
+ ;; Wait for the key to be pressed
+_waitpad::
+ LDA HL,2(SP) ; Skip return address
+ LD D,(HL)
+ ;; Wait for the key in D to be pressed
+.wait_pad::
+1$:
+ CALL .jpad ; Read pad
+ AND D ; Compare with mask?
+ JR Z,1$ ; Loop if no intersection
+ RET
+
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/pad_ex.s b/gbdk/gbdk-lib/libc/targets/sm83/pad_ex.s
new file mode 100644
index 00000000..95684b2e
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/pad_ex.s
@@ -0,0 +1,132 @@
+ .include "global.s"
+
+ .MLT_REQ = 0x11
+
+ .area _HOME
+
+_joypad_init::
+ call .sgb_check
+ ld a, e
+ inc e
+ or a
+
+ jr Z, 1$
+
+ ldhl sp, #0x02
+ ld e, (hl)
+
+ add sp, #-0x10
+ ldhl sp, #0
+ ld c, #0x10
+ xor a
+ rst 0x28
+
+ ldhl sp, #0
+ ld a, #((.MLT_REQ << 3) | 1)
+ ld (hl+), a
+
+ ld a, e
+
+ cp a, #0x02
+ jr Z, 3$
+ cp a, #0x04
+ jr Z, 4$
+ jr 5$
+
+3$:
+ ld a, #0x01
+ ld (hl-), a
+ call .sgb_transfer
+ ld e, #0x02
+ jr 2$
+
+4$:
+ ld a, #0x03
+ ld (hl-), a
+ call .sgb_transfer
+ ld e, #0x04
+ jr 2$
+5$:
+ ld a, #0x00
+ ld (hl-), a
+ call .sgb_transfer
+ ld e, #0x01
+2$:
+ add sp, #0x10
+1$:
+ ldhl sp, #3
+ ld a, (hl+)
+ ld h, (hl)
+ ld l, a
+ ld a, e
+ ld (hl+), a
+ xor a
+ ld (hl+), a
+ ld (hl+), a
+ ld (hl+), a
+ ld (hl), a
+ ret
+
+_joypad_ex::
+ lda hl, 2(sp)
+ ld a, (hl+)
+ ld e, a
+ ld d, (hl)
+
+.joypad_ex::
+ ld a, (de)
+ inc de
+ or a
+ jr z, 2$
+
+ dec a
+ and #3
+ inc a
+2$:
+ push bc
+ ld b, a
+1$:
+ ld a, #(.P14 | .P15)
+ ldh (#.P1), a
+ ldh a, (#.P1)
+ ldh a, (#.P1)
+ ldh a, (#.P1)
+ ldh a, (#.P1)
+ and #0x0f
+ sub #0x0f
+ cpl
+ inc a ; A contains joypad number
+
+ and #0x03 ; buffer overrun protection
+
+ add e ; HL = DE + A
+ ld l, a
+ adc d
+ sub l
+ ld h, a
+
+ ld a, #.P15
+ ldh (#.P1), a
+ ldh a, (#.P1)
+ ldh a, (#.P1)
+ and #0x0f
+ ld c, a
+ ld a, #.P14
+ ldh (#.P1), a
+ ldh a, (#.P1)
+ ldh a, (#.P1)
+ ldh a, (#.P1)
+ ldh a, (#.P1)
+ ldh a, (#.P1)
+ ldh a, (#.P1)
+ and #0x0f
+ swap a
+ or c
+ cpl
+ ld (hl), a
+
+ dec b
+ jr nz, 1$
+ pop bc
+
+ ret
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/rle_decompress.s b/gbdk/gbdk-lib/libc/targets/sm83/rle_decompress.s
new file mode 100644
index 00000000..4c72e357
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/rle_decompress.s
@@ -0,0 +1,116 @@
+ .include "global.s"
+
+ .module RLE_DECOMPRESS
+
+ .area _DATA
+
+rle_cursor:
+ .ds 0x02
+rle_counter:
+ .ds 0x01
+rle_current:
+ .ds 0x01
+
+ .area _CODE
+
+_rle_init::
+ ldhl sp, #2
+ ld a, (hl+)
+ ld e, (hl)
+ ld hl, #rle_cursor
+ ld (hl+), a
+ ld a, e
+ ld (hl+), a
+ xor a
+ ld (hl+), a
+ ld (hl), a
+ ld e, #1
+ ret
+
+_rle_decompress::
+ ;; Pop the return address
+ ldhl sp, #2
+ ld a, (hl+)
+ ld c, a
+ ld a, (hl+)
+ ld d, a ; de == dest
+ ld b, (hl) ; b == count
+
+ ld hl, #rle_cursor
+ ld a, (hl+)
+ ld h, (hl)
+ ld l, a ; hl == cursor
+
+ or h
+ ld e, a
+ ret z
+
+ ld e, c
+
+ ld a, (rle_counter)
+ or a
+ ld c, a
+ jr z, 1$
+
+ ld a, (rle_current)
+ bit 7, c
+ jr nz, 10$
+ jr 11$
+1$:
+ ;; Fetch the run
+ ld c, (hl)
+ inc hl
+ ;; Negative means a run
+8$:
+ bit 7, c
+ jr z, 2$
+ ;; Expanding a run
+ ld a, (hl+)
+3$:
+ ld (de), a
+ inc de
+
+ dec b
+ jr z, 6$
+10$:
+ inc c
+ jr NZ, 3$
+ jr 1$
+2$:
+ ;; Zero means end of a block
+ inc c
+ dec c
+ jr z, 4$
+ ;; Expanding a block
+5$:
+ ld a, (hl+)
+ ld (de), a
+ inc de
+
+ dec b
+ jr z, 6$
+11$:
+ dec c
+ jr NZ, 5$
+ jr 1$
+4$:
+ ;; save state and exit
+ ld hl, #rle_cursor
+ xor a
+ ld (hl+), a
+ ld (hl), a
+ ld e, a
+ ret
+6$:
+ ;; save state and exit
+ ld d, h
+ ld e, l
+ ld hl, #rle_current
+ ld (hl-), a
+ ld a, c
+ ld (hl-), a
+ ld a, d
+ ld (hl-), a
+ ld (hl), e
+ ld e, #1
+ ret \ No newline at end of file
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/serial.s b/gbdk/gbdk-lib/libc/targets/sm83/serial.s
new file mode 100644
index 00000000..b948ca1d
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/serial.s
@@ -0,0 +1,140 @@
+ .include "global.s"
+
+ .globl .int
+
+ .globl __io_out
+ .globl __io_in
+ .globl __io_status
+
+ .area _HEADER_SIO (ABS)
+
+ .org 0x58 ; SIO
+.int_SIO:
+ PUSH AF
+ PUSH HL
+ LD HL,#.int_0x58
+ JP .int
+
+ .area _GSINIT
+
+ ;; initialize SIO
+ LD BC,#.serial_IO
+ CALL .add_SIO
+
+ XOR A
+ LDH (.IF),A
+
+ LDH A,(.IE)
+ OR A,#0b00001000 ; Serial I/O = On
+ LDH (.IE),A
+
+ LDH (.SC),A ; Use external clock
+ LD A,#.DT_IDLE
+ LDH (.SB),A ; Send IDLE byte
+ LD A,#0x80
+ LDH (.SC),A ; Use external clock
+
+ .area _HOME
+
+_add_SIO::
+ PUSH BC
+ LDA HL,4(SP) ; Skip return address and registers
+ LD C,(HL)
+ INC HL
+ LD B,(HL)
+ CALL .add_SIO
+ POP BC
+ RET
+
+.add_SIO::
+ LD HL,#.int_0x58
+ JP .add_int
+
+_remove_SIO::
+ PUSH BC
+ LDA HL,4(SP) ; Skip return address and registers
+ LD C,(HL)
+ INC HL
+ LD B,(HL)
+ CALL .remove_SIO
+ POP BC
+ RET
+
+.remove_SIO::
+ LD HL,#.int_0x58
+ JP .remove_int
+
+ ;; Serial interrupt
+.serial_IO::
+ LD A,(__io_status) ; Get status
+
+ CP #.IO_RECEIVING
+ JR NZ, 1$
+
+ ;; Receiving data
+ LDH A,(.SB) ; Get data byte
+ LD (__io_in),A ; Store it
+
+2$:
+ LD A,#.IO_IDLE
+3$:
+ LD (__io_status),A ; Store status
+
+ XOR A
+ LDH (.SC),A ; Use external clock
+ LD A,#.DT_IDLE
+ LDH (.SB),A ; Reply with IDLE byte
+4$:
+ LD A,#0x80
+ LDH (.SC),A ; Enable transfer with external clock
+ RET
+
+1$:
+ CP #.IO_SENDING
+ JR NZ, 4$
+
+ ;; Sending data
+ LDH A,(.SB) ; Get data byte
+ CP #.DT_RECEIVING
+ JR Z, 2$
+ LD A,#.IO_ERROR
+ JR 3$
+
+ .area _DATA
+
+__io_out::
+ .ds 0x01 ; Byte to send
+__io_in::
+ .ds 0x01 ; Received byte
+__io_status::
+ .ds 0x01 ; Status of serial IO
+.int_0x58::
+ .blkw 0x08
+
+ .area _CODE
+
+ ;; Send byte in __io_out to the serial port
+.send_byte:
+_send_byte:: ; Banked
+ LD A,#.IO_SENDING
+ LD (__io_status),A ; Store status
+ LD A,#0x01
+ LDH (.SC),A ; Use internal clock
+ LD A,(__io_out)
+ LDH (.SB),A ; Send data byte
+ LD A,#0x81
+ LDH (.SC),A ; Use internal clock
+ RET
+
+ ;; Receive byte from the serial port in __io_in
+.receive_byte:
+_receive_byte:: ; Banked
+ LD A,#.IO_RECEIVING
+ LD (__io_status),A ; Store status
+ XOR A
+ LDH (.SC),A ; Use external clock
+ LD A,#.DT_RECEIVING
+ LDH (.SB),A ; Send RECEIVING byte
+ LD A,#0x80
+ LDH (.SC),A ; Use external clock
+ RET
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/set_1bit_data.s b/gbdk/gbdk-lib/libc/targets/sm83/set_1bit_data.s
new file mode 100644
index 00000000..a16d57b7
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/set_1bit_data.s
@@ -0,0 +1,98 @@
+ .include "global.s"
+
+ .globl __current_1bpp_colors
+
+ .area _HOME
+
+_set_bkg_1bpp_data::
+_set_win_1bpp_data::
+ ld d, #0x90
+ ldh a, (.LCDC)
+ and #LCDCF_BG8000
+ jr z, .copy_1bpp_tiles
+_set_sprite_1bpp_data::
+ ld d, #0x80
+.copy_1bpp_tiles:
+ push bc
+
+ lda hl, 4(sp)
+ ld a, (hl+) ; ID of 1st tile
+ ld e, a
+ ld a, (hl+) ; Nb of tiles
+ ld c, a
+ ld a, (hl+) ; Src ptr
+ ld h, (hl)
+ ld l, a
+
+ ; Compute dest ptr
+ swap e ; *16 (size of a tile)
+ ld a, e
+ and #0x0F ; Get high bits
+ add d ; Add base offset of target tile "block"
+ ld d, a
+ ld a, e
+ and #0xF0 ; Get low bits only
+ ld e, a
+
+ push de
+ ld d, h
+ ld e, l
+ pop hl
+
+1$:
+ ; Wrap from past $97FF to $8800 onwards
+ ; This can be reduced to "bit 4 must be clear if bit 3 is set"
+ bit 3, h
+ jr z, 2$
+ res 4, h
+2$:
+ ld b, #8
+3$:
+ push bc
+ ld a, (de) ; a == bits
+ inc de
+ push de
+ push hl
+
+ ld hl, #__current_1bpp_colors
+ ld c, (hl)
+ inc hl
+ ld h, (hl)
+ ld l, c ; L ==.fg_colour, H == .bg_colour
+
+ ld e, #8
+8$:
+ rra
+ jr c, 7$
+ ld d, h
+ jr 9$
+7$:
+ ld d, l
+9$:
+ srl d
+ rr c
+ srl d
+ rr b
+
+ dec e
+ jr nz, 8$
+
+ pop hl
+
+ WAIT_STAT
+ ld (hl), c
+ inc l
+ ld (hl), b
+ inc hl
+
+ pop de
+ pop bc
+
+ dec b
+ jr nz, 3$
+
+ dec c
+ jr nz, 1$
+
+ pop bc
+ ret \ No newline at end of file
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/set_bk_t.s b/gbdk/gbdk-lib/libc/targets/sm83/set_bk_t.s
new file mode 100644
index 00000000..36992eec
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/set_bk_t.s
@@ -0,0 +1,26 @@
+ .include "global.s"
+
+ .globl .set_xy_btt
+
+ .area _HOME
+
+_set_bkg_tiles::
+ PUSH BC
+
+ LDA HL,4(SP) ; Skip return address and registers
+ LD A,(HL+) ; D = x
+ LD D, A
+ LD E,(HL) ; E = y
+ LDA HL,9(SP)
+ LD A,(HL-) ; BC = tiles
+ LD B, A
+ LD A,(HL-)
+ LD C, A
+ LD A,(HL-) ; A = h
+ LD H,(HL) ; H = w
+ LD L,A ; L = h
+
+ CALL .set_xy_btt
+
+ POP BC
+ RET
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/set_data.s b/gbdk/gbdk-lib/libc/targets/sm83/set_data.s
new file mode 100644
index 00000000..33208ef7
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/set_data.s
@@ -0,0 +1,58 @@
+ .include "global.s"
+
+ .area _HOME
+
+_set_tile_data::
+ ldhl sp, #6
+ ld d,(hl)
+ jr .copy_tiles
+_set_bkg_data::
+_set_win_data::
+ ld d, #0x90
+ ldh a, (.LCDC)
+ and #LCDCF_BG8000
+ jr z, .copy_tiles
+_set_sprite_data::
+ ld d, #0x80
+.copy_tiles:
+ push bc
+ ldhl sp, #4
+ ld a, (hl+) ; ID of 1st tile
+ ld e, a
+ ld a, (hl+) ; Nb of tiles
+ ld c, a
+ ld a, (hl+) ; Src ptr
+ ld h, (hl)
+ ld l, a
+
+ ; Compute dest ptr
+ swap e ; *16 (size of a tile)
+ ld a, e
+ and #0x0F ; Get high bits
+ add d ; Add base offset of target tile "block"
+ ld d, a
+ ld a, e
+ and #0xF0 ; Get low bits only
+ ld e, a
+2$:
+ ; Wrap from past $97FF to $8800 onwards
+ ; This can be reduced to "bit 4 must be clear if bit 3 is set"
+ bit 3, d
+ jr z, 1$
+ res 4, d
+1$:
+ ld b, #16
+3$:
+ WAIT_STAT
+ ld a, (hl+)
+ ld (de), a
+ inc de
+
+ dec b
+ jr nz, 3$
+
+ dec c
+ jr nz, 2$
+
+ pop bc
+ ret \ No newline at end of file
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/set_prop.s b/gbdk/gbdk-lib/libc/targets/sm83/set_prop.s
new file mode 100644
index 00000000..0cd46be8
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/set_prop.s
@@ -0,0 +1,16 @@
+ .include "global.s"
+
+ .area _HOME
+
+ ;; Set properties of sprite number C to D
+.set_sprite_prop::
+ LD HL,#_shadow_OAM+3 ; Calculate origin of sprite info
+
+ SLA C ; Multiply C by 4
+ SLA C
+ LD B,#0x00
+ ADD HL,BC
+
+ LD A,D ; Set sprite properties
+ LD (HL),A
+ RET
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/set_spr.s b/gbdk/gbdk-lib/libc/targets/sm83/set_spr.s
new file mode 100644
index 00000000..8b428fe9
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/set_spr.s
@@ -0,0 +1,16 @@
+ .include "global.s"
+
+ .area _HOME
+
+ ;; Set sprite number C to tile D
+.set_sprite_tile::
+ LD HL,#_shadow_OAM+2 ; Calculate origin of sprite info
+
+ SLA C ; Multiply C by 4
+ SLA C
+ LD B,#0x00
+ ADD HL,BC
+
+ LD A,D ; Set sprite number
+ LD (HL),A
+ RET
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/set_t.s b/gbdk/gbdk-lib/libc/targets/sm83/set_t.s
new file mode 100644
index 00000000..98d7288c
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/set_t.s
@@ -0,0 +1,28 @@
+ .include "global.s"
+
+ .globl .set_xy_tt
+
+ .area _HOME
+
+; void set_tiles(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t *vram_addr, const uint8_t *tiles);
+
+_set_tiles::
+ LDHL SP, #5
+ LD A, (HL-)
+ LD E, A
+ LD A, (HL-)
+ LD D, A
+ PUSH DE
+ LD A, (HL-)
+ LD E, A
+ LD D, (HL)
+ LDHL SP, #11
+ LD A, (HL-)
+ LD B, A
+ LD A, (HL-)
+ LD C, A
+ LD A, (HL-)
+ LD L, (HL)
+ LD H, A
+
+ JP .set_xy_tt ;; Set background tile from (BC) at XY = DE, size WH on stack, to vram from address (HL)
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/set_tile.s b/gbdk/gbdk-lib/libc/targets/sm83/set_tile.s
new file mode 100644
index 00000000..bbb472eb
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/set_tile.s
@@ -0,0 +1,60 @@
+.include "global.s"
+
+.area _CODE
+
+_set_vram_byte::
+ ; de = addr, hl = &t
+ ldhl sp,#2
+ ld a,(hl+)
+ ld e, a
+ ld a,(hl+)
+ ld d, a
+
+ WAIT_STAT
+
+ ; Write tile
+ ld a,(hl)
+ ld (de),a
+ ret
+
+_set_win_tile_xy::
+ ldh a,(.LCDC)
+ and #LCDCF_WIN9C00
+ jr z,.is98
+ jr .is9c
+_set_bkg_tile_xy::
+ ldh a,(.LCDC)
+ and #LCDCF_BG9C00
+ jr nz,.is9c
+.is98:
+ ld d,#0x98 ; DE = origin
+ jr .set_tile_xy
+.is9c:
+ ld d,#0x9C ; DE = origin
+
+.set_tile_xy:
+ push bc
+ ldhl sp,#4
+
+ ld a, (hl+)
+ ld b, a
+ ld a, (hl+)
+
+ ld e, d
+ swap a
+ rlca
+ ld c, a
+ and #0x03
+ add e
+ ld d, a
+ ld a, #0xE0
+ and c
+ add b
+ ld e, a ; dest DE = BASE + 0x20 * Y + X
+
+ WAIT_STAT
+ ld a, (hl)
+ ld (de), a
+
+ pop bc
+ ret
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/set_tile_submap.s b/gbdk/gbdk-lib/libc/targets/sm83/set_tile_submap.s
new file mode 100644
index 00000000..266b96da
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/set_tile_submap.s
@@ -0,0 +1,150 @@
+ .include "global.s"
+
+ .title "Set tile submap"
+ .module SetTileSubmap
+
+ .area _DATA
+
+.image_tile_width::
+ .ds 0x01
+
+ .area _INITIALIZED
+
+__submap_tile_offset::
+ .ds 0x01
+
+ .area _INITIALIZER
+
+ .db 0x00
+
+ .area _HOME
+
+_set_bkg_submap::
+ ldhl sp, #2
+ ld a, (hl+) ; b = x
+ ld b, a
+ ld c, (hl) ; c = y
+
+ ldhl sp, #8
+ ld a, (hl)
+ ldhl sp, #4
+ sub (hl)
+ ld (.image_tile_width), a ; .image_tile_width contains corrected width map width
+ add (hl)
+
+ ld d, #0
+ ld e, a
+ ld a, c
+ MUL_DE_BY_A_RET_HL
+ ld a, b
+ ADD_A_REG16 h, l
+ ld d, h
+ ld e, l
+
+ ldhl sp, #6
+ ld a,(hl+)
+ ld h,(hl)
+ ld l,a
+ add hl, de
+ ld b, h
+ ld c, l
+
+ ldhl sp, #2
+ ld a, (hl+) ; d = x
+ and #0x1f
+ ld d, a
+ ld a, (hl) ; e = y
+ and #0x1f
+ ld e, a
+
+ ldhl sp, #5
+ ld a,(hl-) ; a = h
+ ld h,(hl) ; h = w
+ ld l,a ; l = h
+
+ jr .set_xy_bkg_submap
+
+ ;; set window tile table from bc at xy = de of size wh = hl
+.set_xy_win_submap::
+ push hl ; store wh
+ ldh a,(.LCDC)
+ and #LCDCF_WIN9C00
+ jr z,.is98
+ jr .is9c
+ ;; set background tile table from (bc) at xy = de of size wh = hl
+.set_xy_bkg_submap::
+ push hl ; store wh
+ ldh a,(.LCDC)
+ and #LCDCF_BG9C00
+ jr nz,.is9c
+.is98:
+ ld hl,#0x9800
+ jr .set_xy_submap
+.is9c:
+ ld hl,#0x9c00
+ ;; set background tile from (bc) at xy = de, size wh on stack, to vram from address (hl)
+.set_xy_submap::
+ push bc ; store source
+
+ swap e
+ rlc e
+ ld a,e
+ and #0x03
+ add h
+ ld b,a
+ ld a,#0xe0
+ and e
+ add d
+ ld c,a ; dest bc = hl + 0x20 * y + x
+
+ pop hl ; hl = source
+ pop de ; de = wh
+ push de ; store wh
+ push bc ; store dest
+3$: ; copy w tiles
+ WAIT_STAT
+ ld a, (__submap_tile_offset)
+ add (hl)
+ ld (bc), a
+ inc hl
+
+ ld a, c ; inc dest and wrap around
+ and #0xe0
+ ld e, a
+ ld a, c
+ inc a
+ and #0x1f
+ or e
+ ld c, a
+
+ dec d
+ jr nz, 3$
+
+ ld a, (.image_tile_width)
+ ADD_A_REG16 h, l
+
+ pop bc
+ pop de
+
+ dec e
+ ret z
+
+ push de
+
+ ld a, b ; next row and wrap around
+ and #0xfc
+ ld e, a ; save high bits
+
+ ld a,#0x20
+
+ add c
+ ld c, a
+ adc b
+ sub c
+ and #0x03
+ or e ; restore high bits
+ ld b, a
+
+ push bc
+
+ jr 3$
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/set_wi_t.s b/gbdk/gbdk-lib/libc/targets/sm83/set_wi_t.s
new file mode 100644
index 00000000..0642668e
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/set_wi_t.s
@@ -0,0 +1,27 @@
+ .include "global.s"
+
+ .globl .set_xy_wtt
+
+ ;; BANKED: checked, imperfect
+ .area _HOME
+
+_set_win_tiles::
+ PUSH BC
+
+ LDA HL,4(SP) ; Skip return address and registers
+ LD A,(HL+) ; D = x
+ LD D, A
+ LD E,(HL) ; E = y
+ LDA HL,9(SP)
+ LD A,(HL-) ; BC = tiles
+ LD B, A
+ LD A,(HL-)
+ LD C, A
+ LD A,(HL-) ; A = h
+ LD H,(HL) ; H = w
+ LD L,A ; L = h
+
+ CALL .set_xy_wtt
+
+ POP BC
+ RET
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/set_win_tile_submap.s b/gbdk/gbdk-lib/libc/targets/sm83/set_win_tile_submap.s
new file mode 100644
index 00000000..04c5276b
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/set_win_tile_submap.s
@@ -0,0 +1,50 @@
+ .include "global.s"
+
+ .globl .image_tile_width, .set_xy_win_submap
+
+ .area _HOME
+
+_set_win_submap::
+ ldhl sp, #2
+ ld a, (hl+) ; b = x
+ ld b, a
+ ld c, (hl) ; c = y
+
+ ldhl sp, #8
+ ld a, (hl)
+ ldhl sp, #4
+ sub (hl)
+ ld (.image_tile_width), a ; .image_tile_width contains corrected width map width
+ add (hl)
+
+ ld d, #0
+ ld e, a
+ ld a, c
+ MUL_DE_BY_A_RET_HL
+ ld a, b
+ ADD_A_REG16 h, l
+ ld d, h
+ ld e, l
+
+ ldhl sp, #6
+ ld a,(hl+)
+ ld h,(hl)
+ ld l,a
+ add hl, de
+ ld b, h
+ ld c, l
+
+ ldhl sp, #2
+ ld a, (hl+) ; d = x
+ and #0x1f
+ ld d, a
+ ld a, (hl) ; e = y
+ and #0x1f
+ ld e, a
+
+ ldhl sp, #5
+ ld a,(hl-) ; a = h
+ ld h,(hl) ; h = w
+ ld l,a ; l = h
+
+ jp .set_xy_win_submap
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/set_xy_t.s b/gbdk/gbdk-lib/libc/targets/sm83/set_xy_t.s
new file mode 100644
index 00000000..fe164c47
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/set_xy_t.s
@@ -0,0 +1,99 @@
+ .include "global.s"
+
+ .title "Set tile map"
+ .module SetTileMap
+
+ .area _INITIALIZED
+
+__map_tile_offset::
+ .ds 0x01
+
+ .area _INITIALIZER
+
+ .db 0x00
+
+ .area _HOME
+
+ ;; Set window tile table from BC at XY = DE of size WH = HL
+.set_xy_wtt::
+ PUSH HL ; Store WH
+ LDH A,(.LCDC)
+ AND #LCDCF_WIN9C00
+ JR Z,.is98
+ JR .is9c
+ ;; Set background tile table from (BC) at XY = DE of size WH = HL
+.set_xy_btt::
+ PUSH HL ; Store WH
+ LDH A,(.LCDC)
+ AND #LCDCF_BG9C00
+ JR NZ,.is9c
+.is98:
+ LD HL,#0x9800
+ JR .set_xy_tt
+.is9c:
+ LD HL,#0x9C00
+ ;; Set background tile from (BC) at XY = DE, size WH on stack, to vram from address (HL)
+.set_xy_tt::
+ PUSH BC ; Store source
+
+ SWAP E
+ RLC E
+ LD A,E
+ AND #0x03
+ ADD H
+ LD B,A
+ LD A,#0xE0
+ AND E
+ ADD D
+ LD C,A ; dest BC = HL + 0x20 * Y + X
+
+ POP HL ; HL = source
+ POP DE ; DE = WH
+ PUSH DE ; store WH
+ PUSH BC ; store dest
+
+3$: ; Copy W tiles
+
+ WAIT_STAT
+ LD A, (__map_tile_offset)
+ ADD (HL)
+ LD (BC), A
+ INC HL
+
+ LD A, C ; inc dest and wrap around
+ AND #0xE0
+ LD E, A
+ LD A, C
+ INC A
+ AND #0x1F
+ OR E
+ LD C, A
+
+ DEC D
+ JR NZ, 3$
+
+ POP BC
+ POP DE
+
+ DEC E
+ RET Z
+
+ PUSH DE
+
+ LD A, B ; next row and wrap around
+ AND #0xFC
+ LD E, A ; save high bits
+
+ LD A,#0x20
+
+ ADD C
+ LD C, A
+ ADC B
+ SUB C
+ AND #0x03
+ OR E ; restore high bits
+ LD B, A
+
+ PUSH BC
+
+ JR 3$
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/sgb.s b/gbdk/gbdk-lib/libc/targets/sm83/sgb.s
new file mode 100644
index 00000000..aadc6d57
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/sgb.s
@@ -0,0 +1,128 @@
+ .include "global.s"
+
+ .area _CODE
+
+ ;; Check if running on SGB
+ ;; Set A to 0xFF when running on SGB
+ ;; Clear A when running on DMG
+.sgb_check::
+_sgb_check::
+ PUSH BC
+ ADD SP, #-0x10
+ LDHL SP, #0
+ LD C, #0x10
+ XOR A
+ RST 0x28
+ LDHL SP,#0
+ LD A,#((.MLT_REQ << 3) | 1)
+ LD (HL+),A
+ LD A,#0x03
+ LD (HL-),A
+ CALL .sgb_transfer
+ LD C,#.P1
+ LD A,#(.P14 | .P15)
+ LDH (C),A
+ LDH A,(C)
+ LDH A,(C)
+ LD E, #4
+ LDH A,(C) ; read delayed
+3$:
+ LD B, A
+
+ LD A,#.P15
+ LDH (C),A
+ LDH A,(C)
+ LDH A,(C)
+
+ LD A,#.P14
+ LDH (C),A
+ LDH A,(C)
+ LDH A,(C)
+
+ LD A,#(.P14 | .P15)
+ LDH (C),A
+ LDH A,(C)
+ LDH A,(C)
+ LDH A,(C)
+ LDH A,(C) ; read delayed
+ CP B
+ JR NZ,1$
+
+ DEC E
+ JR NZ,3$
+2$:
+ LD E,#0
+ JR 4$
+1$:
+ LDHL SP,#1
+ LD A,#0x00
+ LD (HL-),A
+ CALL .sgb_transfer
+ LD E,#1
+4$:
+ ADD SP,#0x10
+ POP BC
+ RET
+
+_sgb_transfer::
+ LDHL SP,#2
+ LD A,(HL+)
+ LD H,(HL)
+ LD L,A
+
+.sgb_transfer::
+ PUSH BC
+ LD A,(HL) ; Top of command data
+ AND #0x03
+ JR Z,6$
+1$:
+ PUSH AF
+ LD C,#.P1
+ LDH (C),A ; Send reset
+ LD A,#(.P14 | .P15)
+ LDH (C),A
+ LD B,#0x10 ; Set counter to transfer 16 byte
+2$: LD E,#0x08 ; Set counter to transfer 8 bit
+ LD A,(HL+)
+ LD D,A
+
+3$:
+ SRL D
+ LD A,#.P14 ; P14 = high, P15 = low (output "1")
+ JR C,4$
+ LD A,#.P15 ; P14 = low, P15 = high (output "0")
+4$:
+ LDH (C),A
+ LDH A,(C) ; delay
+ LDH A,(C)
+ LD A,#(.P14 | .P15); P14 = high, P15 = high
+ LDH (C),A
+ LDH A,(C) ; delay
+ LDH A,(C)
+ DEC E
+ JR NZ,3$
+
+ DEC B
+ JR NZ,2$
+
+ LD A,#.P15 ; 129th bit "0" output
+ LDH (C),A
+ LDH A,(C) ; delay
+ LDH A,(C)
+ LD A,#(.P14 | .P15)
+ LDH (C),A
+
+ LD DE,#8400 ; was: 7000
+5$:
+ LDH A,(.P1) ; 3 +
+ DEC DE ; 2 +
+ LD A,D ; 1 +
+ OR E ; 1 +
+ JR NZ,5$ ; 3 = 10 cycles
+
+ POP AF
+ DEC A
+ JR NZ, 1$
+6$:
+ POP BC
+ RET
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/tim.s b/gbdk/gbdk-lib/libc/targets/sm83/tim.s
new file mode 100644
index 00000000..af5563d8
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/tim.s
@@ -0,0 +1,25 @@
+ .include "global.s"
+
+ .globl .int, .int_0x50
+ .globl .add_TIM
+
+ .area _HEADER_TIM (ABS)
+
+ .org 0x50 ; TIM
+.int_TIM:
+ PUSH AF
+ PUSH HL
+ LD HL,#.int_0x50
+ JP .int
+
+ .area _HOME
+
+_add_TIM::
+ PUSH BC
+ LDA HL,4(SP) ; Skip return address and registers
+ LD C,(HL)
+ INC HL
+ LD B,(HL)
+ CALL .add_TIM
+ POP BC
+ RET
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/tim_common.s b/gbdk/gbdk-lib/libc/targets/sm83/tim_common.s
new file mode 100644
index 00000000..1893554e
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/tim_common.s
@@ -0,0 +1,28 @@
+ .include "global.s"
+
+ .globl .int, .add_int, .remove_int
+
+ .area _HOME
+
+.add_TIM::
+ LD HL,#.int_0x50
+ JP .add_int
+
+_remove_TIM::
+ PUSH BC
+ LDA HL,4(SP) ; Skip return address and registers
+ LD C,(HL)
+ INC HL
+ LD B,(HL)
+ CALL .remove_TIM
+ POP BC
+ RET
+
+.remove_TIM::
+ LD HL,#.int_0x50
+ JP .remove_int
+
+ .area _DATA
+
+.int_0x50::
+ .blkw 0x08
diff --git a/gbdk/gbdk-lib/libc/targets/sm83/tim_nested.s b/gbdk/gbdk-lib/libc/targets/sm83/tim_nested.s
new file mode 100644
index 00000000..a6ddbcca
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/sm83/tim_nested.s
@@ -0,0 +1,29 @@
+ .include "global.s"
+
+ .globl .int, .int_0x50
+ .globl .add_TIM
+
+ .area _HEADER_NESTED_TIM (ABS)
+
+ .org 0x50 ; TIM
+.int_TIM_nested:
+ EI
+ PUSH AF
+ PUSH HL
+ JP .tim_isr_jump
+
+ .area _HOME
+
+.tim_isr_jump:
+ LD HL, #.int_0x50
+ JP .int
+
+_add_low_priority_TIM::
+ PUSH BC
+ LDA HL, 4(SP) ; Skip return address and registers
+ LD C, (HL)
+ INC HL
+ LD B,(HL)
+ CALL .add_TIM
+ POP BC
+ RET
diff --git a/gbdk/gbdk-lib/libc/targets/z80/clock.s b/gbdk/gbdk-lib/libc/targets/z80/clock.s
new file mode 100644
index 00000000..c1b16d8a
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/clock.s
@@ -0,0 +1,12 @@
+ .include "global.s"
+
+ .title "System clock"
+ .module Clock
+
+ .globl .sys_time
+
+ .area _HOME
+
+_clock::
+ LD HL,(.sys_time)
+ RET
diff --git a/gbdk/gbdk-lib/libc/targets/z80/cls.s b/gbdk/gbdk-lib/libc/targets/z80/cls.s
new file mode 100644
index 00000000..9ae8e7fa
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/cls.s
@@ -0,0 +1,34 @@
+ .include "global.s"
+
+ .title "console utilities"
+ .module ConsoleUtils
+
+ .globl .curx, .cury
+
+ .area _HOME
+
+_cls::
+ ld a, #.SCREEN_X_OFS
+ ld (.curx), a
+ ld a, #.SCREEN_Y_OFS
+ ld (.cury), a
+
+ DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT
+
+ ld hl, #(.VDP_TILEMAP + ((.SCREEN_Y_OFS * .VDP_MAP_WIDTH) * 2))
+ WRITE_VDP_CMD_HL
+
+ ld hl, #.SPACE
+ ld bc, #(.SCREEN_HEIGHT * .VDP_MAP_WIDTH)
+ inc b
+ inc c
+ jr 1$
+2$:
+ WRITE_VDP_DATA_HL
+1$:
+ dec c
+ jr nz, 2$
+ djnz 2$
+
+ ENABLE_VBLANK_COPY ; switch ON copy shadow SAT
+ ret \ No newline at end of file
diff --git a/gbdk/gbdk-lib/libc/targets/z80/color.s b/gbdk/gbdk-lib/libc/targets/z80/color.s
new file mode 100644
index 00000000..d65ed1ed
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/color.s
@@ -0,0 +1,17 @@
+ .include "global.s"
+
+ .title "Colors"
+ .module colors
+
+ .area _INITIALIZED
+
+__current_1bpp_colors::
+.fg_colour::
+ .ds 1
+.bg_colour::
+ .ds 1
+
+ .area _INITIALIZER
+
+ .db 0x03 ; .fg_colour
+ .db 0x00 ; .bg_color
diff --git a/gbdk/gbdk-lib/libc/targets/z80/coords_to_address.s b/gbdk/gbdk-lib/libc/targets/z80/coords_to_address.s
new file mode 100644
index 00000000..7c30c835
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/coords_to_address.s
@@ -0,0 +1,47 @@
+ .include "global.s"
+
+ .title "VRAM utilities"
+ .module VRAMUtils
+
+ .area _HOME
+
+; translate coords in DE and given base in BC into address in DE
+.coords_to_address::
+ ld a, d
+ add #.SCREEN_Y_OFS
+ ld d, a
+ xor a
+ FAST_MOD8 d #28
+ ld d, a
+
+ ld a, e
+ add #.SCREEN_X_OFS
+ and #0x1f
+ ld e, a
+
+ ld a, d
+ rrca ; rrca(2) == rlca(6)
+ rrca
+ ld d, a
+ and #0x07
+ add b
+ ld b, a
+ ld a, #0xC0
+ and d
+ sla e
+ add e
+ ld e, a
+ ld d, b ; dest DE = BC + ((0x20 * Y) * 2) + (X * 2)
+
+ ret
+
+; uint8_t * get_bkg_xy_addr(uint8_t x, uint8_t y) __z88dk_callee __preserves_regs(iyh, iyl);
+
+_get_bkg_xy_addr::
+ pop hl
+ ex (sp), hl
+ ex de, hl
+ ld bc, #.VDP_TILEMAP
+ call .coords_to_address
+ ex de, hl
+ ret \ No newline at end of file
diff --git a/gbdk/gbdk-lib/libc/targets/z80/delay.s b/gbdk/gbdk-lib/libc/targets/z80/delay.s
new file mode 100644
index 00000000..ccb36518
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/delay.s
@@ -0,0 +1,53 @@
+ .include "global.s"
+
+ .title "Delay"
+ .module delay
+
+ .area _CODE
+
+;; hl must contain amount of tstates, which must be >= 141
+wait_hl_tstates::
+ ld bc, #-141
+ add hl, bc
+ ld bc, #-23
+1$:
+ add hl,bc
+ jr c, 1$
+ ld a, l
+ add a, #15
+ jr nc, 2$
+ cp #8
+ jr c, 3$
+ or #0
+2$:
+ inc hl
+3$:
+ rra
+ jr c, 4$
+ nop
+4$:
+ rra
+ jr nc, 5$
+ or #0
+5$:
+ rra
+ ret nc
+ ret
+
+;; hl = milliseconds (0 = 65536)
+_delay::
+ ld e, l
+ ld d, h
+1$:
+ dec de
+ ld a,d
+ or e
+ jr z, 2$
+
+ ld hl,#((.CPU_CLOCK / 1000) - 43)
+ call wait_hl_tstates
+ jr 1$
+2$:
+ ld hl,#((.CPU_CLOCK / 1000) - 54)
+ jp wait_hl_tstates
+ ret \ No newline at end of file
diff --git a/gbdk/gbdk-lib/libc/targets/z80/emu_debug_printf.s b/gbdk/gbdk-lib/libc/targets/z80/emu_debug_printf.s
new file mode 100644
index 00000000..66e73be0
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/emu_debug_printf.s
@@ -0,0 +1,44 @@
+ .include "global.s"
+
+ .title "EMU_debug"
+ .module EMU_debug
+
+ .globl _sprintf
+
+ .area _DATA
+
+ret_save:
+ .ds 0x02
+printf_buffer:
+ .ds 0x80
+
+ .area _HOME
+
+ ;; EMU_printf(fmt, ...)
+_EMU_printf::
+ di
+ pop de
+ ld hl, #ret_save
+ ld (hl), e
+ inc hl
+ ld (hl), d
+
+ ld de, #printf_buffer
+ push de
+ call _sprintf
+ pop hl
+
+ ld d,d
+ jr 1$
+ .dw 0x6464
+ .dw 0x0001
+ .dw #printf_buffer
+ .dw 0
+1$:
+ ld hl, #ret_save
+ ld a, (hl)
+ inc hl
+ ld h, (hl)
+ ld l, a
+ ei
+ jp (hl)
diff --git a/gbdk/gbdk-lib/libc/targets/z80/f_ibm_full.s b/gbdk/gbdk-lib/libc/targets/z80/f_ibm_full.s
new file mode 100644
index 00000000..d7f09b18
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/f_ibm_full.s
@@ -0,0 +1,2616 @@
+; font: font
+
+ .area _HOME
+
+ .globl font_load
+ ;; Perform tricks with banking to shift this font out of
+ ;; bank 0. Doesnt currently work as the encoding table
+ ;; must always be visible.
+_font_load_ibm_fixed:: ; Banked
+ ld hl,#_font_ibm_fixed
+ call font_load
+ ret
+
+_font_ibm_fixed::
+ .db 0+4 ; 256 char encoding, compressed
+ .db 255 ; Number of tiles
+
+; Encoding table
+
+ ; Hack
+ .db 0x00
+ .db 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08
+ .db 0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,0x10
+ .db 0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18
+ .db 0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,0x20
+ .db 0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28
+ .db 0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,0x30
+ .db 0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38
+ .db 0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F,0x40
+ .db 0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48
+ .db 0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F,0x50
+ .db 0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58
+ .db 0x59,0x5A,0x5B,0x5C,0x5D,0x5E,0x5F,0x60
+ .db 0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68
+ .db 0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F,0x70
+ .db 0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78
+ .db 0x79,0x7A,0x7B,0x7C,0x7D,0x7E,0x7F,0x80
+ .db 0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88
+ .db 0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90
+ .db 0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98
+ .db 0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,0xA0
+ .db 0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8
+ .db 0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0
+ .db 0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8
+ .db 0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF,0xC0
+ .db 0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8
+ .db 0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0
+ .db 0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8
+ .db 0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF,0xE0
+ .db 0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8
+ .db 0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0
+ .db 0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8
+ .db 0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF
+ ; Tile data
+ ;; Hook for the graphics routines
+_font_ibm_fixed_tiles::
+; Default character (space)
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+
+; Character: ? (01)
+ .db 0b00011000 ; oo
+ .db 0b00100100 ; o o
+ .db 0b01000010 ; o o
+ .db 0b10000001 ; o o
+ .db 0b11100111 ; ooo ooo
+ .db 0b00100100 ; o o
+ .db 0b00100100 ; o o
+ .db 0b00111100 ; oooo
+
+; Character: ? (02)
+ .db 0b00111100 ; oooo
+ .db 0b00100100 ; o o
+ .db 0b00100100 ; o o
+ .db 0b11100111 ; ooo ooo
+ .db 0b10000001 ; o o
+ .db 0b01000010 ; o o
+ .db 0b00100100 ; o o
+ .db 0b00011000 ; oo
+
+; Character: ? (03)
+ .db 0b00011000 ; oo
+ .db 0b00010100 ; o o
+ .db 0b11110010 ; oooo o
+ .db 0b10000001 ; o o
+ .db 0b10000001 ; o o
+ .db 0b11110010 ; oooo o
+ .db 0b00010100 ; o o
+ .db 0b00011000 ; oo
+
+; Character: ? (04)
+ .db 0b00011000 ; oo
+ .db 0b00101000 ; o o
+ .db 0b01001111 ; o oooo
+ .db 0b10000001 ; o o
+ .db 0b10000001 ; o o
+ .db 0b01001111 ; o oooo
+ .db 0b00101000 ; o o
+ .db 0b00011000 ; oo
+
+; Character: ? (05)
+ .db 0b11111111 ; oooooooo
+ .db 0b10000001 ; o o
+ .db 0b10000001 ; o o
+ .db 0b10000001 ; o o
+ .db 0b10000001 ; o o
+ .db 0b10000001 ; o o
+ .db 0b10000001 ; o o
+ .db 0b11111111 ; oooooooo
+
+; Character: ? (06)
+ .db 0b11111000 ; ooooo
+ .db 0b10001000 ; o o
+ .db 0b10001111 ; o oooo
+ .db 0b10001001 ; o o o
+ .db 0b11111001 ; ooooo o
+ .db 0b01000001 ; o o
+ .db 0b01000001 ; o o
+ .db 0b01111111 ; ooooooo
+
+; Character: ? (07)
+ .db 0b11111111 ; oooooooo
+ .db 0b10001001 ; o o o
+ .db 0b10001001 ; o o o
+ .db 0b10001001 ; o o o
+ .db 0b11111001 ; ooooo o
+ .db 0b10000001 ; o o
+ .db 0b10000001 ; o o
+ .db 0b11111111 ; oooooooo
+
+; Character: ? (08)
+ .db 0b00000001 ; o
+ .db 0b00000011 ; oo
+ .db 0b00000110 ; oo
+ .db 0b10001100 ; o oo
+ .db 0b11011000 ; oo oo
+ .db 0b01110000 ; ooo
+ .db 0b00100000 ; o
+ .db 0b00000000 ;
+
+; Character: ? (09)
+ .db 0b01111110 ; oooooo
+ .db 0b11000011 ; oo oo
+ .db 0b11010011 ; oo o oo
+ .db 0b11010011 ; oo o oo
+ .db 0b11011011 ; oo oo oo
+ .db 0b11000011 ; oo oo
+ .db 0b11000011 ; oo oo
+ .db 0b01111110 ; oooooo
+
+; Character: ? (0A)
+ .db 0b00011000 ; oo
+ .db 0b00111100 ; oooo
+ .db 0b00101100 ; o oo
+ .db 0b00101100 ; o oo
+ .db 0b01111110 ; oooooo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+
+; Character: ? (0B)
+ .db 0b00010000 ; o
+ .db 0b00011100 ; ooo
+ .db 0b00010010 ; o o
+ .db 0b00010000 ; o
+ .db 0b00010000 ; o
+ .db 0b01110000 ; ooo
+ .db 0b11110000 ; oooo
+ .db 0b01100000 ; oo
+
+; Character: ? (0C)
+ .db 0b11110000 ; oooo
+ .db 0b11000000 ; oo
+ .db 0b11111110 ; ooooooo
+ .db 0b11011000 ; oo oo
+ .db 0b11011110 ; oo oooo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+
+; Character: ? (0D)
+ .db 0b01110000 ; ooo
+ .db 0b11001000 ; oo o
+ .db 0b11011110 ; oo oooo
+ .db 0b11011011 ; oo oo oo
+ .db 0b11011011 ; oo oo oo
+ .db 0b01111110 ; oooooo
+ .db 0b00011011 ; oo oo
+ .db 0b00011011 ; oo oo
+
+; Character: ? (0E)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b11111111 ; oooooooo
+ .db 0b11111111 ; oooooooo
+ .db 0b11111111 ; oooooooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (0F)
+ .db 0b00011100 ; ooo
+ .db 0b00011100 ; ooo
+ .db 0b00011100 ; ooo
+ .db 0b00011100 ; ooo
+ .db 0b00011100 ; ooo
+ .db 0b00011100 ; ooo
+ .db 0b00011100 ; ooo
+ .db 0b00011100 ; ooo
+
+; Character: ? (10)
+ .db 0b01111100 ; ooooo
+ .db 0b11000110 ; oo oo
+ .db 0b11000110 ; oo oo
+ .db 0b00000000 ;
+ .db 0b11000110 ; oo oo
+ .db 0b11000110 ; oo oo
+ .db 0b01111100 ; ooooo
+ .db 0b00000000 ;
+
+; Character: ? (11)
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00000000 ;
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00000000 ;
+
+; Character: ? (12)
+ .db 0b01111100 ; ooooo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b01111100 ; ooooo
+ .db 0b11000000 ; oo
+ .db 0b11000000 ; oo
+ .db 0b01111100 ; ooooo
+ .db 0b00000000 ;
+
+; Character: ? (13)
+ .db 0b01111100 ; ooooo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b01111100 ; ooooo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b01111100 ; ooooo
+ .db 0b00000000 ;
+
+; Character: ? (14)
+ .db 0b11000110 ; oo oo
+ .db 0b11000110 ; oo oo
+ .db 0b11000110 ; oo oo
+ .db 0b01111100 ; ooooo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00000000 ;
+
+; Character: ? (15)
+ .db 0b01111100 ; ooooo
+ .db 0b11000000 ; oo
+ .db 0b11000000 ; oo
+ .db 0b01111100 ; ooooo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b01111100 ; ooooo
+ .db 0b00000000 ;
+
+; Character: ? (16)
+ .db 0b01111100 ; ooooo
+ .db 0b11000000 ; oo
+ .db 0b11000000 ; oo
+ .db 0b01111100 ; ooooo
+ .db 0b11000110 ; oo oo
+ .db 0b11000110 ; oo oo
+ .db 0b01111100 ; ooooo
+ .db 0b00000000 ;
+
+; Character: ? (17)
+ .db 0b01111100 ; ooooo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00000000 ;
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00000000 ;
+
+; Character: ? (18)
+ .db 0b01111100 ; ooooo
+ .db 0b11000110 ; oo oo
+ .db 0b11000110 ; oo oo
+ .db 0b01111100 ; ooooo
+ .db 0b11000110 ; oo oo
+ .db 0b11000110 ; oo oo
+ .db 0b01111100 ; ooooo
+ .db 0b00000000 ;
+
+; Character: ? (19)
+ .db 0b01111100 ; ooooo
+ .db 0b11000110 ; oo oo
+ .db 0b11000110 ; oo oo
+ .db 0b01111100 ; ooooo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b01111100 ; ooooo
+ .db 0b00000000 ;
+
+; Character: ? (1A)
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01000110 ; o oo
+ .db 0b00000110 ; oo
+ .db 0b01111110 ; oooooo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: ? (1B)
+ .db 0b01111000 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01111101 ; ooooo o
+ .db 0b01100100 ; oo o
+ .db 0b01111110 ; oooooo
+ .db 0b00000011 ; oo
+ .db 0b00001011 ; o oo
+ .db 0b00000110 ; oo
+
+; Character: ? (1C)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00011111 ; ooooo
+ .db 0b00011111 ; ooooo
+ .db 0b00011111 ; ooooo
+ .db 0b00011100 ; ooo
+ .db 0b00011100 ; ooo
+
+; Character: ? (1D)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b11111100 ; oooooo
+ .db 0b11111100 ; oooooo
+ .db 0b11111100 ; oooooo
+ .db 0b00011100 ; ooo
+ .db 0b00011100 ; ooo
+
+; Character: ? (1E)
+ .db 0b00011100 ; ooo
+ .db 0b00011100 ; ooo
+ .db 0b00011100 ; ooo
+ .db 0b00011111 ; ooooo
+ .db 0b00011111 ; ooooo
+ .db 0b00011111 ; ooooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (1F)
+ .db 0b00011100 ; ooo
+ .db 0b00011100 ; ooo
+ .db 0b00011100 ; ooo
+ .db 0b11111100 ; oooooo
+ .db 0b11111100 ; oooooo
+ .db 0b11111100 ; oooooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: (20)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ! (21)
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+
+; Character: " (22)
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01000100 ; o o
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: # (23)
+ .db 0b00000000 ;
+ .db 0b00100100 ; o o
+ .db 0b01111110 ; oooooo
+ .db 0b00100100 ; o o
+ .db 0b00100100 ; o o
+ .db 0b01111110 ; oooooo
+ .db 0b00100100 ; o o
+ .db 0b00000000 ;
+
+; Character: $ (24)
+ .db 0b00010100 ; o o
+ .db 0b00111110 ; ooooo
+ .db 0b01010101 ; o o o o
+ .db 0b00111100 ; oooo
+ .db 0b00011110 ; oooo
+ .db 0b01010101 ; o o o o
+ .db 0b00111110 ; ooooo
+ .db 0b00010100 ; o o
+
+; Character: % (25)
+ .db 0b01100010 ; oo o
+ .db 0b01100110 ; oo oo
+ .db 0b00001100 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00110000 ; oo
+ .db 0b01100110 ; oo oo
+ .db 0b01000110 ; o oo
+ .db 0b00000000 ;
+
+; Character: & (26)
+ .db 0b01111000 ; oooo
+ .db 0b11001100 ; oo oo
+ .db 0b01100001 ; oo o
+ .db 0b11001110 ; oo ooo
+ .db 0b11001100 ; oo oo
+ .db 0b11001100 ; oo oo
+ .db 0b01111000 ; oooo
+ .db 0b00000000 ;
+
+; Character: ' (27)
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00010000 ; o
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ( (28)
+ .db 0b00000100 ; o
+ .db 0b00001000 ; o
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00001000 ; o
+ .db 0b00000100 ; o
+
+; Character: ) (29)
+ .db 0b00100000 ; o
+ .db 0b00010000 ; o
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00010000 ; o
+ .db 0b00100000 ; o
+
+; Character: * (2A)
+ .db 0b00000000 ;
+ .db 0b01010100 ; o o o
+ .db 0b00111000 ; ooo
+ .db 0b11111110 ; ooooooo
+ .db 0b00111000 ; ooo
+ .db 0b01010100 ; o o o
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: + (2B)
+ .db 0b00000000 ;
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b01111110 ; oooooo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: , (2C)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00110000 ; oo
+ .db 0b00110000 ; oo
+ .db 0b00100000 ; o
+
+; Character: - (2D)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: . (2E)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+
+; Character: / (2F)
+ .db 0b00000011 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00110000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b11000000 ; oo
+ .db 0b00000000 ;
+
+; Character: 0 (30)
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01101110 ; oo ooo
+ .db 0b01110110 ; ooo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: 1 (31)
+ .db 0b00011000 ; oo
+ .db 0b00111000 ; ooo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+
+; Character: 2 (32)
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b00001110 ; ooo
+ .db 0b00011100 ; ooo
+ .db 0b00111000 ; ooo
+ .db 0b01110000 ; ooo
+ .db 0b01111110 ; oooooo
+ .db 0b00000000 ;
+
+; Character: 3 (33)
+ .db 0b01111110 ; oooooo
+ .db 0b00001100 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00111100 ; oooo
+ .db 0b00000110 ; oo
+ .db 0b01000110 ; o oo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: 4 (34)
+ .db 0b00001100 ; oo
+ .db 0b00011100 ; ooo
+ .db 0b00101100 ; o oo
+ .db 0b01001100 ; o oo
+ .db 0b01111110 ; oooooo
+ .db 0b00001100 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00000000 ;
+
+; Character: 5 (35)
+ .db 0b01111110 ; oooooo
+ .db 0b01100000 ; oo
+ .db 0b01111100 ; ooooo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b01000110 ; o oo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: 6 (36)
+ .db 0b00011100 ; ooo
+ .db 0b00100000 ; o
+ .db 0b01100000 ; oo
+ .db 0b01111100 ; ooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: 7 (37)
+ .db 0b01111110 ; oooooo
+ .db 0b00000110 ; oo
+ .db 0b00001110 ; ooo
+ .db 0b00011100 ; ooo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+
+; Character: 8 (38)
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: 9 (39)
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111110 ; ooooo
+ .db 0b00000110 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00111000 ; ooo
+ .db 0b00000000 ;
+
+; Character: : (3A)
+ .db 0b00000000 ;
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+
+; Character: ; (3B)
+ .db 0b00000000 ;
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00010000 ; o
+ .db 0b00000000 ;
+
+; Character: < (3C)
+ .db 0b00000110 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00110000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00000000 ;
+
+; Character: = (3D)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: > (3E)
+ .db 0b01100000 ; oo
+ .db 0b00110000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00110000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b00000000 ;
+
+; Character: ? (3F)
+ .db 0b00111100 ; oooo
+ .db 0b01000110 ; o oo
+ .db 0b00000110 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+ .db 0b00011000 ; oo
+
+; Character: @ (40)
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01101110 ; oo ooo
+ .db 0b01101010 ; oo o o
+ .db 0b01101110 ; oo ooo
+ .db 0b01100000 ; oo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: A (41)
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01111110 ; oooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00000000 ;
+
+; Character: B (42)
+ .db 0b01111100 ; ooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01111100 ; ooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01111100 ; ooooo
+ .db 0b00000000 ;
+
+; Character: C (43)
+ .db 0b00111100 ; oooo
+ .db 0b01100010 ; oo o
+ .db 0b01100000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b01100010 ; oo o
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: D (44)
+ .db 0b01111100 ; ooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01111100 ; ooooo
+ .db 0b00000000 ;
+
+; Character: E (45)
+ .db 0b01111110 ; oooooo
+ .db 0b01100000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b01111100 ; ooooo
+ .db 0b01100000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b01111110 ; oooooo
+ .db 0b00000000 ;
+
+; Character: F (46)
+ .db 0b01111110 ; oooooo
+ .db 0b01100000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b01111100 ; ooooo
+ .db 0b01100000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b00000000 ;
+
+; Character: G (47)
+ .db 0b00111100 ; oooo
+ .db 0b01100010 ; oo o
+ .db 0b01100000 ; oo
+ .db 0b01101110 ; oo ooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111110 ; ooooo
+ .db 0b00000000 ;
+
+; Character: H (48)
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01111110 ; oooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00000000 ;
+
+; Character: I (49)
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+
+; Character: J (4A)
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b01000110 ; o oo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: K (4B)
+ .db 0b01100110 ; oo oo
+ .db 0b01101100 ; oo oo
+ .db 0b01111000 ; oooo
+ .db 0b01110000 ; ooo
+ .db 0b01111000 ; oooo
+ .db 0b01101100 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00000000 ;
+
+; Character: L (4C)
+ .db 0b01100000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b01111100 ; ooooo
+ .db 0b00000000 ;
+
+; Character: M (4D)
+ .db 0b11111100 ; oooooo
+ .db 0b11010110 ; oo o oo
+ .db 0b11010110 ; oo o oo
+ .db 0b11010110 ; oo o oo
+ .db 0b11010110 ; oo o oo
+ .db 0b11000110 ; oo oo
+ .db 0b11000110 ; oo oo
+ .db 0b00000000 ;
+
+; Character: N (4E)
+ .db 0b01100010 ; oo o
+ .db 0b01110010 ; ooo o
+ .db 0b01111010 ; oooo o
+ .db 0b01011110 ; o oooo
+ .db 0b01001110 ; o ooo
+ .db 0b01000110 ; o oo
+ .db 0b01000010 ; o o
+ .db 0b00000000 ;
+
+; Character: O (4F)
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: P (50)
+ .db 0b01111100 ; ooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01111100 ; ooooo
+ .db 0b01100000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b00000000 ;
+
+; Character: Q (51)
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b00000110 ; oo
+
+; Character: R (52)
+ .db 0b01111100 ; ooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01111100 ; ooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00000000 ;
+
+; Character: S (53)
+ .db 0b00111100 ; oooo
+ .db 0b01100010 ; oo o
+ .db 0b01110000 ; ooo
+ .db 0b00111100 ; oooo
+ .db 0b00001110 ; ooo
+ .db 0b01000110 ; o oo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: T (54)
+ .db 0b01111110 ; oooooo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+
+; Character: U (55)
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: V (56)
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100100 ; oo o
+ .db 0b01111000 ; oooo
+ .db 0b00000000 ;
+
+; Character: W (57)
+ .db 0b11000110 ; oo oo
+ .db 0b11000110 ; oo oo
+ .db 0b11000110 ; oo oo
+ .db 0b11010110 ; oo o oo
+ .db 0b11010110 ; oo o oo
+ .db 0b11010110 ; oo o oo
+ .db 0b11111100 ; oooooo
+ .db 0b00000000 ;
+
+; Character: X (58)
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00000000 ;
+
+; Character: Y (59)
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+
+; Character: Z (5A)
+ .db 0b01111110 ; oooooo
+ .db 0b00001110 ; ooo
+ .db 0b00011100 ; ooo
+ .db 0b00111000 ; ooo
+ .db 0b01110000 ; ooo
+ .db 0b01100000 ; oo
+ .db 0b01111110 ; oooooo
+ .db 0b00000000 ;
+
+; Character: [ (5B)
+ .db 0b00011110 ; oooo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011110 ; oooo
+ .db 0b00000000 ;
+
+; Character: \ (5C)
+ .db 0b01000000 ; o
+ .db 0b01100000 ; oo
+ .db 0b00110000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00000010 ; o
+ .db 0b00000000 ;
+
+; Character: ] (5D)
+ .db 0b01111000 ; oooo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b01111000 ; oooo
+ .db 0b00000000 ;
+
+; Character: ^ (5E)
+ .db 0b00010000 ; o
+ .db 0b00111000 ; ooo
+ .db 0b01101100 ; oo oo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: _ (5F)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b01111110 ; oooooo
+ .db 0b00000000 ;
+
+; Character: ` (60)
+ .db 0b00000000 ;
+ .db 0b11000000 ; oo
+ .db 0b11000000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: a (61)
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01000110 ; o oo
+ .db 0b00111110 ; ooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111110 ; ooooo
+ .db 0b00000000 ;
+
+; Character: b (62)
+ .db 0b01100000 ; oo
+ .db 0b01111100 ; ooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01111100 ; ooooo
+ .db 0b00000000 ;
+
+; Character: c (63)
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01100010 ; oo o
+ .db 0b01100000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b01100010 ; oo o
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: d (64)
+ .db 0b00000110 ; oo
+ .db 0b00111110 ; ooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111110 ; ooooo
+ .db 0b00000000 ;
+
+; Character: e (65)
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01111110 ; oooooo
+ .db 0b01100000 ; oo
+ .db 0b01100010 ; oo o
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: f (66)
+ .db 0b00011110 ; oooo
+ .db 0b00110000 ; oo
+ .db 0b01111100 ; ooooo
+ .db 0b00110000 ; oo
+ .db 0b00110000 ; oo
+ .db 0b00110000 ; oo
+ .db 0b00110000 ; oo
+ .db 0b00000000 ;
+
+; Character: g (67)
+ .db 0b00000000 ;
+ .db 0b00111110 ; ooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111110 ; ooooo
+ .db 0b01000110 ; o oo
+ .db 0b00111100 ; oooo
+
+; Character: h (68)
+ .db 0b01100000 ; oo
+ .db 0b01111100 ; ooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00000000 ;
+
+; Character: i (69)
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+
+; Character: j (6A)
+ .db 0b00000000 ;
+ .db 0b00001000 ; o
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b01011000 ; o oo
+ .db 0b00110000 ; oo
+
+; Character: k (6B)
+ .db 0b01100000 ; oo
+ .db 0b01100100 ; oo o
+ .db 0b01101000 ; oo o
+ .db 0b01110000 ; ooo
+ .db 0b01111000 ; oooo
+ .db 0b01101100 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00000000 ;
+
+; Character: l (6C)
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00000000 ;
+
+; Character: m (6D)
+ .db 0b00000000 ;
+ .db 0b11111100 ; oooooo
+ .db 0b11010110 ; oo o oo
+ .db 0b11010110 ; oo o oo
+ .db 0b11010110 ; oo o oo
+ .db 0b11010110 ; oo o oo
+ .db 0b11000110 ; oo oo
+ .db 0b00000000 ;
+
+; Character: n (6E)
+ .db 0b00000000 ;
+ .db 0b01111100 ; ooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00000000 ;
+
+; Character: o (6F)
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: p (70)
+ .db 0b00000000 ;
+ .db 0b01111100 ; ooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01111100 ; ooooo
+ .db 0b01100000 ; oo
+ .db 0b01100000 ; oo
+
+; Character: q (71)
+ .db 0b00000000 ;
+ .db 0b00111110 ; ooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111110 ; ooooo
+ .db 0b00000110 ; oo
+
+; Character: r (72)
+ .db 0b00000000 ;
+ .db 0b01101100 ; oo oo
+ .db 0b01110000 ; ooo
+ .db 0b01100000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b00000000 ;
+
+; Character: s (73)
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01110010 ; ooo o
+ .db 0b00111000 ; ooo
+ .db 0b00011100 ; ooo
+ .db 0b01001110 ; o ooo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: t (74)
+ .db 0b00011000 ; oo
+ .db 0b00111100 ; oooo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00000000 ;
+
+; Character: u (75)
+ .db 0b00000000 ;
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111110 ; ooooo
+ .db 0b00000000 ;
+
+; Character: v (76)
+ .db 0b00000000 ;
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100100 ; oo o
+ .db 0b01111000 ; oooo
+ .db 0b00000000 ;
+
+; Character: w (77)
+ .db 0b00000000 ;
+ .db 0b11000110 ; oo oo
+ .db 0b11000110 ; oo oo
+ .db 0b11010110 ; oo o oo
+ .db 0b11010110 ; oo o oo
+ .db 0b11010110 ; oo o oo
+ .db 0b11111100 ; oooooo
+ .db 0b00000000 ;
+
+; Character: x (78)
+ .db 0b00000000 ;
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00000000 ;
+
+; Character: y (79)
+ .db 0b00000000 ;
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00100110 ; o oo
+ .db 0b00011110 ; oooo
+ .db 0b01000110 ; o oo
+ .db 0b00111100 ; oooo
+
+; Character: z (7A)
+ .db 0b00000000 ;
+ .db 0b01111110 ; oooooo
+ .db 0b00001110 ; ooo
+ .db 0b00011100 ; ooo
+ .db 0b00111000 ; ooo
+ .db 0b01110000 ; ooo
+ .db 0b01111110 ; oooooo
+ .db 0b00000000 ;
+
+; Character: { (7B)
+ .db 0b00001110 ; ooo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00110000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00001110 ; ooo
+ .db 0b00000000 ;
+
+; Character: | (7C)
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+
+; Character: } (7D)
+ .db 0b01110000 ; ooo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b01110000 ; ooo
+ .db 0b00000000 ;
+
+; Character: ~ (7E)
+ .db 0b00000000 ;
+ .db 0b01100000 ; oo
+ .db 0b11110010 ; oooo o
+ .db 0b10011110 ; o oooo
+ .db 0b00001100 ; oo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (7F)
+ .db 0b00010000 ; o
+ .db 0b00010000 ; o
+ .db 0b00101000 ; o o
+ .db 0b00101000 ; o o
+ .db 0b01000100 ; o o
+ .db 0b01000100 ; o o
+ .db 0b10000010 ; o o
+ .db 0b11111110 ; ooooooo
+
+; Character: ? (80)
+ .db 0b00111100 ; oooo
+ .db 0b01100010 ; oo o
+ .db 0b01100000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b01100010 ; oo o
+ .db 0b00011100 ; ooo
+ .db 0b00110000 ; oo
+
+; Character: ? (81)
+ .db 0b00100100 ; o o
+ .db 0b00000000 ;
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111110 ; ooooo
+ .db 0b00000000 ;
+
+; Character: ? (82)
+ .db 0b00001100 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01111110 ; oooooo
+ .db 0b01100000 ; oo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: ? (83)
+ .db 0b00011000 ; oo
+ .db 0b01100110 ; oo oo
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b00000110 ; oo
+ .db 0b01111110 ; oooooo
+ .db 0b00111110 ; ooooo
+ .db 0b00000000 ;
+
+; Character: ? (84)
+ .db 0b00100100 ; o o
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01000110 ; o oo
+ .db 0b00111110 ; ooooo
+ .db 0b01000110 ; o oo
+ .db 0b00111110 ; ooooo
+ .db 0b00000000 ;
+
+; Character: ? (85)
+ .db 0b00110000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b00000110 ; oo
+ .db 0b01111110 ; oooooo
+ .db 0b00111110 ; ooooo
+ .db 0b00000000 ;
+
+; Character: ? (86)
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b00000110 ; oo
+ .db 0b01111110 ; oooooo
+ .db 0b00111110 ; ooooo
+ .db 0b00000000 ;
+
+; Character: ? (87)
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01100010 ; oo o
+ .db 0b01100000 ; oo
+ .db 0b01100010 ; oo o
+ .db 0b00111100 ; oooo
+ .db 0b00001000 ; o
+ .db 0b00011000 ; oo
+
+; Character: ? (88)
+ .db 0b00011000 ; oo
+ .db 0b00110100 ; oo o
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01111110 ; oooooo
+ .db 0b01100000 ; oo
+ .db 0b00111110 ; ooooo
+ .db 0b00000000 ;
+
+; Character: ? (89)
+ .db 0b00100100 ; o o
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01111110 ; oooooo
+ .db 0b01100000 ; oo
+ .db 0b00111110 ; ooooo
+ .db 0b00000000 ;
+
+; Character: ? (8A)
+ .db 0b00110000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01111110 ; oooooo
+ .db 0b01100000 ; oo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: ? (8B)
+ .db 0b00100100 ; o o
+ .db 0b00000000 ;
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+
+; Character: ? (8C)
+ .db 0b00011000 ; oo
+ .db 0b00100100 ; o o
+ .db 0b00000000 ;
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+
+; Character: ? (8D)
+ .db 0b00010000 ; o
+ .db 0b00001000 ; o
+ .db 0b00000000 ;
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+
+; Character: ? (8E)
+ .db 0b00100100 ; o o
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01111110 ; oooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00000000 ;
+
+; Character: ? (8F)
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01111110 ; oooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00000000 ;
+
+; Character: ? (90)
+ .db 0b00001100 ; oo
+ .db 0b00011000 ; oo
+ .db 0b01111110 ; oooooo
+ .db 0b01100000 ; oo
+ .db 0b01111100 ; ooooo
+ .db 0b01100000 ; oo
+ .db 0b01111110 ; oooooo
+ .db 0b00000000 ;
+
+; Character: ? (91)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b01111110 ; oooooo
+ .db 0b00011011 ; oo oo
+ .db 0b01111111 ; ooooooo
+ .db 0b11011000 ; oo oo
+ .db 0b01111110 ; oooooo
+ .db 0b00000000 ;
+
+; Character: ? (92)
+ .db 0b00111111 ; oooooo
+ .db 0b01111000 ; oooo
+ .db 0b11011000 ; oo oo
+ .db 0b11011110 ; oo oooo
+ .db 0b11111000 ; ooooo
+ .db 0b11011000 ; oo oo
+ .db 0b11011111 ; oo ooooo
+ .db 0b00000000 ;
+
+; Character: ? (93)
+ .db 0b00011000 ; oo
+ .db 0b00110100 ; oo o
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: ? (94)
+ .db 0b00100100 ; o o
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: ? (95)
+ .db 0b00110000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: ? (96)
+ .db 0b00011000 ; oo
+ .db 0b00100100 ; o o
+ .db 0b00000000 ;
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: ? (97)
+ .db 0b00110000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: ? (98)
+ .db 0b01100110 ; oo oo
+ .db 0b00000000 ;
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111110 ; ooooo
+ .db 0b01000110 ; o oo
+ .db 0b00111100 ; oooo
+
+; Character: ? (99)
+ .db 0b01100110 ; oo oo
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: ? (9A)
+ .db 0b01100110 ; oo oo
+ .db 0b00000000 ;
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: ? (9B)
+ .db 0b00011000 ; oo
+ .db 0b00111100 ; oooo
+ .db 0b01100010 ; oo o
+ .db 0b01100000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b01100010 ; oo o
+ .db 0b00111100 ; oooo
+ .db 0b00011000 ; oo
+
+; Character: ? (9C)
+ .db 0b00011100 ; ooo
+ .db 0b00111010 ; ooo o
+ .db 0b00110000 ; oo
+ .db 0b01111100 ; ooooo
+ .db 0b00110000 ; oo
+ .db 0b00110000 ; oo
+ .db 0b01111110 ; oooooo
+ .db 0b00000000 ;
+
+; Character: ? (9D)
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b00011000 ; oo
+ .db 0b00111100 ; oooo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+
+; Character: ? (9E)
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01101100 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b11101100 ; ooo oo
+ .db 0b00000000 ;
+
+; Character: ? (9F)
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+
+; Character: ? (A0)
+ .db 0b00001100 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b00000110 ; oo
+ .db 0b01111110 ; oooooo
+ .db 0b00111110 ; ooooo
+ .db 0b00000000 ;
+
+; Character: ? (A1)
+ .db 0b00001100 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+
+; Character: ? (A2)
+ .db 0b00001100 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: ? (A3)
+ .db 0b00001100 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111110 ; ooooo
+ .db 0b00000000 ;
+
+; Character: ? (A4)
+ .db 0b00110100 ; oo o
+ .db 0b01011000 ; o oo
+ .db 0b00000000 ;
+ .db 0b01111100 ; ooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00000000 ;
+
+; Character: ? (A5)
+ .db 0b00011010 ; oo o
+ .db 0b00101100 ; o oo
+ .db 0b01100010 ; oo o
+ .db 0b01110010 ; ooo o
+ .db 0b01011010 ; o oo o
+ .db 0b01001110 ; o ooo
+ .db 0b01000110 ; o oo
+ .db 0b00000000 ;
+
+; Character: ? (A6)
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01000110 ; o oo
+ .db 0b00111110 ; ooooo
+ .db 0b01100110 ; oo oo
+ .db 0b00111110 ; ooooo
+ .db 0b00000000 ;
+ .db 0b01111110 ; oooooo
+
+; Character: ? (A7)
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+ .db 0b01111110 ; oooooo
+
+; Character: ? (A8)
+ .db 0b00000000 ;
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+ .db 0b00011000 ; oo
+ .db 0b00110000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+
+; Character: ? (A9)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00111110 ; ooooo
+ .db 0b00110000 ; oo
+ .db 0b00110000 ; oo
+ .db 0b00110000 ; oo
+ .db 0b00000000 ;
+
+; Character: ? (AA)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b01111100 ; ooooo
+ .db 0b00001100 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00000000 ;
+
+; Character: ? (AB)
+ .db 0b01100010 ; oo o
+ .db 0b11100100 ; ooo o
+ .db 0b01101000 ; oo o
+ .db 0b01110110 ; ooo oo
+ .db 0b00101011 ; o o oo
+ .db 0b01000011 ; o oo
+ .db 0b10000110 ; o oo
+ .db 0b00001111 ; oooo
+
+; Character: ? (AC)
+ .db 0b01100010 ; oo o
+ .db 0b11100100 ; ooo o
+ .db 0b01101000 ; oo o
+ .db 0b01110110 ; ooo oo
+ .db 0b00101110 ; o ooo
+ .db 0b01010110 ; o o oo
+ .db 0b10011111 ; o ooooo
+ .db 0b00000110 ; oo
+
+; Character: ? (AD)
+ .db 0b00000000 ;
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+
+; Character: ? (AE)
+ .db 0b00011011 ; oo oo
+ .db 0b00110110 ; oo oo
+ .db 0b01101100 ; oo oo
+ .db 0b11011000 ; oo oo
+ .db 0b01101100 ; oo oo
+ .db 0b00110110 ; oo oo
+ .db 0b00011011 ; oo oo
+ .db 0b00000000 ;
+
+; Character: ? (AF)
+ .db 0b11011000 ; oo oo
+ .db 0b01101100 ; oo oo
+ .db 0b00110110 ; oo oo
+ .db 0b00011011 ; oo oo
+ .db 0b00110110 ; oo oo
+ .db 0b01101100 ; oo oo
+ .db 0b11011000 ; oo oo
+ .db 0b00000000 ;
+
+; Character: ? (B0)
+ .db 0b00110100 ; oo o
+ .db 0b01011000 ; o oo
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b00000110 ; oo
+ .db 0b01111110 ; oooooo
+ .db 0b00111110 ; ooooo
+ .db 0b00000000 ;
+
+; Character: ? (B1)
+ .db 0b00110100 ; oo o
+ .db 0b01011000 ; o oo
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: ? (B2)
+ .db 0b00000010 ; o
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01101110 ; oo ooo
+ .db 0b01110110 ; ooo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b01000000 ; o
+
+; Character: ? (B3)
+ .db 0b00000000 ;
+ .db 0b00000010 ; o
+ .db 0b00111100 ; oooo
+ .db 0b01101110 ; oo ooo
+ .db 0b01110110 ; ooo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b01000000 ; o
+
+; Character: ? (B4)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b01111110 ; oooooo
+ .db 0b11011011 ; oo oo oo
+ .db 0b11011110 ; oo oooo
+ .db 0b11011000 ; oo oo
+ .db 0b01111111 ; ooooooo
+ .db 0b00000000 ;
+
+; Character: ? (B5)
+ .db 0b00000000 ;
+ .db 0b01111110 ; oooooo
+ .db 0b11011000 ; oo oo
+ .db 0b11011000 ; oo oo
+ .db 0b11111100 ; oooooo
+ .db 0b11011000 ; oo oo
+ .db 0b11011000 ; oo oo
+ .db 0b11011110 ; oo oooo
+
+; Character: ? (B6)
+ .db 0b00100000 ; o
+ .db 0b00010000 ; o
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01111110 ; oooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+
+; Character: ? (B7)
+ .db 0b00110100 ; oo o
+ .db 0b01011000 ; o oo
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01111110 ; oooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+
+; Character: ? (B8)
+ .db 0b00110100 ; oo o
+ .db 0b01011000 ; o oo
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+
+; Character: ? (B9)
+ .db 0b01100110 ; oo oo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (BA)
+ .db 0b00001100 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00110000 ; oo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (BB)
+ .db 0b00000000 ;
+ .db 0b00010000 ; o
+ .db 0b00111000 ; ooo
+ .db 0b00010000 ; o
+ .db 0b00010000 ; o
+ .db 0b00010000 ; o
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (BC)
+ .db 0b01111010 ; oooo o
+ .db 0b11001010 ; oo o o
+ .db 0b11001010 ; oo o o
+ .db 0b11001010 ; oo o o
+ .db 0b01111010 ; oooo o
+ .db 0b00001010 ; o o
+ .db 0b00001010 ; o o
+ .db 0b00001010 ; o o
+
+; Character: ? (BD)
+ .db 0b00111100 ; oooo
+ .db 0b01000010 ; o o
+ .db 0b10011001 ; o oo o
+ .db 0b10110101 ; o oo o o
+ .db 0b10110001 ; o oo o
+ .db 0b10011101 ; o ooo o
+ .db 0b01000010 ; o o
+ .db 0b00111100 ; oooo
+
+; Character: ? (BE)
+ .db 0b00111100 ; oooo
+ .db 0b01000010 ; o o
+ .db 0b10111001 ; o ooo o
+ .db 0b10110101 ; o oo o o
+ .db 0b10111001 ; o ooo o
+ .db 0b10110101 ; o oo o o
+ .db 0b01000010 ; o o
+ .db 0b00111100 ; oooo
+
+; Character: ? (BF)
+ .db 0b11110001 ; oooo o
+ .db 0b01011011 ; o oo oo
+ .db 0b01010101 ; o o o o
+ .db 0b01010001 ; o o o
+ .db 0b01010001 ; o o o
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (C0)
+ .db 0b01100110 ; oo oo
+ .db 0b00000000 ;
+ .db 0b11100110 ; ooo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b11110110 ; oooo oo
+ .db 0b00000110 ; oo
+ .db 0b00011100 ; ooo
+
+; Character: ? (C1)
+ .db 0b11110110 ; oooo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b11110110 ; oooo oo
+ .db 0b00000110 ; oo
+ .db 0b00011100 ; ooo
+
+; Character: ? (C2)
+ .db 0b00000000 ;
+ .db 0b01100110 ; oo oo
+ .db 0b01110110 ; ooo oo
+ .db 0b00111100 ; oooo
+ .db 0b01101110 ; oo ooo
+ .db 0b01100110 ; oo oo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (C3)
+ .db 0b00000000 ;
+ .db 0b01111100 ; ooooo
+ .db 0b00001100 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00001100 ; oo
+ .db 0b01111110 ; oooooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (C4)
+ .db 0b00000000 ;
+ .db 0b00011110 ; oooo
+ .db 0b00000110 ; oo
+ .db 0b00001110 ; ooo
+ .db 0b00011110 ; oooo
+ .db 0b00110110 ; oo oo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (C5)
+ .db 0b00000000 ;
+ .db 0b01111110 ; oooooo
+ .db 0b00001100 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (C6)
+ .db 0b00000000 ;
+ .db 0b01111100 ; ooooo
+ .db 0b00000110 ; oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (C7)
+ .db 0b00000000 ;
+ .db 0b00011100 ; ooo
+ .db 0b00001100 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (C8)
+ .db 0b00000000 ;
+ .db 0b00011110 ; oooo
+ .db 0b00001100 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (C9)
+ .db 0b00000000 ;
+ .db 0b01111110 ; oooooo
+ .db 0b00110110 ; oo oo
+ .db 0b00110110 ; oo oo
+ .db 0b00110110 ; oo oo
+ .db 0b00110110 ; oo oo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (CA)
+ .db 0b01100000 ; oo
+ .db 0b01101110 ; oo ooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01111110 ; oooooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (CB)
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b00001100 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (CC)
+ .db 0b00000000 ;
+ .db 0b00111110 ; ooooo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00111110 ; ooooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (CD)
+ .db 0b01100000 ; oo
+ .db 0b01111110 ; oooooo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00001110 ; ooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (CE)
+ .db 0b00000000 ;
+ .db 0b01101100 ; oo oo
+ .db 0b00111110 ; ooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01101110 ; oo ooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (CF)
+ .db 0b00000000 ;
+ .db 0b00011100 ; ooo
+ .db 0b00001100 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (D0)
+ .db 0b00000000 ;
+ .db 0b00111110 ; ooooo
+ .db 0b00110110 ; oo oo
+ .db 0b00110110 ; oo oo
+ .db 0b00110110 ; oo oo
+ .db 0b00011100 ; ooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (D1)
+ .db 0b00000000 ;
+ .db 0b00110110 ; oo oo
+ .db 0b00110110 ; oo oo
+ .db 0b00110110 ; oo oo
+ .db 0b00110110 ; oo oo
+ .db 0b01111110 ; oooooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (D2)
+ .db 0b00000000 ;
+ .db 0b01111110 ; oooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01110110 ; ooo oo
+ .db 0b00000110 ; oo
+ .db 0b01111110 ; oooooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (D3)
+ .db 0b00000000 ;
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b00001110 ; ooo
+ .db 0b01111110 ; oooooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (D4)
+ .db 0b00000000 ;
+ .db 0b00111110 ; ooooo
+ .db 0b00000110 ; oo
+ .db 0b00110110 ; oo oo
+ .db 0b00110110 ; oo oo
+ .db 0b00110100 ; oo o
+ .db 0b00110000 ; oo
+ .db 0b00000000 ;
+
+; Character: ? (D5)
+ .db 0b00000000 ;
+ .db 0b01111000 ; oooo
+ .db 0b00001100 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (D6)
+ .db 0b00000000 ;
+ .db 0b11010110 ; oo o oo
+ .db 0b11010110 ; oo o oo
+ .db 0b11010110 ; oo o oo
+ .db 0b11010110 ; oo o oo
+ .db 0b11111110 ; ooooooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (D7)
+ .db 0b00000000 ;
+ .db 0b01111100 ; ooooo
+ .db 0b01101100 ; oo oo
+ .db 0b01101100 ; oo oo
+ .db 0b01101100 ; oo oo
+ .db 0b11101100 ; ooo oo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (D8)
+ .db 0b00000000 ;
+ .db 0b00011100 ; ooo
+ .db 0b00001100 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00000000 ;
+
+; Character: ? (D9)
+ .db 0b00000000 ;
+ .db 0b00111110 ; ooooo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00000000 ;
+
+; Character: ? (DA)
+ .db 0b00000000 ;
+ .db 0b11111110 ; ooooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01111110 ; oooooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (DB)
+ .db 0b00000000 ;
+ .db 0b01111110 ; oooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01110110 ; ooo oo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00000110 ; oo
+ .db 0b00000000 ;
+
+; Character: ? (DC)
+ .db 0b00000000 ;
+ .db 0b00110110 ; oo oo
+ .db 0b00110110 ; oo oo
+ .db 0b00011100 ; ooo
+ .db 0b00001100 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00000000 ;
+
+; Character: ? (DD)
+ .db 0b00011100 ; ooo
+ .db 0b00110010 ; oo o
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b01001100 ; o oo
+ .db 0b00111000 ; ooo
+
+; Character: ? (DE)
+ .db 0b00000000 ;
+ .db 0b00010000 ; o
+ .db 0b00111000 ; ooo
+ .db 0b01101100 ; oo oo
+ .db 0b11000110 ; oo oo
+ .db 0b10000010 ; o o
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (DF)
+ .db 0b01100110 ; oo oo
+ .db 0b11110111 ; oooo ooo
+ .db 0b10011001 ; o oo o
+ .db 0b10011001 ; o oo o
+ .db 0b11101111 ; ooo oooo
+ .db 0b01100110 ; oo oo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (E0)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b01110110 ; ooo oo
+ .db 0b11011100 ; oo ooo
+ .db 0b11001000 ; oo o
+ .db 0b11011100 ; oo ooo
+ .db 0b01110110 ; ooo oo
+ .db 0b00000000 ;
+
+; Character: ? (E1)
+ .db 0b00011100 ; ooo
+ .db 0b00110110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01111100 ; ooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01111100 ; ooooo
+ .db 0b01100000 ; oo
+
+; Character: ? (E2)
+ .db 0b00000000 ;
+ .db 0b11111110 ; ooooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100010 ; oo o
+ .db 0b01100000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b11111000 ; ooooo
+
+; Character: ? (E3)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b11111110 ; ooooooo
+ .db 0b01101100 ; oo oo
+ .db 0b01101100 ; oo oo
+ .db 0b01101100 ; oo oo
+ .db 0b01101100 ; oo oo
+ .db 0b01001000 ; o o
+
+; Character: ? (E4)
+ .db 0b11111110 ; ooooooo
+ .db 0b01100110 ; oo oo
+ .db 0b00110000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00110000 ; oo
+ .db 0b01100110 ; oo oo
+ .db 0b11111110 ; ooooooo
+ .db 0b00000000 ;
+
+; Character: ? (E5)
+ .db 0b00000000 ;
+ .db 0b00011110 ; oooo
+ .db 0b00111000 ; ooo
+ .db 0b01101100 ; oo oo
+ .db 0b01101100 ; oo oo
+ .db 0b01101100 ; oo oo
+ .db 0b00111000 ; ooo
+ .db 0b00000000 ;
+
+; Character: ? (E6)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b01101100 ; oo oo
+ .db 0b01101100 ; oo oo
+ .db 0b01101100 ; oo oo
+ .db 0b01101100 ; oo oo
+ .db 0b01111111 ; ooooooo
+ .db 0b11000000 ; oo
+
+; Character: ? (E7)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b01111110 ; oooooo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00010000 ; o
+
+; Character: ? (E8)
+ .db 0b00111100 ; oooo
+ .db 0b00011000 ; oo
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b00011000 ; oo
+ .db 0b00111100 ; oooo
+
+; Character: ? (E9)
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01111110 ; oooooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: ? (EA)
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00100100 ; o o
+ .db 0b01100110 ; oo oo
+ .db 0b00000000 ;
+
+; Character: ? (EB)
+ .db 0b00011100 ; ooo
+ .db 0b00110110 ; oo oo
+ .db 0b01111000 ; oooo
+ .db 0b11011100 ; oo ooo
+ .db 0b11001100 ; oo oo
+ .db 0b11101100 ; ooo oo
+ .db 0b01111000 ; oooo
+ .db 0b00000000 ;
+
+; Character: ? (EC)
+ .db 0b00001100 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00111000 ; ooo
+ .db 0b01010100 ; o o o
+ .db 0b01010100 ; o o o
+ .db 0b00111000 ; ooo
+ .db 0b00110000 ; oo
+ .db 0b01100000 ; oo
+
+; Character: ? (ED)
+ .db 0b00000000 ;
+ .db 0b00010000 ; o
+ .db 0b01111100 ; ooooo
+ .db 0b11010110 ; oo o oo
+ .db 0b11010110 ; oo o oo
+ .db 0b11010110 ; oo o oo
+ .db 0b01111100 ; ooooo
+ .db 0b00010000 ; o
+
+; Character: ? (EE)
+ .db 0b00111110 ; ooooo
+ .db 0b01110000 ; ooo
+ .db 0b01100000 ; oo
+ .db 0b01111110 ; oooooo
+ .db 0b01100000 ; oo
+ .db 0b01110000 ; ooo
+ .db 0b00111110 ; ooooo
+ .db 0b00000000 ;
+
+; Character: ? (EF)
+ .db 0b00111100 ; oooo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b01100110 ; oo oo
+ .db 0b00000000 ;
+
+; Character: ? (F0)
+ .db 0b00000000 ;
+ .db 0b01111110 ; oooooo
+ .db 0b00000000 ;
+ .db 0b01111110 ; oooooo
+ .db 0b00000000 ;
+ .db 0b01111110 ; oooooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (F1)
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b01111110 ; oooooo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+ .db 0b01111110 ; oooooo
+ .db 0b00000000 ;
+
+; Character: ? (F2)
+ .db 0b00110000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00110000 ; oo
+ .db 0b00000000 ;
+ .db 0b01111110 ; oooooo
+ .db 0b00000000 ;
+
+; Character: ? (F3)
+ .db 0b00001100 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00110000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00001100 ; oo
+ .db 0b00000000 ;
+ .db 0b01111110 ; oooooo
+ .db 0b00000000 ;
+
+; Character: ? (F4)
+ .db 0b00000000 ;
+ .db 0b00001110 ; ooo
+ .db 0b00011011 ; oo oo
+ .db 0b00011011 ; oo oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+
+; Character: ? (F5)
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b11011000 ; oo oo
+ .db 0b11011000 ; oo oo
+ .db 0b01110000 ; ooo
+ .db 0b00000000 ;
+
+; Character: ? (F6)
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+ .db 0b01111110 ; oooooo
+ .db 0b00000000 ;
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+
+; Character: ? (F7)
+ .db 0b00000000 ;
+ .db 0b00110010 ; oo o
+ .db 0b01001100 ; o oo
+ .db 0b00000000 ;
+ .db 0b00110010 ; oo o
+ .db 0b01001100 ; o oo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (F8)
+ .db 0b00111000 ; ooo
+ .db 0b01101100 ; oo oo
+ .db 0b00111000 ; ooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (F9)
+ .db 0b00111000 ; ooo
+ .db 0b01111100 ; ooooo
+ .db 0b00111000 ; ooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (FA)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (FB)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00001111 ; oooo
+ .db 0b00011000 ; oo
+ .db 0b11011000 ; oo oo
+ .db 0b01110000 ; ooo
+ .db 0b00110000 ; oo
+ .db 0b00000000 ;
+
+; Character: ? (FC)
+ .db 0b00111000 ; ooo
+ .db 0b01101100 ; oo oo
+ .db 0b01101100 ; oo oo
+ .db 0b01101100 ; oo oo
+ .db 0b01101100 ; oo oo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (FD)
+ .db 0b00111000 ; ooo
+ .db 0b01101100 ; oo oo
+ .db 0b00011000 ; oo
+ .db 0b00110000 ; oo
+ .db 0b01111100 ; ooooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (FE)
+ .db 0b01111000 ; oooo
+ .db 0b00001100 ; oo
+ .db 0b00111000 ; ooo
+ .db 0b00001100 ; oo
+ .db 0b01111000 ; oooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (FF)
+ .db 0b00000000 ;
+ .db 0b11111110 ; ooooooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
diff --git a/gbdk/gbdk-lib/libc/targets/z80/f_ibm_sh.s b/gbdk/gbdk-lib/libc/targets/z80/f_ibm_sh.s
new file mode 100644
index 00000000..83e66d6b
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/f_ibm_sh.s
@@ -0,0 +1,174 @@
+; ibm_fixed.ms - fixed width IBM font
+
+ .area _HOME
+
+ ; 898 bytes giving ' '-'0'-'@'-'A'-'Z'-'???'-'a'-'z'-127
+_font_ibm::
+ .byte 1+4 ; 128 character encoding
+ .byte 128-32+6 ; Tiles required
+
+ .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,96,97 ; All map to space
+ .byte 0,0,0,0,0,0,0,0,0,0,0,0,98,99,100,101
+ .byte 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 ; 0x20
+ .byte 16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31
+ .byte 32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47 ; 0x40
+ .byte 48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63
+ .byte 64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79 ; 0x60
+ .byte 80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95
+
+ .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+ .byte 0x18,0x18,0x18,0x18,0x18,0x00,0x18,0x00
+ .byte 0x66,0x66,0x44,0x00,0x00,0x00,0x00,0x00
+ .byte 0x00,0x24,0x7E,0x24,0x24,0x7E,0x24,0x00
+ .byte 0x14,0x3E,0x55,0x3C,0x1E,0x55,0x3E,0x14
+ .byte 0x62,0x66,0x0C,0x18,0x30,0x66,0x46,0x00
+ .byte 0x78,0xCC,0x61,0xCE,0xCC,0xCC,0x78,0x00
+ .byte 0x18,0x18,0x10,0x00,0x00,0x00,0x00,0x00
+ .byte 0x04,0x08,0x18,0x18,0x18,0x18,0x08,0x04
+ .byte 0x20,0x10,0x18,0x18,0x18,0x18,0x10,0x20
+ .byte 0x00,0x54,0x38,0xFE,0x38,0x54,0x00,0x00
+ .byte 0x00,0x18,0x18,0x7E,0x18,0x18,0x00,0x00
+ .byte 0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x20
+ .byte 0x00,0x00,0x00,0x3C,0x00,0x00,0x00,0x00
+ .byte 0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00
+ .byte 0x03,0x06,0x0C,0x18,0x30,0x60,0xC0,0x00
+ .byte 0x3C,0x66,0x6E,0x76,0x66,0x66,0x3C,0x00
+ .byte 0x18,0x38,0x18,0x18,0x18,0x18,0x18,0x00
+ .byte 0x3C,0x66,0x0E,0x1C,0x38,0x70,0x7E,0x00
+ .byte 0x7E,0x0C,0x18,0x3C,0x06,0x46,0x3C,0x00
+ .byte 0x0C,0x1C,0x2C,0x4C,0x7E,0x0C,0x0C,0x00
+ .byte 0x7E,0x60,0x7C,0x06,0x06,0x46,0x3C,0x00
+ .byte 0x1C,0x20,0x60,0x7C,0x66,0x66,0x3C,0x00
+ .byte 0x7E,0x06,0x0E,0x1C,0x18,0x18,0x18,0x00
+ .byte 0x3C,0x66,0x66,0x3C,0x66,0x66,0x3C,0x00
+ .byte 0x3C,0x66,0x66,0x3E,0x06,0x0C,0x38,0x00
+ .byte 0x00,0x18,0x18,0x00,0x00,0x18,0x18,0x00
+ .byte 0x00,0x18,0x18,0x00,0x18,0x18,0x10,0x00
+ .byte 0x06,0x0C,0x18,0x30,0x18,0x0C,0x06,0x00
+ .byte 0x00,0x00,0x3C,0x00,0x00,0x3C,0x00,0x00
+ .byte 0x60,0x30,0x18,0x0C,0x18,0x30,0x60,0x00
+ .byte 0x3C,0x46,0x06,0x0C,0x18,0x18,0x00,0x18
+ .byte 0x3C,0x66,0x6E,0x6A,0x6E,0x60,0x3C,0x00
+ .byte 0x3C,0x66,0x66,0x7E,0x66,0x66,0x66,0x00
+ .byte 0x7C,0x66,0x66,0x7C,0x66,0x66,0x7C,0x00
+ .byte 0x3C,0x62,0x60,0x60,0x60,0x62,0x3C,0x00
+ .byte 0x7C,0x66,0x66,0x66,0x66,0x66,0x7C,0x00
+ .byte 0x7E,0x60,0x60,0x7C,0x60,0x60,0x7E,0x00
+ .byte 0x7E,0x60,0x60,0x7C,0x60,0x60,0x60,0x00
+ .byte 0x3C,0x62,0x60,0x6E,0x66,0x66,0x3E,0x00
+ .byte 0x66,0x66,0x66,0x7E,0x66,0x66,0x66,0x00
+ .byte 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x00
+ .byte 0x06,0x06,0x06,0x06,0x06,0x46,0x3C,0x00
+ .byte 0x66,0x6C,0x78,0x70,0x78,0x6C,0x66,0x00
+ .byte 0x60,0x60,0x60,0x60,0x60,0x60,0x7C,0x00
+ .byte 0xFC,0xD6,0xD6,0xD6,0xD6,0xC6,0xC6,0x00
+ .byte 0x62,0x72,0x7A,0x5E,0x4E,0x46,0x42,0x00
+ .byte 0x3C,0x66,0x66,0x66,0x66,0x66,0x3C,0x00
+ .byte 0x7C,0x66,0x66,0x7C,0x60,0x60,0x60,0x00
+ .byte 0x3C,0x66,0x66,0x66,0x66,0x66,0x3C,0x06
+ .byte 0x7C,0x66,0x66,0x7C,0x66,0x66,0x66,0x00
+ .byte 0x3C,0x62,0x70,0x3C,0x0E,0x46,0x3C,0x00
+ .byte 0x7E,0x18,0x18,0x18,0x18,0x18,0x18,0x00
+ .byte 0x66,0x66,0x66,0x66,0x66,0x66,0x3C,0x00
+ .byte 0x66,0x66,0x66,0x66,0x66,0x64,0x78,0x00
+ .byte 0xC6,0xC6,0xC6,0xD6,0xD6,0xD6,0xFC,0x00
+ .byte 0x66,0x66,0x66,0x3C,0x66,0x66,0x66,0x00
+ .byte 0x66,0x66,0x66,0x3C,0x18,0x18,0x18,0x00
+ .byte 0x7E,0x0E,0x1C,0x38,0x70,0x60,0x7E,0x00
+ .byte 0x1E,0x18,0x18,0x18,0x18,0x18,0x1E,0x00
+ .byte 0x40,0x60,0x30,0x18,0x0C,0x06,0x02,0x00
+ .byte 0x78,0x18,0x18,0x18,0x18,0x18,0x78,0x00
+ .byte 0x10,0x38,0x6C,0x00,0x00,0x00,0x00,0x00
+ .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x00
+ .byte 0x00,0xC0,0xC0,0x60,0x00,0x00,0x00,0x00
+ .byte 0x00,0x3C,0x46,0x3E,0x66,0x66,0x3E,0x00
+ .byte 0x60,0x7C,0x66,0x66,0x66,0x66,0x7C,0x00
+ .byte 0x00,0x3C,0x62,0x60,0x60,0x62,0x3C,0x00
+ .byte 0x06,0x3E,0x66,0x66,0x66,0x66,0x3E,0x00
+ .byte 0x00,0x3C,0x66,0x7E,0x60,0x62,0x3C,0x00
+ .byte 0x1E,0x30,0x7C,0x30,0x30,0x30,0x30,0x00
+ .byte 0x00,0x3E,0x66,0x66,0x66,0x3E,0x46,0x3C
+ .byte 0x60,0x7C,0x66,0x66,0x66,0x66,0x66,0x00
+ .byte 0x18,0x00,0x18,0x18,0x18,0x18,0x18,0x00
+ .byte 0x00,0x08,0x18,0x18,0x18,0x18,0x58,0x30
+ .byte 0x60,0x64,0x68,0x70,0x78,0x6C,0x66,0x00
+ .byte 0x18,0x18,0x18,0x18,0x18,0x18,0x0C,0x00
+ .byte 0x00,0xFC,0xD6,0xD6,0xD6,0xD6,0xC6,0x00
+ .byte 0x00,0x7C,0x66,0x66,0x66,0x66,0x66,0x00
+ .byte 0x00,0x3C,0x66,0x66,0x66,0x66,0x3C,0x00
+ .byte 0x00,0x7C,0x66,0x66,0x66,0x7C,0x60,0x60
+ .byte 0x00,0x3E,0x66,0x66,0x66,0x66,0x3E,0x06
+ .byte 0x00,0x6C,0x70,0x60,0x60,0x60,0x60,0x00
+ .byte 0x00,0x3C,0x72,0x38,0x1C,0x4E,0x3C,0x00
+ .byte 0x18,0x3C,0x18,0x18,0x18,0x18,0x0C,0x00
+ .byte 0x00,0x66,0x66,0x66,0x66,0x66,0x3E,0x00
+ .byte 0x00,0x66,0x66,0x66,0x66,0x64,0x78,0x00
+ .byte 0x00,0xC6,0xC6,0xD6,0xD6,0xD6,0xFC,0x00
+ .byte 0x00,0x66,0x66,0x3C,0x66,0x66,0x66,0x00
+ .byte 0x00,0x66,0x66,0x66,0x26,0x1E,0x46,0x3C
+ .byte 0x00,0x7E,0x0E,0x1C,0x38,0x70,0x7E,0x00
+ .byte 0x0E,0x18,0x18,0x30,0x18,0x18,0x0E,0x00
+ .byte 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18
+ .byte 0x70,0x18,0x18,0x0C,0x18,0x18,0x70,0x00
+ .byte 0x00,0x60,0xF2,0x9E,0x0C,0x00,0x00,0x00
+ .byte 0x10,0x10,0x28,0x28,0x44,0x44,0x82,0xFE
+
+; Character: ? (0E)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b11111111 ; oooooooo
+ .db 0b11111111 ; oooooooo
+ .db 0b11111111 ; oooooooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (0F)
+ .db 0b00011100 ; ooo
+ .db 0b00011100 ; ooo
+ .db 0b00011100 ; ooo
+ .db 0b00011100 ; ooo
+ .db 0b00011100 ; ooo
+ .db 0b00011100 ; ooo
+ .db 0b00011100 ; ooo
+ .db 0b00011100 ; ooo
+
+; Character: ? (1C)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00011111 ; ooooo
+ .db 0b00011111 ; ooooo
+ .db 0b00011111 ; ooooo
+ .db 0b00011100 ; ooo
+ .db 0b00011100 ; ooo
+
+; Character: ? (1D)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b11111100 ; oooooo
+ .db 0b11111100 ; oooooo
+ .db 0b11111100 ; oooooo
+ .db 0b00011100 ; ooo
+ .db 0b00011100 ; ooo
+
+; Character: ? (1E)
+ .db 0b00011100 ; ooo
+ .db 0b00011100 ; ooo
+ .db 0b00011100 ; ooo
+ .db 0b00011111 ; ooooo
+ .db 0b00011111 ; ooooo
+ .db 0b00011111 ; ooooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ? (1F)
+ .db 0b00011100 ; ooo
+ .db 0b00011100 ; ooo
+ .db 0b00011100 ; ooo
+ .db 0b11111100 ; oooooo
+ .db 0b11111100 ; oooooo
+ .db 0b11111100 ; oooooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
diff --git a/gbdk/gbdk-lib/libc/targets/z80/f_italic.s b/gbdk/gbdk-lib/libc/targets/z80/f_italic.s
new file mode 100644
index 00000000..cca67aa6
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/f_italic.s
@@ -0,0 +1,957 @@
+; font: italic
+
+ .area _HOME
+
+_font_italic::
+ .db 1+4 ; 128 char encoding, compressed
+ .db 93 ; Number of tiles
+
+; Encoding table
+
+ .db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+ .db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+ .db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+ .db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+ .db 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07
+ .db 0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F
+ .db 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17
+ .db 0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F
+ .db 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27
+ .db 0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F
+ .db 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37
+ .db 0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x00
+ .db 0x00,0x3F,0x40,0x41,0x42,0x43,0x44,0x45
+ .db 0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D
+ .db 0x4E,0x4F,0x50,0x51,0x52,0x53,0x54,0x55
+ .db 0x56,0x57,0x58,0x59,0x5A,0x5B,0x5C,0x00
+; Tile data
+; Default character (space)
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+
+; Character: ! (21)
+ .db 0b00000000 ;
+ .db 0b00001000 ; o
+ .db 0b00001000 ; o
+ .db 0b00001000 ; o
+ .db 0b00010000 ; o
+ .db 0b00010000 ; o
+ .db 0b00000000 ;
+ .db 0b00100000 ; o
+
+; Character: " (22)
+ .db 0b00000000 ;
+ .db 0b00100100 ; o o
+ .db 0b00100100 ; o o
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: # (23)
+ .db 0b00000000 ;
+ .db 0b00100100 ; o o
+ .db 0b01111110 ; oooooo
+ .db 0b00100100 ; o o
+ .db 0b00100100 ; o o
+ .db 0b01111110 ; oooooo
+ .db 0b00100100 ; o o
+ .db 0b00000000 ;
+
+; Character: $ (24)
+ .db 0b00000000 ;
+ .db 0b00001000 ; o
+ .db 0b00111110 ; ooooo
+ .db 0b00101000 ; o o
+ .db 0b00111110 ; ooooo
+ .db 0b00001010 ; o o
+ .db 0b00111110 ; ooooo
+ .db 0b00001000 ; o
+
+; Character: % (25)
+ .db 0b00000000 ;
+ .db 0b01100010 ; oo o
+ .db 0b01100100 ; oo o
+ .db 0b00001000 ; o
+ .db 0b00010000 ; o
+ .db 0b00100110 ; o oo
+ .db 0b01000110 ; o oo
+ .db 0b00000000 ;
+
+; Character: & (26)
+ .db 0b00000000 ;
+ .db 0b00010000 ; o
+ .db 0b00101000 ; o o
+ .db 0b00010000 ; o
+ .db 0b00101010 ; o o o
+ .db 0b01000100 ; o o
+ .db 0b00111010 ; ooo o
+ .db 0b00000000 ;
+
+; Character: ' (27)
+ .db 0b00000000 ;
+ .db 0b00001000 ; o
+ .db 0b00010000 ; o
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: ( (28)
+ .db 0b00000000 ;
+ .db 0b00000100 ; o
+ .db 0b00001000 ; o
+ .db 0b00001000 ; o
+ .db 0b00001000 ; o
+ .db 0b00001000 ; o
+ .db 0b00000100 ; o
+ .db 0b00000000 ;
+
+; Character: ) (29)
+ .db 0b00000000 ;
+ .db 0b00100000 ; o
+ .db 0b00010000 ; o
+ .db 0b00010000 ; o
+ .db 0b00010000 ; o
+ .db 0b00010000 ; o
+ .db 0b00100000 ; o
+ .db 0b00000000 ;
+
+; Character: * (2A)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00100100 ; o o
+ .db 0b00011000 ; oo
+ .db 0b01111110 ; oooooo
+ .db 0b00011000 ; oo
+ .db 0b00100100 ; o o
+ .db 0b00000000 ;
+
+; Character: + (2B)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00001000 ; o
+ .db 0b00001000 ; o
+ .db 0b00111110 ; ooooo
+ .db 0b00001000 ; o
+ .db 0b00001000 ; o
+ .db 0b00000000 ;
+
+; Character: , (2C)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00001000 ; o
+ .db 0b00001000 ; o
+ .db 0b00010000 ; o
+
+; Character: - (2D)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00111110 ; ooooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: . (2E)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00011000 ; oo
+ .db 0b00011000 ; oo
+ .db 0b00000000 ;
+
+; Character: / (2F)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000010 ; o
+ .db 0b00000100 ; o
+ .db 0b00001000 ; o
+ .db 0b00010000 ; o
+ .db 0b00100000 ; o
+ .db 0b00000000 ;
+
+; Character: 0 (30)
+ .db 0b00000000 ;
+ .db 0b00011100 ; ooo
+ .db 0b00100110 ; o oo
+ .db 0b01001010 ; o o o
+ .db 0b01010100 ; o o o
+ .db 0b10100100 ; o o o
+ .db 0b11001000 ; oo o
+ .db 0b01110000 ; ooo
+
+; Character: 1 (31)
+ .db 0b00000000 ;
+ .db 0b00011000 ; oo
+ .db 0b00101000 ; o o
+ .db 0b00001000 ; o
+ .db 0b00010000 ; o
+ .db 0b00100000 ; o
+ .db 0b00100000 ; o
+ .db 0b11111000 ; ooooo
+
+; Character: 2 (32)
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01000010 ; o o
+ .db 0b00000100 ; o
+ .db 0b00011000 ; oo
+ .db 0b01100000 ; oo
+ .db 0b10000000 ; o
+ .db 0b11111100 ; oooooo
+
+; Character: 3 (33)
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01000010 ; o o
+ .db 0b00000010 ; o
+ .db 0b00001100 ; oo
+ .db 0b00000010 ; o
+ .db 0b10000100 ; o o
+ .db 0b01111000 ; oooo
+
+; Character: 4 (34)
+ .db 0b00000000 ;
+ .db 0b00001100 ; oo
+ .db 0b00110100 ; oo o
+ .db 0b01000100 ; o o
+ .db 0b10001000 ; o o
+ .db 0b11111110 ; ooooooo
+ .db 0b00010000 ; o
+ .db 0b00010000 ; o
+
+; Character: 5 (35)
+ .db 0b00000000 ;
+ .db 0b00111110 ; ooooo
+ .db 0b00100000 ; o
+ .db 0b01000000 ; o
+ .db 0b01111000 ; oooo
+ .db 0b00000100 ; o
+ .db 0b10000100 ; o o
+ .db 0b01111000 ; oooo
+
+; Character: 6 (36)
+ .db 0b00000000 ;
+ .db 0b00011100 ; ooo
+ .db 0b00100010 ; o o
+ .db 0b01000000 ; o
+ .db 0b01111000 ; oooo
+ .db 0b10000100 ; o o
+ .db 0b10000100 ; o o
+ .db 0b01111000 ; oooo
+
+; Character: 7 (37)
+ .db 0b00000000 ;
+ .db 0b00111110 ; ooooo
+ .db 0b00000010 ; o
+ .db 0b00000100 ; o
+ .db 0b00001000 ; o
+ .db 0b00010000 ; o
+ .db 0b00100000 ; o
+ .db 0b00100000 ; o
+
+; Character: 8 (38)
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01000010 ; o o
+ .db 0b00111100 ; oooo
+ .db 0b01000010 ; o o
+ .db 0b10000100 ; o o
+ .db 0b10000100 ; o o
+ .db 0b01111000 ; oooo
+
+; Character: 9 (39)
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01000010 ; o o
+ .db 0b01000010 ; o o
+ .db 0b00111100 ; oooo
+ .db 0b00000100 ; o
+ .db 0b00001000 ; o
+ .db 0b11110000 ; oooo
+
+; Character: : (3A)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00001000 ; o
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00010000 ; o
+ .db 0b00000000 ;
+
+; Character: ; (3B)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00010000 ; o
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00010000 ; o
+ .db 0b00010000 ; o
+ .db 0b00100000 ; o
+
+; Character: < (3C)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000100 ; o
+ .db 0b00001000 ; o
+ .db 0b00010000 ; o
+ .db 0b00001000 ; o
+ .db 0b00000100 ; o
+ .db 0b00000000 ;
+
+; Character: = (3D)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00111110 ; ooooo
+ .db 0b00000000 ;
+ .db 0b01111100 ; ooooo
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
+; Character: > (3E)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00010000 ; o
+ .db 0b00001000 ; o
+ .db 0b00000100 ; o
+ .db 0b00001000 ; o
+ .db 0b00010000 ; o
+ .db 0b00000000 ;
+
+; Character: ? (3F)
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01000010 ; o o
+ .db 0b00000010 ; o
+ .db 0b00001100 ; oo
+ .db 0b00010000 ; o
+ .db 0b00000000 ;
+ .db 0b00110000 ; oo
+
+; Character: @ (40)
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b01001010 ; o o o
+ .db 0b01010110 ; o o oo
+ .db 0b01011110 ; o oooo
+ .db 0b01000000 ; o
+ .db 0b00111100 ; oooo
+ .db 0b00000000 ;
+
+; Character: A (41)
+ .db 0b00000000 ;
+ .db 0b00011100 ; ooo
+ .db 0b00100010 ; o o
+ .db 0b00100010 ; o o
+ .db 0b01111100 ; ooooo
+ .db 0b01000100 ; o o
+ .db 0b10001000 ; o o
+ .db 0b10001000 ; o o
+
+; Character: B (42)
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b00100010 ; o o
+ .db 0b00111100 ; oooo
+ .db 0b01000010 ; o o
+ .db 0b01000010 ; o o
+ .db 0b10000100 ; o o
+ .db 0b11111000 ; ooooo
+
+; Character: C (43)
+ .db 0b00000000 ;
+ .db 0b00011100 ; ooo
+ .db 0b00100010 ; o o
+ .db 0b01000000 ; o
+ .db 0b01000000 ; o
+ .db 0b10000000 ; o
+ .db 0b10000100 ; o o
+ .db 0b01111000 ; oooo
+
+; Character: D (44)
+ .db 0b00000000 ;
+ .db 0b00111000 ; ooo
+ .db 0b00100100 ; o o
+ .db 0b00100010 ; o o
+ .db 0b01000010 ; o o
+ .db 0b01000100 ; o o
+ .db 0b10001000 ; o o
+ .db 0b11110000 ; oooo
+
+; Character: E (45)
+ .db 0b00000000 ;
+ .db 0b00111110 ; ooooo
+ .db 0b00100000 ; o
+ .db 0b01000000 ; o
+ .db 0b01111000 ; oooo
+ .db 0b01000000 ; o
+ .db 0b10000000 ; o
+ .db 0b11111000 ; ooooo
+
+; Character: F (46)
+ .db 0b00000000 ;
+ .db 0b00111110 ; ooooo
+ .db 0b00100000 ; o
+ .db 0b01000000 ; o
+ .db 0b01111000 ; oooo
+ .db 0b01000000 ; o
+ .db 0b10000000 ; o
+ .db 0b10000000 ; o
+
+; Character: G (47)
+ .db 0b00000000 ;
+ .db 0b00011100 ; ooo
+ .db 0b00100010 ; o o
+ .db 0b01000000 ; o
+ .db 0b01000000 ; o
+ .db 0b10001110 ; o ooo
+ .db 0b10000100 ; o o
+ .db 0b01111000 ; oooo
+
+; Character: H (48)
+ .db 0b00000000 ;
+ .db 0b00100010 ; o o
+ .db 0b00100010 ; o o
+ .db 0b01000100 ; o o
+ .db 0b01111100 ; ooooo
+ .db 0b01000100 ; o o
+ .db 0b10001000 ; o o
+ .db 0b10001000 ; o o
+
+; Character: I (49)
+ .db 0b00000000 ;
+ .db 0b00111110 ; ooooo
+ .db 0b00001000 ; o
+ .db 0b00001000 ; o
+ .db 0b00010000 ; o
+ .db 0b00100000 ; o
+ .db 0b00100000 ; o
+ .db 0b11111000 ; ooooo
+
+; Character: J (4A)
+ .db 0b00000000 ;
+ .db 0b00000010 ; o
+ .db 0b00000010 ; o
+ .db 0b00000100 ; o
+ .db 0b00000100 ; o
+ .db 0b10001000 ; o o
+ .db 0b10001000 ; o o
+ .db 0b01110000 ; ooo
+
+; Character: K (4B)
+ .db 0b00000000 ;
+ .db 0b00100010 ; o o
+ .db 0b00100100 ; o o
+ .db 0b01001000 ; o o
+ .db 0b01110000 ; ooo
+ .db 0b01001000 ; o o
+ .db 0b10001000 ; o o
+ .db 0b10000100 ; o o
+
+; Character: L (4C)
+ .db 0b00000000 ;
+ .db 0b00100000 ; o
+ .db 0b00100000 ; o
+ .db 0b01000000 ; o
+ .db 0b01000000 ; o
+ .db 0b01000000 ; o
+ .db 0b10000000 ; o
+ .db 0b11111100 ; oooooo
+
+; Character: M (4D)
+ .db 0b00000000 ;
+ .db 0b00110110 ; oo oo
+ .db 0b00101010 ; o o o
+ .db 0b01010100 ; o o o
+ .db 0b01010100 ; o o o
+ .db 0b01000100 ; o o
+ .db 0b10001000 ; o o
+ .db 0b10001000 ; o o
+
+; Character: N (4E)
+ .db 0b00000000 ;
+ .db 0b00100010 ; o o
+ .db 0b00110010 ; oo o
+ .db 0b01010100 ; o o o
+ .db 0b01010100 ; o o o
+ .db 0b01010100 ; o o o
+ .db 0b10011000 ; o oo
+ .db 0b10001000 ; o o
+
+; Character: O (4F)
+ .db 0b00000000 ;
+ .db 0b00011100 ; ooo
+ .db 0b00100010 ; o o
+ .db 0b01000010 ; o o
+ .db 0b01000100 ; o o
+ .db 0b10000100 ; o o
+ .db 0b10001000 ; o o
+ .db 0b01110000 ; ooo
+
+; Character: P (50)
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b00100010 ; o o
+ .db 0b01000010 ; o o
+ .db 0b01111100 ; ooooo
+ .db 0b01000000 ; o
+ .db 0b10000000 ; o
+ .db 0b10000000 ; o
+
+; Character: Q (51)
+ .db 0b00000000 ;
+ .db 0b00011100 ; ooo
+ .db 0b00100010 ; o o
+ .db 0b01000010 ; o o
+ .db 0b01000100 ; o o
+ .db 0b10010100 ; o o o
+ .db 0b10001000 ; o o
+ .db 0b01110100 ; ooo o
+
+; Character: R (52)
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b00100010 ; o o
+ .db 0b01000010 ; o o
+ .db 0b01111100 ; ooooo
+ .db 0b01001000 ; o o
+ .db 0b10000100 ; o o
+ .db 0b10000100 ; o o
+
+; Character: S (53)
+ .db 0b00000000 ;
+ .db 0b00011110 ; oooo
+ .db 0b00100000 ; o
+ .db 0b00100000 ; o
+ .db 0b00011000 ; oo
+ .db 0b00000100 ; o
+ .db 0b10000100 ; o o
+ .db 0b01111000 ; oooo
+
+; Character: T (54)
+ .db 0b00000000 ;
+ .db 0b11111110 ; ooooooo
+ .db 0b00010000 ; o
+ .db 0b00100000 ; o
+ .db 0b00100000 ; o
+ .db 0b00100000 ; o
+ .db 0b01000000 ; o
+ .db 0b01000000 ; o
+
+; Character: U (55)
+ .db 0b00000000 ;
+ .db 0b00100010 ; o o
+ .db 0b00100010 ; o o
+ .db 0b01000100 ; o o
+ .db 0b01000100 ; o o
+ .db 0b10001000 ; o o
+ .db 0b10001000 ; o o
+ .db 0b01110000 ; ooo
+
+; Character: V (56)
+ .db 0b00000000 ;
+ .db 0b01000010 ; o o
+ .db 0b01000010 ; o o
+ .db 0b01000100 ; o o
+ .db 0b01000100 ; o o
+ .db 0b10001000 ; o o
+ .db 0b10010000 ; o o
+ .db 0b11100000 ; ooo
+
+; Character: W (57)
+ .db 0b00000000 ;
+ .db 0b00100010 ; o o
+ .db 0b00100010 ; o o
+ .db 0b01000100 ; o o
+ .db 0b01010100 ; o o o
+ .db 0b10101000 ; o o o
+ .db 0b10101000 ; o o o
+ .db 0b01010000 ; o o
+
+; Character: X (58)
+ .db 0b00000000 ;
+ .db 0b01000010 ; o o
+ .db 0b00100100 ; o o
+ .db 0b00101000 ; o o
+ .db 0b00010000 ; o
+ .db 0b00101000 ; o o
+ .db 0b01001000 ; o o
+ .db 0b10000100 ; o o
+
+; Character: Y (59)
+ .db 0b00000000 ;
+ .db 0b01000010 ; o o
+ .db 0b00100100 ; o o
+ .db 0b00101000 ; o o
+ .db 0b00010000 ; o
+ .db 0b00010000 ; o
+ .db 0b00100000 ; o
+ .db 0b00100000 ; o
+
+; Character: Z (5A)
+ .db 0b00000000 ;
+ .db 0b01111110 ; oooooo
+ .db 0b00000100 ; o
+ .db 0b00001000 ; o
+ .db 0b00010000 ; o
+ .db 0b00100000 ; o
+ .db 0b01000000 ; o
+ .db 0b11111100 ; oooooo
+
+; Character: [ (5B)
+ .db 0b00000000 ;
+ .db 0b00001110 ; ooo
+ .db 0b00001000 ; o
+ .db 0b00001000 ; o
+ .db 0b00001000 ; o
+ .db 0b00001000 ; o
+ .db 0b00001110 ; ooo
+ .db 0b00000000 ;
+
+; Character: \ (5C)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b01000000 ; o
+ .db 0b00100000 ; o
+ .db 0b00010000 ; o
+ .db 0b00001000 ; o
+ .db 0b00000100 ; o
+ .db 0b00000000 ;
+
+; Character: ] (5D)
+ .db 0b00000000 ;
+ .db 0b01110000 ; ooo
+ .db 0b00010000 ; o
+ .db 0b00010000 ; o
+ .db 0b00010000 ; o
+ .db 0b00010000 ; o
+ .db 0b01110000 ; ooo
+ .db 0b00000000 ;
+
+; Character: ^ (5E)
+ .db 0b00000000 ;
+ .db 0b00010000 ; o
+ .db 0b00111000 ; ooo
+ .db 0b01010100 ; o o o
+ .db 0b00010000 ; o
+ .db 0b00010000 ; o
+ .db 0b00010000 ; o
+ .db 0b00000000 ;
+
+; Character: a (61)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00011100 ; ooo
+ .db 0b00000010 ; o
+ .db 0b00111110 ; ooooo
+ .db 0b01000100 ; o o
+ .db 0b00111100 ; oooo
+
+; Character: b (62)
+ .db 0b00000000 ;
+ .db 0b00010000 ; o
+ .db 0b00010000 ; o
+ .db 0b00100000 ; o
+ .db 0b00111100 ; oooo
+ .db 0b00100010 ; o o
+ .db 0b01000100 ; o o
+ .db 0b01111000 ; oooo
+
+; Character: c (63)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00011110 ; oooo
+ .db 0b00100000 ; o
+ .db 0b01000000 ; o
+ .db 0b01000000 ; o
+ .db 0b00111100 ; oooo
+
+; Character: d (64)
+ .db 0b00000000 ;
+ .db 0b00000010 ; o
+ .db 0b00000010 ; o
+ .db 0b00000100 ; o
+ .db 0b00111100 ; oooo
+ .db 0b01000100 ; o o
+ .db 0b01001000 ; o o
+ .db 0b00111000 ; ooo
+
+; Character: e (65)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00011100 ; ooo
+ .db 0b00100010 ; o o
+ .db 0b01111100 ; ooooo
+ .db 0b01000000 ; o
+ .db 0b00111000 ; ooo
+
+; Character: f (66)
+ .db 0b00000000 ;
+ .db 0b00001110 ; ooo
+ .db 0b00010000 ; o
+ .db 0b00010000 ; o
+ .db 0b00111000 ; ooo
+ .db 0b00100000 ; o
+ .db 0b01000000 ; o
+ .db 0b01000000 ; o
+
+; Character: g (67)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00011110 ; oooo
+ .db 0b00100010 ; o o
+ .db 0b01000100 ; o o
+ .db 0b00111100 ; oooo
+ .db 0b00000100 ; o
+ .db 0b01111000 ; oooo
+
+; Character: h (68)
+ .db 0b00000000 ;
+ .db 0b00010000 ; o
+ .db 0b00010000 ; o
+ .db 0b00100000 ; o
+ .db 0b00111100 ; oooo
+ .db 0b00100010 ; o o
+ .db 0b01000100 ; o o
+ .db 0b01000100 ; o o
+
+; Character: i (69)
+ .db 0b00000000 ;
+ .db 0b00001000 ; o
+ .db 0b00000000 ;
+ .db 0b00011000 ; oo
+ .db 0b00001000 ; o
+ .db 0b00010000 ; o
+ .db 0b00100000 ; o
+ .db 0b01110000 ; ooo
+
+; Character: j (6A)
+ .db 0b00000000 ;
+ .db 0b00000100 ; o
+ .db 0b00000000 ;
+ .db 0b00000100 ; o
+ .db 0b00000100 ; o
+ .db 0b01001000 ; o o
+ .db 0b01001000 ; o o
+ .db 0b00110000 ; oo
+
+; Character: k (6B)
+ .db 0b00000000 ;
+ .db 0b00010000 ; o
+ .db 0b00010000 ; o
+ .db 0b00100000 ; o
+ .db 0b00100100 ; o o
+ .db 0b00111000 ; ooo
+ .db 0b01000100 ; o o
+ .db 0b01000100 ; o o
+
+; Character: l (6C)
+ .db 0b00000000 ;
+ .db 0b00001000 ; o
+ .db 0b00001000 ; o
+ .db 0b00010000 ; o
+ .db 0b00010000 ; o
+ .db 0b00100000 ; o
+ .db 0b00100000 ; o
+ .db 0b00011000 ; oo
+
+; Character: m (6D)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00110100 ; oo o
+ .db 0b00101010 ; o o o
+ .db 0b00101010 ; o o o
+ .db 0b01010100 ; o o o
+ .db 0b01010100 ; o o o
+
+; Character: n (6E)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00111100 ; oooo
+ .db 0b00100010 ; o o
+ .db 0b00100010 ; o o
+ .db 0b01000100 ; o o
+ .db 0b01000100 ; o o
+
+; Character: o (6F)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00011100 ; ooo
+ .db 0b00100010 ; o o
+ .db 0b00100010 ; o o
+ .db 0b01000100 ; o o
+ .db 0b01000100 ; o o
+ .db 0b00111000 ; ooo
+
+; Character: p (70)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00011100 ; ooo
+ .db 0b00010010 ; o o
+ .db 0b00100010 ; o o
+ .db 0b00111100 ; oooo
+ .db 0b01000000 ; o
+ .db 0b01000000 ; o
+
+; Character: q (71)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00011110 ; oooo
+ .db 0b00100010 ; o o
+ .db 0b00100100 ; o o
+ .db 0b00011100 ; ooo
+ .db 0b00001000 ; o
+ .db 0b00001100 ; oo
+
+; Character: r (72)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00001110 ; ooo
+ .db 0b00010000 ; o
+ .db 0b00010000 ; o
+ .db 0b00100000 ; o
+ .db 0b00100000 ; o
+
+; Character: s (73)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00011110 ; oooo
+ .db 0b00100000 ; o
+ .db 0b00011000 ; oo
+ .db 0b00000100 ; o
+ .db 0b01111000 ; oooo
+
+; Character: t (74)
+ .db 0b00000000 ;
+ .db 0b00001000 ; o
+ .db 0b00001000 ; o
+ .db 0b00011100 ; ooo
+ .db 0b00001000 ; o
+ .db 0b00010000 ; o
+ .db 0b00010000 ; o
+ .db 0b00100000 ; o
+
+; Character: u (75)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00100010 ; o o
+ .db 0b00100010 ; o o
+ .db 0b01000100 ; o o
+ .db 0b01000100 ; o o
+ .db 0b00111000 ; ooo
+
+; Character: v (76)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00100010 ; o o
+ .db 0b00100010 ; o o
+ .db 0b01000100 ; o o
+ .db 0b01001000 ; o o
+ .db 0b00110000 ; oo
+
+; Character: w (77)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00100010 ; o o
+ .db 0b00101010 ; o o o
+ .db 0b01010100 ; o o o
+ .db 0b01010100 ; o o o
+ .db 0b00101000 ; o o
+
+; Character: x (78)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00100100 ; o o
+ .db 0b00101000 ; o o
+ .db 0b00011000 ; oo
+ .db 0b00100100 ; o o
+ .db 0b01000100 ; o o
+
+; Character: y (79)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00100010 ; o o
+ .db 0b00100010 ; o o
+ .db 0b00011100 ; ooo
+ .db 0b00000100 ; o
+ .db 0b01111000 ; oooo
+
+; Character: z (7A)
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00111110 ; ooooo
+ .db 0b00000100 ; o
+ .db 0b00011000 ; oo
+ .db 0b00100000 ; o
+ .db 0b01111100 ; ooooo
+
+; Character: { (7B)
+ .db 0b00000000 ;
+ .db 0b00001110 ; ooo
+ .db 0b00001000 ; o
+ .db 0b00110000 ; oo
+ .db 0b00001000 ; o
+ .db 0b00001000 ; o
+ .db 0b00001110 ; ooo
+ .db 0b00000000 ;
+
+; Character: | (7C)
+ .db 0b00000000 ;
+ .db 0b00001000 ; o
+ .db 0b00001000 ; o
+ .db 0b00001000 ; o
+ .db 0b00001000 ; o
+ .db 0b00001000 ; o
+ .db 0b00001000 ; o
+ .db 0b00000000 ;
+
+; Character: } (7D)
+ .db 0b00000000 ;
+ .db 0b01110000 ; ooo
+ .db 0b00010000 ; o
+ .db 0b00001100 ; oo
+ .db 0b00010000 ; o
+ .db 0b00010000 ; o
+ .db 0b01110000 ; ooo
+ .db 0b00000000 ;
+
+; Character: ~ (7E)
+ .db 0b00000000 ;
+ .db 0b00010100 ; o o
+ .db 0b00101000 ; o o
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+ .db 0b00000000 ;
+
diff --git a/gbdk/gbdk-lib/libc/targets/z80/f_min.s b/gbdk/gbdk-lib/libc/targets/z80/f_min.s
new file mode 100644
index 00000000..1fbb5de9
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/f_min.s
@@ -0,0 +1,355 @@
+; font_min.s
+
+; Text font
+; Michael Hope, 1998
+; michaelh@earthling.net
+; Distrubuted under the Artistic License - see www.opensource.org
+;
+ .module font_min
+ .area _HOME
+
+_font_min::
+ .byte 1+4 ; 128 character encoding
+ .byte 37 ; Tiles required
+
+ .byte 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ; All map to space
+ .byte 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ; All map to space
+ .byte 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 ; All map to space
+ .byte 01,02,03,04,05,06,07,08,09,10,00,00,00,00,00,00
+ .byte 00,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25
+ .byte 26,27,28,29,30,21,32,33,34,35,36,00,00,00,00,00
+ .byte 00,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25
+ .byte 26,27,28,29,30,31,32,33,34,35,36,00,00,00,00,00
+
+ .db 0
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+; Character: 0
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000110
+ .db 0b01001010
+ .db 0b01010010
+ .db 0b01100010
+ .db 0b00111100
+ .db 0b00000000
+; Character: 1
+ .db 0b00000000
+ .db 0b00011000
+ .db 0b00101000
+ .db 0b00001000
+ .db 0b00001000
+ .db 0b00001000
+ .db 0b00111110
+ .db 0b00000000
+; Character: 2
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000010
+ .db 0b00000010
+ .db 0b00111100
+ .db 0b01000000
+ .db 0b01111110
+ .db 0b00000000
+; Character: 3
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000010
+ .db 0b00001100
+ .db 0b00000010
+ .db 0b01000010
+ .db 0b00111100
+ .db 0b00000000
+; Character: 4
+ .db 0b00000000
+ .db 0b00001000
+ .db 0b00011000
+ .db 0b00101000
+ .db 0b01001000
+ .db 0b01111110
+ .db 0b00001000
+ .db 0b00000000
+; Character: 5
+ .db 0b00000000
+ .db 0b01111110
+ .db 0b01000000
+ .db 0b01111100
+ .db 0b00000010
+ .db 0b01000010
+ .db 0b00111100
+ .db 0b00000000
+; Character: 6
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000000
+ .db 0b01111100
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b00111100
+ .db 0b00000000
+; Character: 7
+ .db 0b00000000
+ .db 0b01111110
+ .db 0b00000010
+ .db 0b00000100
+ .db 0b00001000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00000000
+; Character: 8
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000010
+ .db 0b00111100
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b00111100
+ .db 0b00000000
+; Character: 9
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b00111110
+ .db 0b00000010
+ .db 0b00111100
+ .db 0b00000000
+; Character: A
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01111110
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b00000000
+; Character: B
+ .db 0b00000000
+ .db 0b01111100
+ .db 0b01000010
+ .db 0b01111100
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01111100
+ .db 0b00000000
+; Character: C
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000010
+ .db 0b01000000
+ .db 0b01000000
+ .db 0b01000010
+ .db 0b00111100
+ .db 0b00000000
+; Character: D
+ .db 0b00000000
+ .db 0b01111000
+ .db 0b01000100
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01000100
+ .db 0b01111000
+ .db 0b00000000
+; Character: E
+ .db 0b00000000
+ .db 0b01111110
+ .db 0b01000000
+ .db 0b01111100
+ .db 0b01000000
+ .db 0b01000000
+ .db 0b01111110
+ .db 0b00000000
+; Character: F
+ .db 0b00000000
+ .db 0b01111110
+ .db 0b01000000
+ .db 0b01111100
+ .db 0b01000000
+ .db 0b01000000
+ .db 0b01000000
+ .db 0b00000000
+; Character: G
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000010
+ .db 0b01000000
+ .db 0b01001110
+ .db 0b01000010
+ .db 0b00111100
+ .db 0b00000000
+; Character: H
+ .db 0b00000000
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01111110
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b00000000
+; Character: I
+ .db 0b00000000
+ .db 0b00111110
+ .db 0b00001000
+ .db 0b00001000
+ .db 0b00001000
+ .db 0b00001000
+ .db 0b00111110
+ .db 0b00000000
+; Character: J
+ .db 0b00000000
+ .db 0b00000010
+ .db 0b00000010
+ .db 0b00000010
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b00111100
+ .db 0b00000000
+; Character: K
+ .db 0b00000000
+ .db 0b01000100
+ .db 0b01001000
+ .db 0b01110000
+ .db 0b01001000
+ .db 0b01000100
+ .db 0b01000010
+ .db 0b00000000
+; Character: L
+ .db 0b00000000
+ .db 0b01000000
+ .db 0b01000000
+ .db 0b01000000
+ .db 0b01000000
+ .db 0b01000000
+ .db 0b01111110
+ .db 0b00000000
+; Character: M
+ .db 0b00000000
+ .db 0b01000010
+ .db 0b01100110
+ .db 0b01011010
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b00000000
+; Character: N
+ .db 0b00000000
+ .db 0b01000010
+ .db 0b01100010
+ .db 0b01010010
+ .db 0b01001010
+ .db 0b01000110
+ .db 0b01000010
+ .db 0b00000000
+; Character: O
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b00111100
+ .db 0b00000000
+; Character: P
+ .db 0b00000000
+ .db 0b01111100
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01111100
+ .db 0b01000000
+ .db 0b01000000
+ .db 0b00000000
+; Character: Q
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01010010
+ .db 0b01001010
+ .db 0b00111100
+ .db 0b00000000
+; Character: R
+ .db 0b00000000
+ .db 0b01111100
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01111100
+ .db 0b01000100
+ .db 0b01000010
+ .db 0b00000000
+; Character: S
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000000
+ .db 0b00111100
+ .db 0b00000010
+ .db 0b01000010
+ .db 0b00111100
+ .db 0b00000000
+; Character: T
+ .db 0b00000000
+ .db 0b11111110
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00000000
+; Character: U
+ .db 0b00000000
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b00111100
+ .db 0b00000000
+; Character: V
+ .db 0b00000000
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b00100100
+ .db 0b00011000
+ .db 0b00000000
+; Character: W
+ .db 0b00000000
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01011010
+ .db 0b00100100
+ .db 0b00000000
+; Character: X
+ .db 0b00000000
+ .db 0b01000010
+ .db 0b00100100
+ .db 0b00011000
+ .db 0b00011000
+ .db 0b00100100
+ .db 0b01000010
+ .db 0b00000000
+; Character: Y
+ .db 0b00000000
+ .db 0b10000010
+ .db 0b01000100
+ .db 0b00101000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00000000
+; Character: Z
+ .db 0b00000000
+ .db 0b01111110
+ .db 0b00000100
+ .db 0b00001000
+ .db 0b00010000
+ .db 0b00100000
+ .db 0b01111110
+ .db 0b00000000
diff --git a/gbdk/gbdk-lib/libc/targets/z80/f_spect.s b/gbdk/gbdk-lib/libc/targets/z80/f_spect.s
new file mode 100644
index 00000000..0da22f4d
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/f_spect.s
@@ -0,0 +1,886 @@
+; font_spect.ms
+; Text font
+; Michael Hope, 1998
+; michaelh@earthling.net
+; Distrubuted under the Artistic License - see www.opensource.org
+;
+
+ .module font_spect
+ .area _HOME
+
+_font_spect::
+ .byte 1+4 ; 128 character encoding
+ .byte 128-32 ; Tiles required
+
+ .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ; All map to space
+ .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+ .byte 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 ; 0x20
+ .byte 16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31
+ .byte 32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47 ; 0x40
+ .byte 48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63
+ .byte 64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79 ; 0x60
+ .byte 80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95
+
+ .db 0
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+; Character: !
+ .db 0b00000000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00000000
+ .db 0b00010000
+ .db 0b00000000
+; Character: "
+ .db 0b00000000
+ .db 0b00100100
+ .db 0b00100100
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+; Character: #
+ .db 0b00000000
+ .db 0b00100100
+ .db 0b01111110
+ .db 0b00100100
+ .db 0b00100100
+ .db 0b01111110
+ .db 0b00100100
+ .db 0b00000000
+; Character: $
+ .db 0b00000000
+ .db 0b00001000
+ .db 0b00111110
+ .db 0b00101000
+ .db 0b00111110
+ .db 0b00001010
+ .db 0b00111110
+ .db 0b00001000
+; Character: %
+ .db 0b00000000
+ .db 0b01100010
+ .db 0b01100100
+ .db 0b00001000
+ .db 0b00010000
+ .db 0b00100110
+ .db 0b01000110
+ .db 0b00000000
+; Character: &
+ .db 0b00000000
+ .db 0b00010000
+ .db 0b00101000
+ .db 0b00010000
+ .db 0b00101010
+ .db 0b01000100
+ .db 0b00111010
+ .db 0b00000000
+; Character: '
+ .db 0b00000000
+ .db 0b00001000
+ .db 0b00010000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+; Character: (
+ .db 0b00000000
+ .db 0b00000100
+ .db 0b00001000
+ .db 0b00001000
+ .db 0b00001000
+ .db 0b00001000
+ .db 0b00000100
+ .db 0b00000000
+; Character: )
+ .db 0b00000000
+ .db 0b00100000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00100000
+ .db 0b00000000
+; Character: *
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00010100
+ .db 0b00001000
+ .db 0b00111110
+ .db 0b00001000
+ .db 0b00010100
+ .db 0b00000000
+; Character: +
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00001000
+ .db 0b00001000
+ .db 0b00111110
+ .db 0b00001000
+ .db 0b00001000
+ .db 0b00000000
+; Character: ,
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00001000
+ .db 0b00001000
+ .db 0b00010000
+; Character: -
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00111110
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+; Character: .
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00011000
+ .db 0b00011000
+ .db 0b00000000
+; Character: /
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000010
+ .db 0b00000100
+ .db 0b00001000
+ .db 0b00010000
+ .db 0b00100000
+ .db 0b00000000
+; Character: 0
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000110
+ .db 0b01001010
+ .db 0b01010010
+ .db 0b01100010
+ .db 0b00111100
+ .db 0b00000000
+; Character: 1
+ .db 0b00000000
+ .db 0b00011000
+ .db 0b00101000
+ .db 0b00001000
+ .db 0b00001000
+ .db 0b00001000
+ .db 0b00111110
+ .db 0b00000000
+; Character: 2
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000010
+ .db 0b00000010
+ .db 0b00111100
+ .db 0b01000000
+ .db 0b01111110
+ .db 0b00000000
+; Character: 3
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000010
+ .db 0b00001100
+ .db 0b00000010
+ .db 0b01000010
+ .db 0b00111100
+ .db 0b00000000
+; Character: 4
+ .db 0b00000000
+ .db 0b00001000
+ .db 0b00011000
+ .db 0b00101000
+ .db 0b01001000
+ .db 0b01111110
+ .db 0b00001000
+ .db 0b00000000
+; Character: 5
+ .db 0b00000000
+ .db 0b01111110
+ .db 0b01000000
+ .db 0b01111100
+ .db 0b00000010
+ .db 0b01000010
+ .db 0b00111100
+ .db 0b00000000
+; Character: 6
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000000
+ .db 0b01111100
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b00111100
+ .db 0b00000000
+; Character: 7
+ .db 0b00000000
+ .db 0b01111110
+ .db 0b00000010
+ .db 0b00000100
+ .db 0b00001000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00000000
+; Character: 8
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000010
+ .db 0b00111100
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b00111100
+ .db 0b00000000
+; Character: 9
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b00111110
+ .db 0b00000010
+ .db 0b00111100
+ .db 0b00000000
+; Character: :
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00010000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00010000
+ .db 0b00000000
+; Character: ;
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00010000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00100000
+; Character: <
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000100
+ .db 0b00001000
+ .db 0b00010000
+ .db 0b00001000
+ .db 0b00000100
+ .db 0b00000000
+; Character: =
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00111110
+ .db 0b00000000
+ .db 0b00111110
+ .db 0b00000000
+ .db 0b00000000
+; Character: >
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00010000
+ .db 0b00001000
+ .db 0b00000100
+ .db 0b00001000
+ .db 0b00010000
+ .db 0b00000000
+; Character: ?
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000010
+ .db 0b00000100
+ .db 0b00001000
+ .db 0b00000000
+ .db 0b00001000
+ .db 0b00000000
+; Character: @
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01001010
+ .db 0b01010110
+ .db 0b01011110
+ .db 0b01000000
+ .db 0b00111100
+ .db 0b00000000
+; Character: A
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01111110
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b00000000
+; Character: B
+ .db 0b00000000
+ .db 0b01111100
+ .db 0b01000010
+ .db 0b01111100
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01111100
+ .db 0b00000000
+; Character: C
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000010
+ .db 0b01000000
+ .db 0b01000000
+ .db 0b01000010
+ .db 0b00111100
+ .db 0b00000000
+; Character: D
+ .db 0b00000000
+ .db 0b01111000
+ .db 0b01000100
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01000100
+ .db 0b01111000
+ .db 0b00000000
+; Character: E
+ .db 0b00000000
+ .db 0b01111110
+ .db 0b01000000
+ .db 0b01111100
+ .db 0b01000000
+ .db 0b01000000
+ .db 0b01111110
+ .db 0b00000000
+; Character: F
+ .db 0b00000000
+ .db 0b01111110
+ .db 0b01000000
+ .db 0b01111100
+ .db 0b01000000
+ .db 0b01000000
+ .db 0b01000000
+ .db 0b00000000
+; Character: G
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000010
+ .db 0b01000000
+ .db 0b01001110
+ .db 0b01000010
+ .db 0b00111100
+ .db 0b00000000
+; Character: H
+ .db 0b00000000
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01111110
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b00000000
+; Character: I
+ .db 0b00000000
+ .db 0b00111110
+ .db 0b00001000
+ .db 0b00001000
+ .db 0b00001000
+ .db 0b00001000
+ .db 0b00111110
+ .db 0b00000000
+; Character: J
+ .db 0b00000000
+ .db 0b00000010
+ .db 0b00000010
+ .db 0b00000010
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b00111100
+ .db 0b00000000
+; Character: K
+ .db 0b00000000
+ .db 0b01000100
+ .db 0b01001000
+ .db 0b01110000
+ .db 0b01001000
+ .db 0b01000100
+ .db 0b01000010
+ .db 0b00000000
+; Character: L
+ .db 0b00000000
+ .db 0b01000000
+ .db 0b01000000
+ .db 0b01000000
+ .db 0b01000000
+ .db 0b01000000
+ .db 0b01111110
+ .db 0b00000000
+; Character: M
+ .db 0b00000000
+ .db 0b01000010
+ .db 0b01100110
+ .db 0b01011010
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b00000000
+; Character: N
+ .db 0b00000000
+ .db 0b01000010
+ .db 0b01100010
+ .db 0b01010010
+ .db 0b01001010
+ .db 0b01000110
+ .db 0b01000010
+ .db 0b00000000
+; Character: O
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b00111100
+ .db 0b00000000
+; Character: P
+ .db 0b00000000
+ .db 0b01111100
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01111100
+ .db 0b01000000
+ .db 0b01000000
+ .db 0b00000000
+; Character: Q
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01010010
+ .db 0b01001010
+ .db 0b00111100
+ .db 0b00000000
+; Character: R
+ .db 0b00000000
+ .db 0b01111100
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01111100
+ .db 0b01000100
+ .db 0b01000010
+ .db 0b00000000
+; Character: S
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000000
+ .db 0b00111100
+ .db 0b00000010
+ .db 0b01000010
+ .db 0b00111100
+ .db 0b00000000
+; Character: T
+ .db 0b00000000
+ .db 0b11111110
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00000000
+; Character: U
+ .db 0b00000000
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b00111100
+ .db 0b00000000
+; Character: V
+ .db 0b00000000
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b00100100
+ .db 0b00011000
+ .db 0b00000000
+; Character: W
+ .db 0b00000000
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01000010
+ .db 0b01011010
+ .db 0b00100100
+ .db 0b00000000
+; Character: X
+ .db 0b00000000
+ .db 0b01000010
+ .db 0b00100100
+ .db 0b00011000
+ .db 0b00011000
+ .db 0b00100100
+ .db 0b01000010
+ .db 0b00000000
+; Character: Y
+ .db 0b00000000
+ .db 0b10000010
+ .db 0b01000100
+ .db 0b00101000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00000000
+; Character: Z
+ .db 0b00000000
+ .db 0b01111110
+ .db 0b00000100
+ .db 0b00001000
+ .db 0b00010000
+ .db 0b00100000
+ .db 0b01111110
+ .db 0b00000000
+; Character: [
+ .db 0b00000000
+ .db 0b00001110
+ .db 0b00001000
+ .db 0b00001000
+ .db 0b00001000
+ .db 0b00001000
+ .db 0b00001110
+ .db 0b00000000
+; Character: \
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b01000000
+ .db 0b00100000
+ .db 0b00010000
+ .db 0b00001000
+ .db 0b00000100
+ .db 0b00000000
+; Character: ]
+ .db 0b00000000
+ .db 0b01110000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b01110000
+ .db 0b00000000
+; Character: ^
+ .db 0b00000000
+ .db 0b00010000
+ .db 0b00111000
+ .db 0b01010100
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00000000
+; Character: _
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b11111111
+; Character: Pound
+ .db 0b00000000
+ .db 0b00011100
+ .db 0b00100010
+ .db 0b01111000
+ .db 0b00100000
+ .db 0b00100000
+ .db 0b01111110
+ .db 0b00000000
+; Character: a
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00111000
+ .db 0b00000100
+ .db 0b00111100
+ .db 0b01000100
+ .db 0b00111100
+ .db 0b00000000
+; Character: b
+ .db 0b00000000
+ .db 0b00100000
+ .db 0b00100000
+ .db 0b00111100
+ .db 0b00100010
+ .db 0b00100010
+ .db 0b00111100
+ .db 0b00000000
+; Character: c
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00011100
+ .db 0b00100000
+ .db 0b00100000
+ .db 0b00100000
+ .db 0b00011100
+ .db 0b00000000
+; Character: d
+ .db 0b00000000
+ .db 0b00000100
+ .db 0b00000100
+ .db 0b00111100
+ .db 0b01000100
+ .db 0b01000100
+ .db 0b00111100
+ .db 0b00000000
+; Character: e
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00111000
+ .db 0b01000100
+ .db 0b01111000
+ .db 0b01000000
+ .db 0b00111100
+ .db 0b00000000
+; Character: f
+ .db 0b00000000
+ .db 0b00001100
+ .db 0b00010000
+ .db 0b00011000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00000000
+; Character: g
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000100
+ .db 0b01000100
+ .db 0b00111100
+ .db 0b00000100
+ .db 0b00111000
+; Character: h
+ .db 0b00000000
+ .db 0b01000000
+ .db 0b01000000
+ .db 0b01111000
+ .db 0b01000100
+ .db 0b01000100
+ .db 0b01000100
+ .db 0b00000000
+; Character: i
+ .db 0b00000000
+ .db 0b00010000
+ .db 0b00000000
+ .db 0b00110000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00111000
+ .db 0b00000000
+; Character: j
+ .db 0b00000000
+ .db 0b00000100
+ .db 0b00000000
+ .db 0b00000100
+ .db 0b00000100
+ .db 0b00000100
+ .db 0b00100100
+ .db 0b00011000
+; Character: k
+ .db 0b00000000
+ .db 0b00100000
+ .db 0b00101000
+ .db 0b00110000
+ .db 0b00110000
+ .db 0b00101000
+ .db 0b00100100
+ .db 0b00000000
+; Character: l
+ .db 0b00000000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00001100
+ .db 0b00000000
+; Character: m
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b01101000
+ .db 0b01010100
+ .db 0b01010100
+ .db 0b01010100
+ .db 0b01010100
+ .db 0b00000000
+; Character: n
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b01111000
+ .db 0b01000100
+ .db 0b01000100
+ .db 0b01000100
+ .db 0b01000100
+ .db 0b00000000
+; Character: o
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00111000
+ .db 0b01000100
+ .db 0b01000100
+ .db 0b01000100
+ .db 0b00111000
+ .db 0b00000000
+; Character: p
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b01111000
+ .db 0b01000100
+ .db 0b01000100
+ .db 0b01111000
+ .db 0b01000000
+ .db 0b01000000
+; Character: q
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00111100
+ .db 0b01000100
+ .db 0b01000100
+ .db 0b00111100
+ .db 0b00000100
+ .db 0b00000110
+; Character: r
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00011100
+ .db 0b00100000
+ .db 0b00100000
+ .db 0b00100000
+ .db 0b00100000
+ .db 0b00000000
+; Character: s
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00111000
+ .db 0b01000000
+ .db 0b00111000
+ .db 0b00000100
+ .db 0b01111000
+ .db 0b00000000
+; Character: t
+ .db 0b00000000
+ .db 0b00010000
+ .db 0b00111000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b00001100
+ .db 0b00000000
+; Character: u
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b01000100
+ .db 0b01000100
+ .db 0b01000100
+ .db 0b01000100
+ .db 0b00111000
+ .db 0b00000000
+; Character: v
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b01000100
+ .db 0b01000100
+ .db 0b00101000
+ .db 0b00101000
+ .db 0b00010000
+ .db 0b00000000
+; Character: w
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b01000100
+ .db 0b01010100
+ .db 0b01010100
+ .db 0b01010100
+ .db 0b00101000
+ .db 0b00000000
+; Character: x
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b01000100
+ .db 0b00101000
+ .db 0b00010000
+ .db 0b00101000
+ .db 0b01000100
+ .db 0b00000000
+; Character: y
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b01000100
+ .db 0b01000100
+ .db 0b01000100
+ .db 0b00111100
+ .db 0b00000100
+ .db 0b00111000
+; Character: z
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b01111100
+ .db 0b00001000
+ .db 0b00010000
+ .db 0b00100000
+ .db 0b01111100
+ .db 0b00000000
+; Character: {
+ .db 0b00000000
+ .db 0b00001110
+ .db 0b00001000
+ .db 0b00110000
+ .db 0b00001000
+ .db 0b00001000
+ .db 0b00001110
+ .db 0b00000000
+; Character: |
+ .db 0b00000000
+ .db 0b00001000
+ .db 0b00001000
+ .db 0b00001000
+ .db 0b00001000
+ .db 0b00001000
+ .db 0b00001000
+ .db 0b00000000
+; Character: }
+ .db 0b00000000
+ .db 0b01110000
+ .db 0b00010000
+ .db 0b00001100
+ .db 0b00010000
+ .db 0b00010000
+ .db 0b01110000
+ .db 0b00000000
+; Character: ~
+ .db 0b00000000
+ .db 0b00010100
+ .db 0b00101000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+ .db 0b00000000
+; Character: Copyright
+ .db 0b00111100
+ .db 0b01000010
+ .db 0b10011001
+ .db 0b10100001
+ .db 0b10100001
+ .db 0b10011001
+ .db 0b01000010
+ .db 0b00111100
diff --git a/gbdk/gbdk-lib/libc/targets/z80/far_ptr.s b/gbdk/gbdk-lib/libc/targets/z80/far_ptr.s
new file mode 100644
index 00000000..de908303
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/far_ptr.s
@@ -0,0 +1,64 @@
+;--------------------------------------------------------------------------
+; far_ptr.s
+;
+; Copyright (C) 2020, Tony Pavlov
+;
+; This library is free software; you can redistribute it and/or modify it
+; under the terms of the GNU General Public License as published by the
+; Free Software Foundation; either version 2, or (at your option) any
+; later version.
+;
+; This library is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this library; see the file COPYING. If not, write to the
+; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+; MA 02110-1301, USA.
+;
+; As a special exception, if you link this library with other files,
+; some of which are compiled with SDCC, to produce an executable,
+; this library does not by itself cause the resulting executable to
+; be covered by the GNU General Public License. This exception does
+; not however invalidate any other reasons why the executable file
+; might be covered by the GNU General Public License.
+;--------------------------------------------------------------------------
+
+ .module far_ptr
+
+ .include "global.s"
+
+ .area _HOME
+
+___call__banked::
+
+ ld a, (#.MAP_FRAME1)
+ push af
+ inc sp
+ ld a, (___call_banked_bank)
+ ld (#.MAP_FRAME1), a
+ ld hl, (___call_banked_addr)
+ CALL_HL
+ dec sp
+ pop af
+ ld (#.MAP_FRAME1), a
+ ret
+
+_to_far_ptr::
+ pop bc
+ pop hl
+ pop de
+ push de
+ push hl
+ push bc
+ ret
+
+ .area _DATA
+
+___call_banked_ptr::
+___call_banked_addr::
+ .ds 0x02 ; far pointer offset
+___call_banked_bank::
+ .ds 0x02 ; far pointer segment
diff --git a/gbdk/gbdk-lib/libc/targets/z80/font.s b/gbdk/gbdk-lib/libc/targets/z80/font.s
new file mode 100644
index 00000000..76169b97
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/font.s
@@ -0,0 +1,170 @@
+ .include "global.s"
+
+ .title "Font utilities"
+ .module FontUtils
+
+ .globl .memset_small
+ .globl _font_ibm
+ .globl __current_1bpp_colors, .fg_colour, .bg_colour
+ .globl _set_native_tile_data, _set_tile_1bpp_data
+
+ ; Structure offsets
+ sfont_handle_sizeof = 3
+ sfont_handle_font = 1
+ sfont_handle_first_tile = 0
+
+ ; Encoding types - lower 2 bits of font
+ FONT_256ENCODING = 0
+ FONT_128ENCODING = 1
+ FONT_NOENCODING = 2
+
+ ; Other bits
+ FONT_BCOMPRESSED = 2
+
+ ; Maximum number of fonts
+ .MAX_FONTS = 6
+
+ .area _DATA
+ ; The current font
+font_current::
+ .ds sfont_handle_sizeof
+ ; Cached copy of the first free tile
+font_first_free_tile:
+ .ds 1
+ ; Table containing descriptors for all of the fonts
+font_table:
+ .ds (sfont_handle_sizeof*.MAX_FONTS)
+
+ .area _HOME
+
+; void vmemcpy (unsigned int dst, const void *src, unsigned int size) __z88dk_callee __preserves_regs(iyh,iyl);
+_font_init::
+ xor a
+ ld (font_first_free_tile), a
+
+ ld hl, #font_table
+ ld c, #(sfont_handle_sizeof*.MAX_FONTS)
+ call .memset_small
+
+ ret
+
+_font_set::
+ pop de
+ pop hl
+ push hl
+ push de
+
+font_set::
+ ld de, #font_current
+ ld bc, #sfont_handle_sizeof
+ ldir
+ ret
+
+_font_color::
+ pop de
+ ex (sp), hl
+ push de
+ ld (__current_1bpp_colors), hl
+ ret
+
+font_load_ibm::
+ ld hl, #_font_ibm
+ jp font_load
+
+_font_load::
+ pop de
+ pop hl
+ push hl
+ push de
+
+ ;; load font in HL to free slor
+font_load::
+ push hl
+ ; find free slot
+ ld b, #.MAX_FONTS
+ ld hl, #(font_table+sfont_handle_font)
+1$:
+ ld a, (hl)
+ inc hl
+ or (hl)
+ jr z, 2$ ; found
+ inc hl
+ inc hl
+ dec b
+ jr nz, 1$
+
+ ld hl, #0 ; no free slot
+ ret
+2$:
+ ; fill free slot with passed pointer
+ pop de
+ ld (hl), d
+ dec hl
+ ld (hl), e
+ ld a, (font_first_free_tile)
+ dec hl
+ ld (hl),a
+
+ push hl
+ call font_set
+
+ call load_font_tiles
+
+ ld hl, (font_current+sfont_handle_font)
+
+ inc hl ; Number of tiles used
+ ld a, (font_first_free_tile)
+ add (hl)
+ ld (font_first_free_tile), a
+
+ pop hl ; return handle in hl
+ ret
+
+load_font_tiles:
+ ld hl, (font_current+sfont_handle_font)
+
+ inc hl
+ ld e, (hl)
+ ld d, #0
+
+ dec hl
+ ld a, (hl) ; a = flags
+ push af
+ and #3
+
+ ld bc, #128
+ cp #FONT_128ENCODING ; 0 for 256 char encoding table, 1 for 128 char
+ jr z, 1$
+
+ ld bc, #0
+ cp #FONT_NOENCODING
+ jr z, 1$
+
+ ld bc, #256 ; Must be 256 element encoding
+1$:
+ inc hl
+ inc hl ; Points to the start of the encoding table
+ add hl, bc
+
+ ld a,(font_current+sfont_handle_first_tile)
+ ld c, a
+ ld b, #0
+
+ pop af ; Recover flags
+ bit FONT_BCOMPRESSED, a ; Is this font compressed?
+ jp z, 2$
+
+ push hl
+ ld hl, (__current_1bpp_colors)
+ ex (sp), hl
+ push hl
+ push de
+ push bc
+ call _set_tile_1bpp_data
+ ret
+2$:
+ push hl
+ push de
+ push bc
+ call _set_native_tile_data
+ ret
diff --git a/gbdk/gbdk-lib/libc/targets/z80/gb_decompress.s b/gbdk/gbdk-lib/libc/targets/z80/gb_decompress.s
new file mode 100644
index 00000000..00c9c947
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/gb_decompress.s
@@ -0,0 +1,90 @@
+; GB-Deompress routine
+; Compatible with GBTD
+
+ .include "global.s"
+
+ .title "GB Decompress"
+ .module GBDecompress
+
+ .area _CODE
+
+; hl = source; de = dest
+_gb_decompress::
+ pop hl
+ pop de
+ ex (sp), hl
+ ex de, hl
+ push bc
+ push de
+1$:
+ ld a, (hl) ; load command
+ inc hl
+ or a
+ jr z, 9$ ; exit, if last byte
+ bit 7, a
+ jr nz, 5$ ; string functions
+ bit 6, a
+ jr nz, 3$
+ ; RLE byte
+ and #63 ; calc counter
+ inc a
+ ld b, a
+ ld a, (hl)
+ inc hl
+2$:
+ ld (de), a
+ inc de
+ dec b
+ jr nz, 2$
+ jr 1$ ; next command
+3$: ; RLE word
+ and #63
+ inc a
+ ld c, (hl) ; load word into bc
+ inc hl
+ ld b, (hl)
+ inc hl
+ ex de, hl
+4$:
+ ld (hl), c
+ inc hl
+ ld (hl), b
+ inc hl
+ dec a
+ jr nz, 4$
+ ex de, hl
+ jr 1$ ; next command
+5$:
+ bit 6, a
+ jr nz, 7$
+ ; string repeat
+ and #63
+ inc a
+ push hl
+ ld c, (hl)
+ inc hl
+ ld b, (hl)
+ ld h, d
+ ld l, e
+ add hl, bc
+ ld c, a
+ ld b, #0
+ ldir
+ pop hl
+ inc hl
+ inc hl
+ jr 1$ ; next command
+7$: ; string copy
+ and #63
+ inc a
+ ld c, a
+ ld b, #0
+ ldir
+ jr 1$ ; next command
+9$:
+ pop hl
+ ex de, hl
+ or a ; clear carry flag
+ sbc hl, de
+ pop bc
+ ret
diff --git a/gbdk/gbdk-lib/libc/targets/z80/gg/Makefile b/gbdk/gbdk-lib/libc/targets/z80/gg/Makefile
new file mode 100644
index 00000000..63ec01d7
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/gg/Makefile
@@ -0,0 +1,44 @@
+# GB specific Makefile
+
+TOPDIR = ../../../..
+
+THIS = gg
+PORT = z80
+
+CSRC = crlf.c
+
+ASSRC = set_interrupts.s \
+ outi.s vmemcpy.s \
+ sms_refresh_oam.s \
+ sms_set_native_data.s sms_set_1bpp_data.s sms_set_2bpp_data.s \
+ set_tile_map.s set_tile_map_xy.s set_tile_map_compat.s set_tile_map_xy_compat.s \
+ set_tile_submap.s set_tile_submap_compat.s \
+ coords_to_address.s \
+ set_tile.s \
+ sms_fill_rect.s sms_fill_rect_xy.s sms_fill_rect_compat.s sms_fill_rect_xy_compat.s \
+ sms_metasprites.s sms_metasprites_hide.s sms_metasprites_hide_spr.s \
+ f_ibm_full.s f_ibm_sh.s f_italic.s f_min.s f_spect.s \
+ font.s color.s \
+ putchar.s \
+ scroll.s cls.s gotoxy.s \
+ palette.s set_palette.s \
+ pad.s pad_ex.s \
+ sms_int.s nmi.s \
+ mode.s clock.s \
+ delay.s \
+ emu_debug_printf.s \
+ memset_small.s \
+ far_ptr.s \
+ gb_decompress.s \
+ rle_decompress.s \
+ heap.s \
+ __sdcc_bcall.s \
+ crt0.s
+
+CRT0 = crt0.s
+
+include $(TOPDIR)/Makefile.common
+
+AS = $(AS_Z80)
+
+include ../../../Makefile.platform
diff --git a/gbdk/gbdk-lib/libc/targets/z80/gg/__sdcc_bcall.s b/gbdk/gbdk-lib/libc/targets/z80/gg/__sdcc_bcall.s
new file mode 100644
index 00000000..60ebd504
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/gg/__sdcc_bcall.s
@@ -0,0 +1,68 @@
+ .include "global.s"
+
+ .area _CODE
+
+ .globl ___sdcc_bcall
+ .globl ___sdcc_bcall_abc
+ .globl ___sdcc_bcall_ehl
+;
+; trampoline to call banked functions
+; used when legacy banking is enabled only
+; Usage:
+; call ___sdcc_bcall
+; .dw <function>
+; .dw <function_bank>
+;
+___sdcc_bcall::
+ ex (sp), hl
+ ld c, (hl)
+ inc hl
+ ld b, (hl)
+ inc hl
+ ld a, (hl)
+ inc hl
+ inc hl
+ ex (sp), hl
+;
+; trampoline to call banked functions with __z88dk_fastcall calling convention
+; Usage:
+; ld a, #<function_bank>
+; ld bc, #<function>
+; call ___sdcc_bcall_abc
+;
+___sdcc_bcall_abc::
+ push hl
+ ld l, a
+ ld a, (#.MAP_FRAME1)
+ ld h, a
+ ld a, l
+ ld (#.MAP_FRAME1), a
+ ex (sp), hl
+ inc sp
+ call ___sdcc_bjump_abc
+ dec sp
+ pop af
+ ld (#.MAP_FRAME1), a
+ ret
+;
+___sdcc_bjump_abc:
+ push bc
+ ret
+;
+; default trampoline to call banked functions
+; Usage:
+; ld e, #<function_bank>
+; ld hl, #<function>
+; call ___sdcc_bcall_ehl
+;
+___sdcc_bcall_ehl::
+ ld a, (#.MAP_FRAME1)
+ push af
+ inc sp
+ ld a, e
+ ld (#.MAP_FRAME1), a
+ CALL_HL
+ dec sp
+ pop af
+ ld (#.MAP_FRAME1), a
+ ret
diff --git a/gbdk/gbdk-lib/libc/targets/z80/gg/crlf.c b/gbdk/gbdk-lib/libc/targets/z80/gg/crlf.c
new file mode 100644
index 00000000..aca6ec82
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/gg/crlf.c
@@ -0,0 +1 @@
+const char * const __crlf = "\n"; \ No newline at end of file
diff --git a/gbdk/gbdk-lib/libc/targets/z80/gg/crt0.s b/gbdk/gbdk-lib/libc/targets/z80/gg/crt0.s
new file mode 100644
index 00000000..656cbe7e
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/gg/crt0.s
@@ -0,0 +1,268 @@
+ .include "global.s"
+
+ .title "Runtime"
+ .module Runtime
+ .area _HEADER (ABS)
+
+ .globl _set_default_palette
+
+ .org 0x00 ; Reset 00h
+ di ; disable interrupt
+ im 1 ; interrupt mode 1 (this won't change)
+ jp .init
+
+; .org 0x08 ; --profile handler
+
+ .org 0x10 ; RST 0x10: VDP_WRITE_CMD
+
+_WRITE_VDP_CMD::
+ VDP_WRITE_CMD h, l
+ ret
+
+; .org 0x18 ; unusable
+
+ .org 0x20 ; RST 0x20: VDP_WRITE_DATA
+
+_WRITE_VDP_DATA::
+ VDP_WRITE_DATA h, l
+ ret
+
+; .org 0x28 ; unusable
+
+ .org 0x30 ; RST 0x30: call HL
+.call_hl::
+ jp (HL)
+
+ .org 0x38 ; handle IRQ
+ jp _INT_ISR
+
+ .org 0x66 ; handle NMI
+ jp _NMI_ISR
+
+ .org 0x80
+
+.init::
+ ld sp, #.STACK ; set stack pointer at end of RAM
+
+ ld a, (#.BIOS)
+ push af
+
+ xor a
+ ld bc, #l__DATA
+ ld hl, #s__DATA
+ call .memset_simple ; initialize veriables in RAM with zero
+
+ pop af
+ ld (#__BIOS), a ; save BIOS value
+
+ ld hl, #_shadow_OAM
+ ld de, #(_shadow_OAM + 1)
+ ld bc, #64
+ ld (hl), #0xc0
+ ldir
+ ld (hl), #0
+ ld bc, #(128 - 1)
+ ldir
+
+ ld hl,#0x0000 ; initialize mappers
+ ld (#.RAM_CONTROL),hl ; [.RAM_CONTROL]=$00, [.MAP_FRAME0]=$00
+ ld hl,#0x0201
+ ld (#.MAP_FRAME1),hl ; [.MAP_FRAME1]=$01, [.MAP_FRAME2]=$02
+
+ ;; Initialise global variables
+ call .gsinit
+
+ ;; Initialize VDP
+ ld c, #.VDP_CMD
+ ld b, #(.shadow_VDP_end - .shadow_VDP)
+ ld hl,#(.shadow_VDP_end - 1)
+1$:
+ outd
+
+ ld a, b
+ or #.VDP_REG_MASK
+ out (c), a
+
+ ld a, b
+ or a
+ jr nz, 1$
+
+ ;; detect PAL/NTSC
+ in a, (.GG_STATE)
+ and #.GGSTATE_NNTS
+ jr nz, 2$
+ ld a, #.SYSTEM_NTSC
+ jr 3$
+2$:
+ ld a, #.SYSTEM_PAL
+3$:
+ ld (#__SYSTEM), a
+
+ call .clear_VRAM
+
+ call _set_default_palette
+
+ VDP_CANCEL_INT
+
+ ei ; re-enable interrupts before going to main()
+ call _main
+10$:
+ halt
+ jr 10$
+
+ ;; Ordering of segments for the linker.
+ .area _HOME
+ .area _BASE
+ .area _CODE
+ .area _CODE_0
+ .area _LIT
+ .area _INITIALIZER
+ .area _GSINIT
+ .area _GSFINAL
+
+ .area _DATA
+ .area _INITIALIZED
+ .area _BSEG
+ .area _BSS
+ .area _HEAP
+ .area _HEAP_END
+
+ .area _CODE
+ .area _GSINIT
+.gsinit::
+ ;; initialize static storage variables
+ ld bc, #l__INITIALIZER
+ ld hl, #s__INITIALIZER
+ ld de, #s__INITIALIZED
+ call .memcpy_simple
+
+ .area _GSFINAL
+ ret
+
+ .area _HOME
+
+.clear_VRAM:
+ ld a, #<.VDP_VRAM
+ out (#.VDP_CMD), a
+ ld a, #>.VDP_VRAM
+ out (#.VDP_CMD), a
+ xor a
+ ld bc, #0x4101
+ jr 6$
+5$:
+ out (.VDP_DATA), a
+6$:
+ dec c
+ jr nz, 5$
+ dec b
+ jr nz, 5$
+ ret
+
+ ;; fills memory at HL of length BC with A, clobbers DE
+.memset_simple::
+ ld e, a
+ ld a, c
+ or b
+ ret z
+ ld (hl), e
+ dec bc
+ ld d, h
+ ld e, l
+ inc de
+
+ ;; copies BC bytes from HL into DE
+.memcpy_simple::
+ ld a, c
+ or b
+ ret z
+ ldir
+ ret
+
+ ;; Wait for VBL interrupt to be finished
+.wait_vbl_done::
+_wait_vbl_done::
+ ld a, (_shadow_VDP_R1)
+ and #.R1_DISP_ON
+ ret z
+
+ xor a
+ ld (.vbl_done), a
+1$:
+ halt
+ ld a, (.vbl_done)
+ or a
+ jr z, 1$
+ ret
+
+ .area _DATA
+
+.start_crt_globals:
+__BIOS::
+ .ds 0x01 ; GB type (GB, PGB, CGB)
+__SYSTEM::
+ .ds 0x01 ; PAL/NTSC
+.end_crt_globals:
+
+ .area _INITIALIZED
+.shadow_VDP:
+_shadow_VDP_R0::
+ .ds 0x01
+_shadow_VDP_R1::
+ .ds 0x01
+_shadow_VDP_R2::
+ .ds 0x01
+_shadow_VDP_R3::
+ .ds 0x01
+_shadow_VDP_R4::
+ .ds 0x01
+_shadow_VDP_R5::
+ .ds 0x01
+_shadow_VDP_R6::
+ .ds 0x01
+_shadow_VDP_R7::
+_shadow_VDP_RBORDER::
+ .ds 0x01
+_shadow_VDP_R8::
+_shadow_VDP_RSCX::
+ .ds 0x01
+_shadow_VDP_R9::
+_shadow_VDP_RSCY::
+ .ds 0x01
+_shadow_VDP_R10::
+ .ds 0x01
+.shadow_VDP_end::
+
+.sys_time::
+_sys_time::
+ .ds 0x02
+.vbl_done::
+ .ds 0x01
+_VDP_ATTR_SHIFT::
+.vdp_shift::
+ .ds 0x01
+__shadow_OAM_base::
+ .ds 0x01
+__shadow_OAM_OFF::
+ .ds 0x01
+.mode::
+ .ds 0x01 ; Current mode
+
+ .area _INITIALIZER
+
+ .db .R0_DEFAULT
+ .db #(.R1_DEFAULT | .R1_DISP_ON | .R1_IE) ; VBLANK
+ .db .R2_MAP_0x3800
+ .db 0xFF
+ .db 0xFF
+ .db .R5_SAT_0x3F00
+ .db .R6_DATA_0x2000
+ .db #(0 | .R7_COLOR_MASK)
+ .db 0 ; SCX
+ .db 0 ; SCY
+ .db .R10_INT_OFF
+ .dw 0x0000 ; .sys_time
+ .db 0 ; .vbl_done
+ .db 0 ; _VDP_ATTR_SHIFT
+ .db #>_shadow_OAM ; __shadow_OAM_base
+ .db 0 ; __shadow_OAM_OFF
+ .db .T_MODE_INOUT ; .mode \ No newline at end of file
diff --git a/gbdk/gbdk-lib/libc/targets/z80/gg/global.s b/gbdk/gbdk-lib/libc/targets/z80/gg/global.s
new file mode 100644
index 00000000..3d618b47
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/gg/global.s
@@ -0,0 +1,345 @@
+ .GG_STATE = 0x00
+
+ .GGSTATE_STT = 0b10000000
+ .GGSTATE_NJAP = 0b01000000
+ .GGSTATE_NNTS = 0b00100000
+
+ .GG_EXT_7BIT = 0x01
+
+ .GG_EXT_CTL = 0x02
+
+ .GGEXT_NINIT = 0b10000000
+
+ .GG_SIO_SEND = 0x03
+ .GG_SIO_RECV = 0x04
+ .GG_SIO_CTL = 0x05
+
+ .SIOCTL_TXFL = 0b00000001
+ .SIOCTL_RXRD = 0b00000010
+ .SIOCTL_FRER = 0b00000100
+ .SIOCTL_INT = 0b00001000
+ .SIOCTL_TON = 0b00010000
+ .SIOCTL_RON = 0b00100000
+ .SIOCTL_BS0 = 0b01000000
+ .SIOCTL_BS1 = 0b10000000
+
+ .GG_SOUND_PAN = 0x06
+
+ .SOUNDPAN_TN1R = 0b00000001
+ .SOUNDPAN_TN2R = 0b00000010
+ .SOUNDPAN_TN3R = 0b00000100
+ .SOUNDPAN_NOSR = 0b00001000
+ .SOUNDPAN_TN1L = 0b00010000
+ .SOUNDPAN_TN2L = 0b00100000
+ .SOUNDPAN_TN3L = 0b01000000
+ .SOUNDPAN_NOSL = 0b10000000
+
+ .MEMORY_CTL = 0x3E
+
+ .MEMCTL_JOYON = 0b00000000
+ .MEMCTL_JOYOFF = 0b00000100
+ .MEMCTL_BASEON = 0b00000000
+ .MEMCTL_BASEOFF = 0b00001000
+ .MEMCTL_RAMON = 0b00000000
+ .MEMCTL_RAMOFF = 0b00010000
+ .MEMCTL_CROMON = 0b00000000
+ .MEMCTL_CROMOFF = 0b00100000
+ .MEMCTL_ROMON = 0b00000000
+ .MEMCTL_ROMOFF = 0b01000000
+ .MEMCTL_EXTON = 0b00000000
+ .MEMCTL_EXTOFF = 0b10000000
+
+ .JOY_CTL = 0x3F
+
+ .JOY_P1_LATCH = 0b00000010
+ .JOY_P2_LATCH = 0b00001000
+
+ .VDP_VRAM = 0x4000
+ .VDP_TILEMAP = 0x7800
+ .VDP_CRAM = 0xC000
+ .VDP_SAT = 0x7F00
+
+ .VDP_SAT_TERM = 0xD0
+
+ .VDP_VCOUNTER = 0x7E
+ .VDP_PSG = 0x7F
+ .VDP_HCOUNTER = 0x7F
+
+ .VDP_DATA = 0xBE
+ .VDP_CMD = 0xBF
+ .VDP_STAT = 0xBF
+
+ .STATF_INT_VBL = 0b10000000
+ .STATF_9_SPR = 0b01000000
+ .STATF_SPR_COLL = 0b00100000
+
+ .VDP_REG_MASK = 0b10000000
+ .VDP_R0 = 0b10000000
+
+ .R0_VSCRL = 0b00000000
+ .R0_VSCRL_INH = 0b10000000
+ .R0_HSCRL = 0b00000000
+ .R0_HSCRL_INH = 0b01000000
+ .R0_NO_LCB = 0b00000000
+ .R0_LCB = 0b00100000
+ .R0_IE1_OFF = 0b00000000
+ .R0_IE1 = 0b00010000
+ .R0_SS_OFF = 0b00000000
+ .R0_SS = 0b00001000
+ .R0_DEFAULT = 0b00000110
+ .R0_ES_OFF = 0b00000000
+ .R0_ES = 0b00000001
+
+ .VDP_R1 = 0b10000001
+
+ .R1_DEFAULT = 0b10000000
+ .R1_DISP_OFF = 0b00000000
+ .R1_DISP_ON = 0b01000000
+ .R1_IE_OFF = 0b00000000
+ .R1_IE = 0b00100000
+ .R1_SPR_8X8 = 0b00000000
+ .R1_SPR_8X16 = 0b00000010
+
+ .VDP_R2 = 0b10000010
+
+ .R2_MAP_0x3800 = 0xFF
+ .R2_MAP_0x3000 = 0xFD
+ .R2_MAP_0x2800 = 0xFB
+ .R2_MAP_0x2000 = 0xF9
+ .R2_MAP_0x1800 = 0xF7
+ .R2_MAP_0x1000 = 0xF5
+ .R2_MAP_0x0800 = 0xF3
+ .R2_MAP_0x0000 = 0xF1
+
+ .VDP_R3 = 0b10000011
+ .VDP_R4 = 0b10000100
+ .VDP_R5 = 0b10000101
+
+ .R5_SAT_0x3F00 = 0xFF
+ .R5_SAT_MASK = 0b10000001
+
+ .VDP_R6 = 0b10000110
+
+ .R6_BANK0 = 0xFB
+ .R6_DATA_0x0000 = 0xFB
+ .R6_BANK1 = 0xFF
+ .R6_DATA_0x2000 = 0xFF
+
+ .VDP_R7 = 0b10000111
+ .VDP_RBORDER = 0b10000111
+
+ .R7_COLOR_MASK = 0b11110000
+
+ .VDP_R8 = 0b10001000
+ .VDP_RSCX = 0b10001000
+
+ .VDP_R9 = 0b10001001
+ .VDP_RSCY = 0b10001001
+
+ .VDP_R10 = 0b10001010
+
+ .R10_INT_OFF = 0xFF
+ .R10_INT_EVERY = 0x00
+
+ .JOYPAD_COUNT = 1
+
+ .UP = 0b00000001
+ .DOWN = 0b00000010
+ .LEFT = 0b00000100
+ .RIGHT = 0b00001000
+ .A = 0b00010000
+ .B = 0b00100000
+ .SELECT = 0b00100000 ; map to B
+ .START = 0b10000000 ; Game Gear Start button
+
+ .JOY_PORT1 = 0xDC
+
+ .JOY_P1_UP = 0b00000001
+ .JOY_P1_DOWN = 0b00000010
+ .JOY_P1_LEFT = 0b00000100
+ .JOY_P1_RIGHT = 0b00001000
+ .JOY_P1_SW1 = 0b00010000
+ .JOY_P1_TRIGGER = 0b00010000
+ .JOY_P1_SW2 = 0b00100000
+ .JOY_P2_UP = 0b01000000
+ .JOY_P2_DOWN = 0b10000000
+
+ .JOY_PORT2 = 0xDD
+
+ .JOY_P2_LEFT = 0b00000001
+ .JOY_P2_RIGHT = 0b00000010
+ .JOY_P2_SW1 = 0b00000100
+ .JOY_P2_TRIGGER = 0b00000100
+ .JOY_P2_SW2 = 0b00001000
+ .JOY_RESET = 0b00010000
+ .JOY_P1_LIGHT = 0b01000000
+ .JOY_P2_LIGHT = 0b10000000
+
+ .FMADDRESS = 0xF0
+ .FMDATA = 0xF1
+ .AUDIOCTRL = 0xF2
+
+ .RAM_CONTROL = 0xfffc
+
+ .RAMCTL_BANK = 0b00000100
+ .RAMCTL_ROM = 0b00000000
+ .RAMCTL_RAM = 0b00001000
+ .RAMCTL_RO = 0b00010000
+ .RAMCTL_PROT = 0b10000000
+
+ .GLASSES_3D = 0xfff8
+
+ .MAP_FRAME0 = 0xfffd
+ .MAP_FRAME1 = 0xfffe
+ .MAP_FRAME2 = 0xffff
+
+ .BIOS = 0xC000
+
+ .SYSTEM_PAL = 0x00
+ .SYSTEM_NTSC = 0x01
+
+ .CPU_CLOCK = 3579545
+
+ ;; GBDK library screen modes
+
+ .T_MODE = 0x02 ; Text mode (bit 2)
+ .T_MODE_OUT = 0x02 ; Text mode output only
+ .T_MODE_INOUT = 0x03 ; Text mode with input
+ .M_NO_SCROLL = 0x04 ; Disables scrolling of the screen in text mode
+ .M_NO_INTERP = 0x08 ; Disables special character interpretation
+
+ ;; Screen dimentions in tiles
+
+ .SCREEN_X_OFS = 6
+ .SCREEN_Y_OFS = 3
+ .SCREEN_WIDTH = 20
+ .SCREEN_HEIGHT = 18
+ .VDP_MAP_HEIGHT = 28
+ .VDP_MAP_WIDTH = 32
+
+ ;; Interrupt flags
+
+ .VBL_IFLAG = 0x01
+ .LCD_IFLAG = 0x02
+
+ ; characters
+ .CR = 0x0A
+ .SPACE = 0x00
+
+ ;; Global variables
+ .globl .mode
+
+ ;; Interrupt routines
+ .globl _INT_ISR
+ .globl _NMI_ISR
+
+ ;; Symbols defined at link time
+ .globl .STACK
+ .globl _shadow_OAM
+ .globl __shadow_OAM_OFF
+
+ ;; Main user routine
+ .globl _main
+
+ ;; Macro definitions
+
+.macro VDP_WRITE_DATA regH regL ?lbl
+ ld a, i
+ ld a, regL
+ di
+ out (#.VDP_DATA), a ; 11
+ ld a, regH ; 4
+ jp po, lbl ; 7/12
+ ei ; 4 (total: 26/27)
+lbl:
+ out (#.VDP_DATA), a
+.endm
+
+.macro VDP_WRITE_CMD regH regL ?lbl
+ ld a, i
+ ld a, regL
+ di
+ out (#.VDP_CMD), a
+ ld a, regH
+ jp po, lbl
+ ei
+lbl:
+ out (#.VDP_CMD), a
+.endm
+
+.macro VDP_DELAY ?lbl
+ nop
+ jr lbl
+lbl:
+.endm
+
+.macro VDP_CANCEL_INT
+ in a, (.VDP_STAT) ; cancel pending VDP interrupts
+.endm
+
+.macro WRITE_VDP_CMD_HL
+ rst 0x10
+.endm
+
+.macro WRITE_VDP_DATA_HL
+ rst 0x20
+.endm
+
+.macro CALL_HL
+ rst 0x30
+.endm
+
+.macro DISABLE_VBLANK_COPY
+ ld a, #1
+ ld (__shadow_OAM_OFF), a
+.endm
+
+.macro ENABLE_VBLANK_COPY
+ xor a
+ ld (__shadow_OAM_OFF), a
+.endm
+
+.macro ADD_A_REG16 regH regL
+ add regL
+ ld regL, a
+ adc regH
+ sub regL
+ ld regH, a
+.endm
+
+.macro MUL_DE_BY_A_RET_HL ?lbl1 ?lbl2
+ ; Multiply DE by A, return result in HL; preserves: BC
+ ld hl, #0
+lbl1:
+ srl a
+ jp nc, lbl2
+ add hl, de
+lbl2:
+ sla e
+ rl d
+ or a
+ jp nz, lbl1
+.endm
+
+.macro DIV_PART divident divisor ?lbl
+ rl divident
+ rla
+ sub divisor
+ jr nc, lbl
+ add divisor
+lbl:
+.endm
+.macro FAST_DIV8 divident divisor
+ ; returns modulus in A
+ .rept 8
+ DIV_PART divident divisor
+ .endm
+ ld a, divident
+ cpl
+.endm
+.macro FAST_MOD8 divident divisor
+ ; returns modulus in A
+ .rept 8
+ DIV_PART divident divisor
+ .endm
+.endm
diff --git a/gbdk/gbdk-lib/libc/targets/z80/gg/nmi.s b/gbdk/gbdk-lib/libc/targets/z80/gg/nmi.s
new file mode 100644
index 00000000..d61b5ded
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/gg/nmi.s
@@ -0,0 +1,8 @@
+ .include "global.s"
+
+ .title "NMI Handler"
+ .module NMIHandler
+ .area _HOME
+
+_NMI_ISR::
+ retn \ No newline at end of file
diff --git a/gbdk/gbdk-lib/libc/targets/z80/gg/pad.s b/gbdk/gbdk-lib/libc/targets/z80/gg/pad.s
new file mode 100644
index 00000000..cb95ad47
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/gg/pad.s
@@ -0,0 +1,43 @@
+ .include "global.s"
+
+ .title "JOYPad utilities"
+ .module JOYPad
+ .area _HOME
+
+ ;; Get Keypad Button Status
+_joypad::
+.jpad::
+ in a, (.JOY_PORT1)
+ cpl
+ and #0b00111111
+ ld l, a
+ in a, (.GG_STATE)
+ cpl
+ and #.GGSTATE_STT
+ or l
+ ld l, a
+ ret
+
+ ;; Wait until all buttons have been released
+.padup::
+_waitpadup::
+1$:
+ ld h,#0x7f ; wait for .jpad return zero 127 times in a row
+2$:
+ call .jpad
+ or a ; have all buttons been released?
+ jr nz,1$ ; not yet
+
+ dec h
+ jr nz,2$
+
+ ret
+
+ ;; Wait for the key to be pressed
+_waitpad::
+.wait_pad::
+1$:
+ call .jpad ; read pad
+ and l ; compare with mask?
+ jr z,1$ ; loop if no intersection
+ ret
diff --git a/gbdk/gbdk-lib/libc/targets/z80/gg/pad_ex.s b/gbdk/gbdk-lib/libc/targets/z80/gg/pad_ex.s
new file mode 100644
index 00000000..87004dfb
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/gg/pad_ex.s
@@ -0,0 +1,76 @@
+ .include "global.s"
+
+ .title "JOYPad utilities"
+ .module JOYPad
+ .area _HOME
+
+; uint8_t joypad_init(uint8_t npads, joypads_t * joypads) __z88dk_callee;
+_joypad_init::
+ ld hl, #2
+ add hl, sp
+ ld a, (hl)
+ or a
+ jr nz, 1$
+ ld a, #1
+ jr 2$
+1$:
+ cp #(.JOYPAD_COUNT + 1)
+ jr c, 2$
+ ld a, #.JOYPAD_COUNT
+2$:
+ inc hl
+ ld e, (hl)
+ inc hl
+ ld d, (hl)
+
+ inc hl
+ pop bc ; pop return address
+ ld sp, hl ; dispose params
+ push bc ; push return address back
+
+ ld (de), a ; number of joypads
+ ld l, a ; return number of joypads in l
+ xor a
+ inc de
+ ld (de), a
+ inc de
+ ld (de), a
+ inc de
+ ld (de), a
+ inc de
+ ld (de), a
+
+ ret
+
+;void joypad_ex(joypads_t * joypads) __z88dk_fastcall;
+
+_joypad_ex::
+ in a, (.GG_STATE)
+ cpl
+ and #.GGSTATE_STT
+ ld b, a
+ ld c, #.JOY_PORT1
+ in e, (c)
+ inc c
+ in d, (c)
+ ld a, e
+ rla
+ rl d
+ rla
+ rl d
+ ld a, e
+ cpl
+ and #0b00111111
+ or b
+ ld e, a
+ ld a, d
+ cpl
+ and #0b00111111
+ ld d, a
+
+ inc hl
+ ld (hl), e
+ inc hl
+ ld (hl), d
+
+ ret \ No newline at end of file
diff --git a/gbdk/gbdk-lib/libc/targets/z80/gg/palette.s b/gbdk/gbdk-lib/libc/targets/z80/gg/palette.s
new file mode 100644
index 00000000..5e35d425
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/gg/palette.s
@@ -0,0 +1,107 @@
+ ;; SMS palette routines
+
+ .include "global.s"
+
+ .title "CRAM SMS Palettes"
+ .module CRAMUtils
+ .area _HOME
+
+; void set_palette_entry(uint8_t palette, uint8_t entry, uint16_t rgb_data) __z88dk_callee;
+_set_palette_entry::
+ pop de
+ pop bc
+ ld hl, #.VDP_CRAM
+ bit 0, c
+ jr z, 1$
+ set 4, b
+1$:
+ sla b
+ ld c, b
+ ld b, #0
+ add hl, bc
+ pop bc
+
+ ld a, i
+ di
+ ld a, l
+ out (#.VDP_CMD), a
+ ld a, h
+ out (#.VDP_CMD), a
+ ld a, c
+ out (#.VDP_DATA), a
+ jr 3$
+3$:
+ ld a, b
+ out (#.VDP_DATA), a
+ jp po, 2$
+ ei
+2$:
+ ld h, d
+ ld l, e
+ jp (hl)
+
+; void set_palette(uint8_t first_palette, uint8_t nb_palettes, uint16_t *rgb_data) __z88dk_callee;
+_set_palette::
+ pop de
+ pop bc
+ ld hl, #.VDP_CRAM
+ bit 0, c
+ ld a, b
+ ld bc, #0
+ jr z, 1$
+ ld c, #0x20
+1$:
+ add hl, bc
+
+ ld c, a
+
+ DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT
+
+ ld a, i
+ di
+ ld a, l
+ out (#.VDP_CMD), a
+ ld a, h
+ out (#.VDP_CMD), a
+ jp po, 2$
+ ei
+2$:
+ ld a, c
+ or a
+ jr z, 3$
+
+ pop hl
+ ld c, #.VDP_DATA
+5$:
+ ld b, #0x20
+4$:
+ outi
+ jr nz, 4$
+
+ dec a
+ jr nz, 5$
+3$:
+ ENABLE_VBLANK_COPY ; switch ON copy shadow SAT
+
+ ld h, d
+ ld l, e
+ jp (hl)
+
+.CRT_DEFAULT_PALETTE::
+ .dw 0b0000111111111111
+ .dw 0b0000100010001000
+ .dw 0b0000010001000100
+ .dw 0b0000000000000000
+ .dw 0b0000000000001000
+ .dw 0b0000000010000000
+ .dw 0b0000100000000000
+ .dw 0b0000000010001000
+ .dw 0b0000100010000000
+ .dw 0b0000100000001000
+ .dw 0b0000000000001111
+ .dw 0b0000000011110000
+ .dw 0b0000111100000000
+ .dw 0b0000000011111111
+ .dw 0b0000111111110000
+ .dw 0b0000111100001111
+
diff --git a/gbdk/gbdk-lib/libc/targets/z80/gotoxy.s b/gbdk/gbdk-lib/libc/targets/z80/gotoxy.s
new file mode 100644
index 00000000..a2394ad4
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/gotoxy.s
@@ -0,0 +1,34 @@
+ .include "global.s"
+
+ .title "console utilities"
+ .module ConsoleUtils
+
+ .globl .curx, .cury
+
+ .area _HOME
+
+_gotoxy::
+ pop hl
+ pop de
+ push de
+ push hl
+
+ ld a, #.SCREEN_X_OFS
+ add e
+ ld (.curx), a
+ ld a, #.SCREEN_Y_OFS
+ add d
+ ld (.cury), a
+ ret
+
+_posx::
+ ld a, (.curx)
+ sub #.SCREEN_X_OFS
+ ld l, a
+ ret
+
+_posy::
+ ld a, (.cury)
+ sub #.SCREEN_Y_OFS
+ ld l, a
+ ret \ No newline at end of file
diff --git a/gbdk/gbdk-lib/libc/targets/z80/heap.s b/gbdk/gbdk-lib/libc/targets/z80/heap.s
new file mode 100644
index 00000000..991df234
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/heap.s
@@ -0,0 +1,44 @@
+;--------------------------------------------------------------------------
+; heap.s
+;
+; Copyright (C) 2001, Michael Hope
+;
+; This library is free software; you can redistribute it and/or modify it
+; under the terms of the GNU General Public License as published by the
+; Free Software Foundation; either version 2, or (at your option) any
+; later version.
+;
+; This library is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+; GNU General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with this library; see the file COPYING. If not, write to the
+; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+; MA 02110-1301, USA.
+;
+; As a special exception, if you link this library with other files,
+; some of which are compiled with SDCC, to produce an executable,
+; this library does not by itself cause the resulting executable to
+; be covered by the GNU General Public License. This exception does
+; not however invalidate any other reasons why the executable file
+; might be covered by the GNU General Public License.
+;--------------------------------------------------------------------------
+
+; Just stubs - not copyrightable
+
+ ;; Stubs that hook the heap in
+ .globl ___sdcc_heap_init
+
+ .area _GSINIT
+ call ___sdcc_heap_init
+
+ .area _HEAP
+___sdcc_heap::
+ ;; For now just allocate 2k of heap.
+ .ds 2047
+
+ .area _HEAP_END
+___sdcc_heap_end::
+ .ds 1
diff --git a/gbdk/gbdk-lib/libc/targets/z80/memset_small.s b/gbdk/gbdk-lib/libc/targets/z80/memset_small.s
new file mode 100644
index 00000000..a2fa3e13
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/memset_small.s
@@ -0,0 +1,14 @@
+ .include "global.s"
+
+ .title "memset small"
+ .module MemSetSmall
+
+ .area _HOME
+
+.memset_small::
+1$:
+ ld (hl), a
+ inc hl
+ dec c
+ jp nz, 1$
+ ret
diff --git a/gbdk/gbdk-lib/libc/targets/z80/mode.s b/gbdk/gbdk-lib/libc/targets/z80/mode.s
new file mode 100644
index 00000000..17e3b2e1
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/mode.s
@@ -0,0 +1,22 @@
+ .include "global.s"
+
+ .title "screen modes"
+ .module Modes
+
+ .area _HOME
+
+_mode::
+ pop de
+ pop hl
+ push hl
+ push de
+
+.set_mode::
+ ld a, l
+ ld (.mode), a
+ ret
+
+_get_mode::
+ ld hl, #.mode
+ ld l, (hl)
+ ret \ No newline at end of file
diff --git a/gbdk/gbdk-lib/libc/targets/z80/msxdos/Makefile b/gbdk/gbdk-lib/libc/targets/z80/msxdos/Makefile
new file mode 100644
index 00000000..77c4a0dd
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/msxdos/Makefile
@@ -0,0 +1,36 @@
+# GB specific Makefile
+
+TOPDIR = ../../../..
+
+THIS = msxdos
+PORT = z80
+
+CSRC = crlf.c
+
+ASSRC = set_interrupts.s \
+ outi.s \
+ bdos_putchar.s bdos_getchar.s bdos_gets.s \
+ msx_refresh_oam.s \
+ msx_write_vdp.s \
+ msx_set_native_data.s msx_set_1bpp_data.s msx_set_1bpp_sprite_data.s \
+ msx_set_tile_map.s msx_set_tile_map_xy.s \
+ msx_fill_rect.s msx_fill_rect_xy.s \
+ msx_metasprites.s msx_metasprites_hide.s msx_metasprites_hide_spr.s \
+ pad.s \
+ msx_int.s \
+ mode.s clock.s \
+ delay.s \
+ memset_small.s \
+ far_ptr.s \
+ color.s \
+ heap.s \
+ __sdcc_bcall.s __sdcc_bcall_abc.s \
+ crt0.s
+
+CRT0 = crt0.s
+
+include $(TOPDIR)/Makefile.common
+
+AS = $(AS_Z80)
+
+include ../../../Makefile.platform
diff --git a/gbdk/gbdk-lib/libc/targets/z80/msxdos/__sdcc_bcall.s b/gbdk/gbdk-lib/libc/targets/z80/msxdos/__sdcc_bcall.s
new file mode 100644
index 00000000..0d39036b
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/msxdos/__sdcc_bcall.s
@@ -0,0 +1,41 @@
+ .include "global.s"
+
+ .area _CODE
+
+ .globl ___sdcc_bcall_ehl
+;
+; default trampoline to call banked functions
+; Usage:
+; ld e, #<function_bank>
+; ld hl, #<function>
+; call ___sdcc_bcall_ehl
+;
+___sdcc_bcall_ehl::
+ push hl
+ ld h, #>__banks_remap_table
+ ld l, e ; e == new bank
+
+ ld a, (__current_bank)
+ ld l, (hl) ; l == segment
+ ld h, a ; h == old bank
+
+ ld a, e
+ ld (__current_bank), a ; new bank to __current_bank
+
+ ld a, l ; set segment
+ call .mapper_page_set
+ ex (sp), hl ; old bank is left on stack
+ inc sp
+
+ CALL_HL
+ dec sp
+
+ ex (sp), hl
+ ld a, h
+ ld (__current_bank), a
+ ld h, #>__banks_remap_table
+ ld l, a
+ ld a, (hl)
+ call .mapper_page_set
+ pop hl
+ ret
diff --git a/gbdk/gbdk-lib/libc/targets/z80/msxdos/__sdcc_bcall_abc.s b/gbdk/gbdk-lib/libc/targets/z80/msxdos/__sdcc_bcall_abc.s
new file mode 100644
index 00000000..217fac7f
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/msxdos/__sdcc_bcall_abc.s
@@ -0,0 +1,59 @@
+ .include "global.s"
+
+ .area _CODE
+
+ .globl ___sdcc_bcall
+ .globl ___sdcc_bcall_abc
+
+;
+; trampoline to call banked functions
+; used when legacy banking is enabled only
+; Usage:
+; call ___sdcc_bcall
+; .dw <function>
+; .dw <function_bank>
+;
+___sdcc_bcall::
+ ex (sp), hl
+ ld c, (hl)
+ inc hl
+ ld b, (hl)
+ inc hl
+ ld a, (hl)
+ inc hl
+ inc hl
+ ex (sp), hl
+;
+; trampoline to call banked functions with __z88dk_fastcall calling convention
+; Usage:
+; ld a, #<function_bank>
+; ld bc, #<function>
+; call ___sdcc_bcall_abc
+;
+___sdcc_bcall_abc::
+ push hl
+ ld l, a
+ ld a, (__current_bank)
+ ld h, #>__banks_remap_table
+ ld l, (hl)
+ ld h, a
+ call .mapper_page_set
+ ex (sp), hl
+
+ inc sp
+ call ___sdcc_bjump_abc
+ dec sp
+
+ ex (sp), hl
+ ld a, h
+ ld (__current_bank), a
+ ld h, #>__banks_remap_table
+ ld l, a
+ ld a, (hl)
+ call .mapper_page_set
+ pop hl
+ ret
+;
+___sdcc_bjump_abc:
+ push bc
+ ret
diff --git a/gbdk/gbdk-lib/libc/targets/z80/msxdos/bdos_getchar.s b/gbdk/gbdk-lib/libc/targets/z80/msxdos/bdos_getchar.s
new file mode 100644
index 00000000..d99cf4ba
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/msxdos/bdos_getchar.s
@@ -0,0 +1,10 @@
+ .include "global.s"
+
+ .title "getchar"
+ .module getchar
+
+ .area _CODE
+
+_getchar::
+ JP_BDOS #_INNOE
+ \ No newline at end of file
diff --git a/gbdk/gbdk-lib/libc/targets/z80/msxdos/bdos_gets.s b/gbdk/gbdk-lib/libc/targets/z80/msxdos/bdos_gets.s
new file mode 100644
index 00000000..acc3801a
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/msxdos/bdos_gets.s
@@ -0,0 +1,34 @@
+ .include "global.s"
+
+ .title "gets"
+ .module gets
+
+ .area _CODE
+
+_gets::
+ pop hl
+ pop de
+ push de
+ push hl
+ push de
+ ld c, #63 ; limit input to 64 bytes including trailing zero
+ ; that match with internal buffer in scanf()
+1$:
+ push bc
+ push de
+ CALL_BDOS #_CONIN
+ pop de
+ pop bc
+ cp #0x0d ; CR
+ jp z, 2$
+ cp #0x05 ; EOF
+ jp z, 2$
+ ld (de), a
+ inc de
+ dec c
+ jp nz, 1$
+2$:
+ xor a
+ ld (de), a
+ pop hl
+ ret \ No newline at end of file
diff --git a/gbdk/gbdk-lib/libc/targets/z80/msxdos/bdos_putchar.s b/gbdk/gbdk-lib/libc/targets/z80/msxdos/bdos_putchar.s
new file mode 100644
index 00000000..79dfa70a
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/msxdos/bdos_putchar.s
@@ -0,0 +1,15 @@
+ .include "global.s"
+
+ .title "putchar"
+ .module putchar
+
+ .area _CODE
+
+_setchar::
+_putchar::
+ pop hl
+ pop de
+ push de ; char in E
+ push hl
+ JP_BDOS #_CONOUT
+ \ No newline at end of file
diff --git a/gbdk/gbdk-lib/libc/targets/z80/msxdos/crlf.c b/gbdk/gbdk-lib/libc/targets/z80/msxdos/crlf.c
new file mode 100644
index 00000000..c10d2cb4
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/msxdos/crlf.c
@@ -0,0 +1 @@
+const char * const __crlf = "\r\n"; \ No newline at end of file
diff --git a/gbdk/gbdk-lib/libc/targets/z80/msxdos/crt0.s b/gbdk/gbdk-lib/libc/targets/z80/msxdos/crt0.s
new file mode 100644
index 00000000..0b1a2e4d
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/msxdos/crt0.s
@@ -0,0 +1,522 @@
+ .include "global.s"
+
+ .title "Runtime"
+ .module Runtime
+
+ .ez80
+
+ ;; Ordering of segments for the linker.
+ .area _CODE
+ .area _CODE_0
+ .area _HOME
+ .area _BASE
+ .area _LIT
+ .area _GSINIT
+ .area _GSFINAL
+ .area _INITIALIZER
+
+ .area _DATA
+ .area _INITIALIZED
+ .area _BSEG
+ .area _BSS
+ .area _HEAP
+ .area _HEAP_END
+
+ ; program startup code
+ .area _CODE
+.start::
+ ei
+ call .save_int_vector
+ call .gsinit
+
+ ld a, (___overlay_count)
+ and a
+ call nz, .load_overlays
+ jp c, .exit_error
+
+ call .setup_video_mode
+
+ ld hl, #.LS_FILE_BUFFER
+ xor a
+ ld b, a
+ ld c, (hl)
+ or c
+ jr z, 1$
+
+ add hl, bc
+ inc hl
+ xor a
+ ld (hl), a
+ ld c, a ; param counter
+
+ ld hl, #(.LS_FILE_BUFFER + 1)
+3$:
+ ld a, (hl)
+ or a
+ jr z, 6$
+ cp #0x20
+ jr nz, 6$
+ inc hl
+ jr 3$
+6$:
+ jr z, 2$
+
+ inc c
+ push hl
+4$:
+ inc hl
+ ld a, (hl)
+ or a
+ jr z, 2$
+ cp #0x20
+ jr nz, 4$
+5$:
+ ld (hl), #0
+ inc hl
+ jr 3$
+2$:
+ ld hl, #0
+ add hl, sp
+ push hl ; push pointer to argv array on stack
+1$:
+ ld b, #0
+ push bc ; push argc
+ ; reverse argv order
+ ld e, c
+ srl e
+ jr z, 7$ ; only 1 parameter
+
+ dec c
+ ld ixh, b
+ ld ixl, c
+ add ix, ix
+ ld b, h
+ ld c, l
+ add ix, bc
+8$:
+ ld d, (hl)
+ ld a, 0 (ix)
+ ld 0 (ix), d
+ ld (hl), a
+ inc hl
+ ld d, (hl)
+ ld a, 1 (ix)
+ ld 1 (ix), d
+ ld (hl), a
+ inc hl
+ dec ix
+ dec ix
+ dec e
+ jr nz, 8$
+7$:
+ call _main
+.exit:
+ push hl
+ ld l, #0
+ call _SWITCH_ROM
+ call .restore_int_vector
+ pop hl
+ ld b, l
+ CALL_BDOS #_TERM ; try terminate usind MSX DOS 2 function
+ JP_BDOS #_TERM0
+_exit::
+ pop hl
+ pop hl
+ jr .exit
+
+.exit_error:
+ ld hl, #1$
+ push hl
+ call _puts
+ JP_BDOS #_TERM0
+1$:
+ .asciz "LOAD ERROR!\r\n"
+
+ ;; fills memory at HL of length BC with A, clobbers DE
+.memset_simple::
+ ld e, a
+ ld a, c
+ or b
+ ret z
+ ld (hl), e
+ dec bc
+ ld d, h
+ ld e, l
+ inc de
+
+ ;; copies BC bytes from HL into DE
+.memcpy_simple::
+ ld a, c
+ or b
+ ret z
+ ldir
+ ret
+
+ ;; put some internal data here, to save bytes wasted for the alignment of __banks_remap_table
+
+___overlay_count::
+ .db 0
+.overlay_fcb:
+ .db 0 ; drive
+___overlay_name::
+ .ascii "OVERLAYS" ; filename
+.overlay_fcb_ext::
+ .ascii "000" ; extension
+.overlay_fcb_extent:
+ .db 0 ; extent
+ .db 0 ; attributes
+.overlay_fcb_record_size:
+ .db 0 ; extent ; msx-dos1: record size low byte
+.overlay_fbc_record_cont:
+ .db 0 ; record count ; msx-dos1: record size high byte
+.overlay_fcb_file_size:
+ .db 0, 0, 0, 0 ; file size
+ .db 0, 0, 0, 0 ; volume id
+ .ds 8 ; internal
+.overlay_fcb_position:
+ .db 0 ; current record within extent
+.overlay_fcb_random_pos:
+ .db 0, 0, 0, 0 ; Random record number
+.overlay_fcb_end:
+
+__memman_present::
+ .db 0
+__rammapper_table::
+ .dw 0
+
+.rammapper_hiwater:
+ .db 4 ; 7 segments for 128K config
+.rammapper_alloc_hiwater:
+ .db 1 ; allocation starts from bank 1
+
+.mapper_page_alloc::
+ ld hl, #.rammapper_hiwater
+ ld a, (hl)
+ inc (hl)
+ or a ; never fail
+ ret
+
+_SWITCH_ROM:: ; Z88DK_FASTCALL : uint8_t parameter in l
+ ld a, l
+ ld (__current_bank), a
+ ld h, #>__banks_remap_table
+ ld l, a
+ ld a, (hl)
+.mapper_page_set::
+ out (.MAP_FRAME1), a
+ ret
+
+.mapper_page_get::
+ in a, (.MAP_FRAME1)
+__mapper_page_mask = .+1
+.globl __mapper_page_mask
+ and #0x00 ; zero ram size, will be patched
+ ret
+
+__current_bank::
+ .db 0
+
+; --- 256 byte boundary ---------------------------------------
+
+ .bndry 0x100
+__banks_remap_table::
+ .ds 100
+l__banks_remap_table = .-__banks_remap_table
+
+__mapper_bank_alloc::
+ ld hl, #.rammapper_alloc_hiwater
+ ld a, (hl)
+ inc (hl)
+ ld h, #>__banks_remap_table
+ ld l, a
+ ld a, #0xff
+ cp (hl)
+ jr nz, 1$
+
+ xor a
+ ld b, a
+ push hl
+ call .mapper_page_alloc
+ pop hl
+ ret c ; return if no memory
+ ld (hl), a ; set segment number for the bank number
+1$:
+ or a
+ ret ; allocated bank returns in l
+
+.macro TRANSFER_POINTER ofs dest
+ ld hl, #dest
+ ld (hl), #0xc3
+ inc hl
+ ld a, ofs (ix)
+ ld (hl), a
+ inc hl
+ ld a, ofs+1 (ix)
+ ld (hl), a
+.endm
+
+.initialize_ram_mapper::
+ ; detect mapper capacity
+ in a, (.MAP_FRAME1)
+ ld e, a
+ xor a
+ out (.MAP_FRAME1), a
+ in a, (.MAP_FRAME1)
+ cpl
+ ld (__mapper_page_mask), a
+ and e
+ ld hl, #__banks_remap_table
+ ld (hl), a
+ inc hl
+ ld (hl), a ; bank 0 == bank 1
+
+ xor a
+ ld de,#0401 ; get routines info table
+ call .EXTBIO
+ ld (__rammapper_table), hl
+
+ xor a
+ ld de, #0x0402 ; populate ram mapper routines table
+ call .EXTBIO
+ or a
+ jr nz, 1$
+ scf
+ ret
+1$:
+ push hl
+ pop ix
+
+ TRANSFER_POINTER 0x01, .mapper_page_alloc
+ TRANSFER_POINTER 0x1f, .mapper_page_set
+ TRANSFER_POINTER 0x22, .mapper_page_get
+
+ ld a, #1
+ ld (__memman_present), a
+
+ or a ; return ok
+ ret
+
+ ;; Wait for VBL interrupt to be finished
+.wait_vbl_done::
+_wait_vbl_done::
+ ld a, (_shadow_VDP_R1)
+ and #.R1_DISP_ON
+ ret z
+
+ xor a
+ ld (.vbl_done), a
+1$:
+ halt
+ ld a, (.vbl_done)
+ or a
+ jr z, 1$
+ ret
+
+; --- 256 byte boundary ---------------------------------------
+
+ .bndry 256
+_shadow_OAM::
+ .ds 0x80
+
+ ;; load overlays, count in A
+.load_overlays:
+ ld b, a
+ ld a, (__memman_present)
+ or a
+ jr nz, 3$
+ ld a, (__mapper_page_mask)
+ sub #3 ; ram segments used for DOS
+ inc a
+ cp b
+ ret c ; not sufficient ram to load overlays
+3$:
+ ld c, #1
+1$:
+ push bc
+ call .load_overlay
+ pop bc
+ ret c ; error loading overlay
+
+ ld a, c
+ cp b
+ jr z, 2$ ; all loaded - return
+
+ inc c ; next overlay
+ ld a, #(l__banks_remap_table - 1)
+ cp c
+ ret c ; more than 99 overlays are not allowed
+
+ jr 1$
+2$:
+ xor a
+ call _SWITCH_ROM
+ ret
+
+.load_overlay:
+ push bc
+ call __mapper_bank_alloc
+ pop bc
+ ret c ; no free segments
+
+ call _SWITCH_ROM ; switch bank to l
+
+ ld b, #8
+ xor a
+1$:
+ rlc c
+ adc a
+ daa
+ djnz 1$
+ ; result in a, max 99 overlays
+ ld c, a
+ ld b, #0x0f
+ ld e, #'0'
+ ld hl, #(.overlay_fcb_ext + 1)
+ rra
+ rra
+ rra
+ rra
+ and b
+ add e
+ ld (hl), a
+ inc hl
+ ld a, c
+ and b
+ add e
+ ld (hl), a
+
+ xor a
+ ld bc, #(.overlay_fcb_end - .overlay_fcb_extent)
+ ld hl, #.overlay_fcb_extent
+ call .memset_simple ; initialize fcb
+
+ ld de, #.overlay_fcb
+ CALL_BDOS #_FOPEN
+ rrca
+ ret c ; file not found
+
+ ld de, #0x4000
+3$:
+ CALL_BDOS #_SETDTA
+
+ push de
+ ld de, #.overlay_fcb
+ CALL_BDOS #_RDSEQ
+ pop de
+
+ rrca
+ jr c, 2$ ; EOF reached
+
+ ld a, #128
+ ADD_A_REG16 d, e
+
+ ld a, #0xc0
+ cp d
+ jr z, 2$ ; end of page1 reached
+
+ jr 3$
+2$:
+ ld de, #.overlay_fcb
+ CALL_BDOS #_FCLOSE
+
+ or a ; return ok
+ ret
+
+.restore_int_vector:
+ ld hl, #__old_int_vector
+ ld de, #.LS_INT_VECTOR
+ jr .restore_ldir
+.save_int_vector:
+ ld hl, #.LS_INT_VECTOR
+ ld de, #__old_int_vector
+.restore_ldir:
+ ld bc, #0x0005
+ ld a, i
+ push af
+ di
+ ldir
+ pop af
+ jp po, 1$
+ ei
+1$:
+ ret
+
+.setup_video_mode:
+ ld a, i
+ push af
+ di
+ ;; Initialize VDP
+ ld c, #.VDP_CMD
+ ld b, #(.shadow_VDP_end - .shadow_VDP)
+ ld hl,#(.shadow_VDP_end - 1)
+1$:
+ outd
+ jr 3$ ; delay
+3$:
+ ld a, b
+ or #.VDP_REG_MASK
+ out (c), a
+
+ ld a, b
+ or a
+ jr nz, 1$
+
+ pop af
+ jp po, 2$
+ ei
+2$:
+ ret
+
+.shadow_VDP:
+_shadow_VDP_R0::
+ .db #(.R0_DEFAULT | .R0_SCR_MODE2)
+_shadow_VDP_R1::
+ .db #(.R1_DEFAULT | .R1_DISP_ON | .R1_IE | .R1_SCR_MODE2 | .R1_SPR_8X8)
+_shadow_VDP_R2::
+ .db .R2_MAP_0x1C00
+_shadow_VDP_R3::
+ .db 0xFF ; tiledata attr from 0x2000
+_shadow_VDP_R4::
+ .db 0x03 ; tiledata from 0x0000
+_shadow_VDP_R5::
+ .db .R5_SAT_0x1B00
+_shadow_VDP_R6::
+ .db 0x07
+_shadow_VDP_R7::
+_shadow_VDP_RBORDER::
+ .db 0x01
+.shadow_VDP_end::
+
+.sys_time::
+_sys_time::
+ .dw 0x0000
+.vbl_done::
+ .db 0
+__shadow_OAM_base::
+ .db #>_shadow_OAM
+__shadow_OAM_OFF::
+ .db 0
+.mode::
+ .ds .T_MODE_INOUT ; Current mode
+__old_int_vector::
+ .ds 5
+
+ .area _GSINIT
+.gsinit::
+ ;; initialize static storage
+ xor a
+ ld bc, #l__DATA
+ ld hl, #s__DATA
+ call .memset_simple ; initialize variables in RAM with zero
+
+ ;; initialize static storage variables
+ ld bc, #l__INITIALIZER
+ ld hl, #s__INITIALIZER
+ ld de, #s__INITIALIZED
+ call .memcpy_simple
+
+ ;; initialize ram mapper
+ call .initialize_ram_mapper
+
+ .area _GSFINAL
+ ret
diff --git a/gbdk/gbdk-lib/libc/targets/z80/msxdos/global.s b/gbdk/gbdk-lib/libc/targets/z80/msxdos/global.s
new file mode 100644
index 00000000..e20449aa
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/msxdos/global.s
@@ -0,0 +1,483 @@
+ .OS_RESET = 0x0000
+ .LS_IO = 0x0003
+ .LS_DSK = 0x0004
+ .LS_INT_VECTOR = 0x0038
+ .LS_FCB0 = 0x005C
+ .LS_FCB1 = 0x006C
+ .LS_FILE_BUFFER = 0x0080
+ .BDOS = 0x0005
+
+ .EXTBIO = 0xFFCA
+
+ ; MSX-DOS 1
+ _TERM0 = 0x00 ; Program terminate
+ _CONIN = 0x01 ; Console input
+ _CONOUT = 0x02 ; Console output
+ _AUXIN = 0x03 ; Auxiliary input
+ _AUXOUT = 0x04 ; Auxiliary output
+ _LSTOUT = 0x05 ; Printer output
+ _DIRIO = 0x06 ; Direct console I/O
+ _DIRIN = 0x07 ; Direct console input
+ _INNOE = 0x08 ; Console input without echo
+ _STROUT = 0x09 ; String output
+ _BUFIN = 0x0A ; Buffered line input
+ _CONST = 0x0B ; Console status
+ _CPMVER = 0x0C ; Return version number
+ _DSKRST = 0x0D ; Disk reset
+ _SELDSK = 0x0E ; Select disk
+ _FOPEN = 0x0F ; Open file (FCB)
+ _FCLOSE = 0x10 ; Close file (FCB)
+ _SFIRST = 0x11 ; Search for first entry (FCB)
+ _SNEXT = 0x12 ; Search for next entry (FCB)
+ _FDEL = 0x13 ; Delete file (FCB)
+ _RDSEQ = 0x14 ; Sequential read (FCB)
+ _WRSEQ = 0x15 ; Sequential write (FCB)
+ _FMAKE = 0x16 ; Create file (FCB)
+ _FREN = 0x17 ; Rename file (FCB)
+ _LOGIN = 0x18 ; Get login vector
+ _CURDRV = 0x19 ; Get current drive
+ _SETDTA = 0x1A ; Set disk transfer address
+ _ALLOC = 0x1B ; Get allocation information
+ _RDRND = 0x21 ; Random read (FCB)
+ _WRRND = 0x22 ; Random write (FCB)
+ _FSIZE = 0x23 ; Get file size (FCB)
+ _SETRND = 0x24 ; Set random record (FCB)
+ _WRBLK = 0x26 ; Random block write (FCB)
+ _RDBLK = 0x27 ; Random block read (FCB)
+ _WRZER = 0x28 ; Random write with zero fill (FCB)
+ _GDATE = 0x2A ; Get date
+ _SDATE = 0x2B ; Set date
+ _GTIME = 0x2C ; Get time
+ _STIME = 0x2D ; Set time
+ _VERIFY = 0x2E ; Set/reset verify flag
+ _RDABS = 0x2F ; Absolute sector read
+ _WRABS = 0x30 ; Absolute sector write
+
+ ; MSX-DOS2
+ _DPARM = 0x31 ; Get disk parameters
+ _FFIRST = 0x40 ; Find first entry
+ _FNEXT = 0x41 ; Find next entry
+ _FNEW = 0x42 ; Find new entry
+ _OPEN = 0x43 ; Open file handle
+ _CREATE = 0x44 ; Create file handle
+ _CLOSE = 0x45 ; Close file handle
+ _ENSURE = 0x46 ; Ensure file handle
+ _DUP = 0x47 ; Duplicate file handle
+ _READ = 0x48 ; Read from file handle
+ _WRITE = 0x49 ; Write to file handle
+ _SEEK = 0x4A ; Move file handle pointer
+ _IOCTL = 0x4B ; I/O control for devices
+ _HTEST = 0x4C ; Test file handle
+ _DELETE = 0x4D ; Delete file or subdirectory
+ _RENAME = 0x4E ; Rename file or subdirectory
+ _MOVE = 0x4F ; Move file or subdirectory
+ _ATTR = 0x50 ; Get/set file attributes
+ _FTIME = 0x51 ; Get/set file date and time
+ _HDELETE = 0x52 ; Delete file handle
+ _HRENAME = 0x53 ; Rename file handle
+ _HMOVE = 0x54 ; Move file handle
+ _HATTR = 0x55 ; Get/set file handle attributes
+ _HFTIME = 0x56 ; Get/set file handle date and time
+ _GETDTA = 0x57 ; Get disk transfer address
+ _GETVFY = 0x58 ; Get verify flag setting
+ _GETCD = 0x59 ; Get current directory
+ _CHDIR = 0x5A ; Change current directory
+ _PARSE = 0x5B ; Parse pathname
+ _PFILE = 0x5C ; Parse filename
+ _CHKCHR = 0x5D ; Check character
+ _WPATH = 0x5E ; Get whole path string
+ _FLUSH = 0x5F ; Flush disk buffers
+ _FORK = 0x60 ; Fork a child process
+ _JOIN = 0x61 ; Rejoin parent process
+ _TERM = 0x62 ; Terminate with error code
+ _DEFAB = 0x63 ; Define abort exit routine
+ _DEFER = 0x64 ; Define disk error handler routine
+ _ERROR = 0x65 ; Get previous error code
+ _EXPLAIN = 0x66 ; Explain error code
+ _FORMAT = 0x67 ; Format a disk
+ _RAMD = 0x68 ; Create or destroy RAM disk
+ _BUFFER = 0x69 ; Allocate sector buffers
+ _ASSIGN = 0x6A ; Logical drive assignment
+ _GENV = 0x6B ; Get environment item
+ _SENV = 0x6C ; Set environment item
+ _FENV = 0x6D ; Find environment item
+ _DSKCHK = 0x6E ; Get/set disk check status
+ _DOSVER = 0x6F ; Get MSX-DOS version number
+ _REDIR = 0x70 ; Get/set redirection status
+
+ ; MSX_DOS ERROR CODES
+ .NCOMP = 0xFF ; Incompatible disk
+ .WRERR = 0xFE ; Write error
+ .DISK = 0xFD ; Disk error
+ .NRDY = 0xFC ; Not ready
+ .VERFY = 0xFB ; Verify error
+ .DATA = 0xFA ; Data error
+ .RNF = 0xF9 ; Sector not found
+ .WPROT = 0xF8 ; Write protected disk
+ .UFORM = 0xF7 ; Unformatted disk
+ .NDOS = 0xF6 ; Not a DOS disk
+ .WDISK = 0xF5 ; Wrong disk
+ .WFILE = 0xF4 ; Wrong disk for file
+ .SEEK = 0xF3 ; Seek error
+ .IFAT = 0xF2 ; Bad file allocation table
+ .NOUPB = 0xF1 ; --
+ .IFORM = 0xF0 ; Cannot format this drive
+ .INTER = 0xDF ; Internal error
+ .NORAM = 0xDE ; Not enough memory
+ .IBDOS = 0xDC ; Invalid MSX-DOS call
+ .IDRV = 0xDB ; Invalid drive
+ .IFNM = 0xDA ; Invalid filename
+ .IPATH = 0xD9 ; Invalid pathname
+ .PLONG = 0xD8 ; Pathname too long
+ .NOFIL = 0xD7 ; File not found
+ .NODIR = 0xD6 ; Directory not found
+ .DRFUL = 0xD5 ; Root directory full
+ .DKFUL = 0xD4 ; Disk full
+ .DUPF = 0xD3 ; Duplicate filename
+ .DIRE = 0xD2 ; Invalid directory move
+ .FILRO = 0xD1 ; Read only file
+ .DIRNE = 0xD0 ; Directory not empty
+ .IATTR = 0xCF ; Invalid attributes
+ .DOT = 0xCE ; Invalid . or .. operation
+ .SYSX = 0xCD ; System file exists
+ .DIRX = 0xCC ; Directory exists
+ .FILEX = 0xCB ; File exists
+ .FOPEN = 0xCA ; File already in use
+ .OV64K = 0xC9 ; Cannot transfer above 64K
+ .FILE = 0xC8 ; File allocation error
+ .EOF = 0xC7 ; End of file
+ .ACCV = 0xC6 ; File access violation
+ .IPROC = 0xC5 ; Invalid process id
+ .NHAND = 0xC4 ; No spare file handles
+ .IHAND = 0xC3 ; Invalid file handle
+ .NOPEN = 0xC2 ; File handle not open
+ .IDEV = 0xC1 ; Invalid device operation
+ .IENV = 0xC0 ; Invalid environment string
+ .ELONG = 0xBF ; Environment string too long
+ .IDATE = 0xBE ; Invalid date
+ .ITIME = 0xBD ; Invalid time
+ .RAMDX = 0xBC ; RAM disk (drive H ) already exists
+ .NRAMD = 0xBB ; RAM disk does not exist
+ .HDEAD = 0xBA ; File handle has been deleted
+ .EOL = 0xB9 ; Internal error. Should never occur
+ .ISBFN = 0xB8 ; Invalid sub-function number
+ .STOP = 0x9F ; Ctrl-STOP pressed
+ .CTRLC = 0x9E ; Ctrl-C pressed
+ .ABORT = 0x9D ; Disk operation aborted
+ .OUTERR = 0x9C ; Error on standard output
+ .INERR = 0x9B ; Error on standard input
+ .BADCOM = 0x8F ; Wrong version of COMMAND
+ .BADCM = 0x8E ; Unrecognized command
+ .BUFUL = 0x8D ; Command too long
+ .OKCMD = 0x8C ; --
+ .IPARM = 0x8B ; Invalid parameter
+ .INP = 0x8A ; Too many parameters
+ .NOPAR = 0x89 ; Missing parameter
+ .IOPT = 0x88 ; Invalid option
+ .BADNO = 0x87 ; Invalid number
+ .NOHELP = 0x86 ; File for HELP not found
+ .BADVER = 0x85 ; Wrong version of MSX-DOS
+ .NOCAT = 0x84 ; Cannot concatenate destination file
+ .BADEST = 0x83 ; Cannot create destination file
+ .COPY = 0x82 ; File cannot be copied onto itself
+ .OVDEST = 0x81 ; Cannot overwrite previous destination file
+
+ .MEMORY_CTL = 0x3E
+
+ .MEMCTL_JOYON = 0b00000000
+ .MEMCTL_JOYOFF = 0b00000100
+ .MEMCTL_BASEON = 0b00000000
+ .MEMCTL_BASEOFF = 0b00001000
+ .MEMCTL_RAMON = 0b00000000
+ .MEMCTL_RAMOFF = 0b00010000
+ .MEMCTL_CROMON = 0b00000000
+ .MEMCTL_CROMOFF = 0b00100000
+ .MEMCTL_ROMON = 0b00000000
+ .MEMCTL_ROMOFF = 0b01000000
+ .MEMCTL_EXTON = 0b00000000
+ .MEMCTL_EXTOFF = 0b10000000
+
+ .JOY_CTL = 0x3F
+
+ .JOY_P1_LATCH = 0b00000010
+ .JOY_P2_LATCH = 0b00001000
+
+ .VDP_VRAM = 0x4000
+ .VDP_TILEDATA0 = 0x4000
+ .VDP_TILEDATA1 = 0x4800
+ .VDP_TILEDATA2 = 0x5000
+ .VDP_COLORDATA0 = 0x6000
+ .VDP_COLORDATA1 = 0x6800
+ .VDP_COLORDATA1 = 0x7000
+
+ .VDP_SPRDATA0 = 0x7800
+
+ .VDP_TILEMAP = 0x5C00
+ .VDP_CRAM = 0xC000
+ .VDP_SAT = 0x5B00
+
+ .VDP_SAT_TERM = 0xD0
+
+ .VDP_VCOUNTER = 0x7E
+ .VDP_PSG = 0x7F
+ .VDP_HCOUNTER = 0x7F
+
+ .VDP_DATA = 0x98
+ .VDP_CMD = 0x99
+ .VDP_STAT = 0x99
+
+ .STATF_INT_VBL = 0b10000000
+ .STATF_9_SPR = 0b01000000
+ .STATF_SPR_COLL = 0b00100000
+
+ .VDP_REG_MASK = 0b10000000
+ .VDP_R0 = 0b10000000
+
+ .R0_DEFAULT = 0b00000000
+ .R0_CB_OUTPUT = 0b00000000
+ .R0_CB_INPUT = 0b01000000
+ .R0_IE2_OFF = 0b00000000
+ .R0_IE2 = 0b00100000
+ .R0_IE1_OFF = 0b00000000
+ .R0_IE1 = 0b00010000
+ .R0_SCR_MODE1 = 0b00000000
+ .R0_SCR_MODE2 = 0b00000010
+ .R0_ES_OFF = 0b00000000
+ .R0_ES = 0b00000001
+
+ .VDP_R1 = 0b10000001
+
+ .R1_DEFAULT = 0b10000000
+ .R1_DISP_OFF = 0b00000000
+ .R1_DISP_ON = 0b01000000
+ .R1_IE_OFF = 0b00000000
+ .R1_IE = 0b00100000
+ .R1_SCR_MODE1 = 0b00010000
+ .R1_SCR_MODE2 = 0b00000000
+ .R1_SCR_MODE3 = 0b00000000
+ .R1_SPR_8X8 = 0b00000000
+ .R1_SPR_16X16 = 0b00000010
+ .R1_SPR_MAG = 0b00000001
+ .R1_SPR_MAG_OFF = 0b00000000
+
+ .VDP_R2 = 0b10000010
+
+ .R2_MAP_0x1C00 = 0x07
+
+ .VDP_R3 = 0b10000011
+ .VDP_R4 = 0b10000100
+ .VDP_R5 = 0b10000101
+
+ .R5_SAT_0x1B00 = 0x36
+ .R5_SAT_MASK = 0b10000001
+
+ .VDP_R6 = 0b10000110
+
+ .VDP_R7 = 0b10000111
+ .VDP_RBORDER = 0b10000111
+
+ .R7_COLOR_MASK = 0b11110000
+
+ .VDP_R8 = 0b10001000
+
+ .VDP_R9 = 0b10001001
+
+ .VDP_R10 = 0b10001010
+
+ .JOYPAD_COUNT = 1
+
+ .UP = 0b00100000
+ .DOWN = 0b01000000
+ .LEFT = 0b00010000
+ .RIGHT = 0b10000000
+ .A = 0b00000001
+ .B = 0b00000100
+ .SELECT = 0b00001000
+ .START = 0b00000010
+
+ .KBD_SELECT_ROW = 0xAA
+ .KBD_INPUT = 0xA9
+
+ .JOY_PORT1 = 0xDC
+
+ .JOY_P1_UP = 0b00000001
+ .JOY_P1_DOWN = 0b00000010
+ .JOY_P1_LEFT = 0b00000100
+ .JOY_P1_RIGHT = 0b00001000
+ .JOY_P1_SW1 = 0b00010000
+ .JOY_P1_TRIGGER = 0b00010000
+ .JOY_P1_SW2 = 0b00100000
+ .JOY_P2_UP = 0b01000000
+ .JOY_P2_DOWN = 0b10000000
+
+ .JOY_PORT2 = 0xDD
+
+ .JOY_P2_LEFT = 0b00000001
+ .JOY_P2_RIGHT = 0b00000010
+ .JOY_P2_SW1 = 0b00000100
+ .JOY_P2_TRIGGER = 0b00000100
+ .JOY_P2_SW2 = 0b00001000
+ .JOY_RESET = 0b00010000
+ .JOY_P1_LIGHT = 0b01000000
+ .JOY_P2_LIGHT = 0b10000000
+
+ .FMADDRESS = 0xF0
+ .FMDATA = 0xF1
+ .AUDIOCTRL = 0xF2
+
+ .MAP_FRAME0 = 0xfffc
+ .MAP_FRAME1 = 0xfffd
+ .MAP_FRAME2 = 0xfffe
+ .MAP_FRAME3 = 0xffff
+
+ .BIOS = 0xC000
+
+ .SYSTEM_PAL = 0x00
+ .SYSTEM_NTSC = 0x01
+
+ .CPU_CLOCK = 3579545
+
+ ;; GBDK library screen modes
+
+ .T_MODE = 0x02 ; Text mode (bit 2)
+ .T_MODE_OUT = 0x02 ; Text mode output only
+ .T_MODE_INOUT = 0x03 ; Text mode with input
+ .M_NO_SCROLL = 0x04 ; Disables scrolling of the screen in text mode
+ .M_NO_INTERP = 0x08 ; Disables special character interpretation
+
+ ;; Screen dimentions in tiles
+
+ .SCREEN_X_OFS = 0
+ .SCREEN_Y_OFS = 0
+ .SCREEN_WIDTH = 32
+ .SCREEN_HEIGHT = 24
+ .VDP_MAP_HEIGHT = 24
+ .VDP_MAP_WIDTH = 32
+
+ ;; Interrupt flags
+
+ .VBL_IFLAG = 0x01
+ .LCD_IFLAG = 0x02
+
+ ; characters
+ .CR = 0x0A
+ .SPACE = 0x00
+
+ ;; Main user routine
+ .globl _main
+
+ ;; interrupt handler
+ .globl _INT_ISR
+
+ ;; Macro definitions
+
+.macro CALL_BDOS fn
+ ld c, fn
+ call .BDOS
+.endm
+
+.macro JP_BDOS fn
+ ld c, fn
+ jp .BDOS
+.endm
+
+.macro VDP_WRITE_DATA regH regL ?lbl
+ ld a, i
+ ld a, regL
+ di
+ out (#.VDP_DATA), a ; 11
+ ld a, regH ; 4
+ jp po, lbl ; 7/12
+ ei ; 4 (total: 26/27)
+lbl:
+ out (#.VDP_DATA), a
+.endm
+
+.macro VDP_WRITE_CMD regH regL ?lbl
+ ld a, i
+ ld a, regL
+ di
+ out (#.VDP_CMD), a
+ ld a, regH
+ jp po, lbl
+ ei
+lbl:
+ out (#.VDP_CMD), a
+.endm
+
+.macro VDP_DELAY ?lbl
+ nop
+ jr lbl
+lbl:
+.endm
+
+.macro VDP_CANCEL_INT
+ in a, (.VDP_STAT) ; cancel pending VDP interrupts
+.endm
+
+.macro WRITE_VDP_CMD_HL
+ MSX_WRITE_VDP_CMD h, l
+.endm
+
+.macro WRITE_VDP_DATA_HL
+ MSX_WRITE_VDP_DATA h, l
+.endm
+
+.macro CALL_HL
+ call ___sdcc_call_hl
+.endm
+
+.macro DISABLE_VBLANK_COPY
+ ld a, #1
+ ld (__shadow_OAM_OFF), a
+.endm
+
+.macro ENABLE_VBLANK_COPY
+ xor a
+ ld (__shadow_OAM_OFF), a
+.endm
+
+.macro ADD_A_REG16 regH regL
+ add regL
+ ld regL, a
+ adc regH
+ sub regL
+ ld regH, a
+.endm
+
+.macro MUL_DE_BY_A_RET_HL ?lbl1 ?lbl2
+ ; Multiply DE by A, return result in HL; preserves: BC
+ ld hl, #0
+lbl1:
+ srl a
+ jp nc, lbl2
+ add hl, de
+lbl2:
+ sla e
+ rl d
+ or a
+ jp nz, lbl1
+.endm
+
+.macro DIV_PART divident divisor ?lbl
+ rl divident
+ rla
+ sub divisor
+ jr nc, lbl
+ add divisor
+lbl:
+.endm
+.macro FAST_DIV8 divident divisor
+ ; returns modulus in A
+ .rept 8
+ DIV_PART divident divisor
+ .endm
+ ld a, divident
+ cpl
+.endm
+.macro FAST_MOD8 divident divisor
+ ; returns modulus in A
+ .rept 8
+ DIV_PART divident divisor
+ .endm
+.endm
diff --git a/gbdk/gbdk-lib/libc/targets/z80/msxdos/msx_fill_rect.s b/gbdk/gbdk-lib/libc/targets/z80/msxdos/msx_fill_rect.s
new file mode 100644
index 00000000..665498fd
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/msxdos/msx_fill_rect.s
@@ -0,0 +1,25 @@
+ .include "global.s"
+
+ .globl .fill_rect_xy
+
+ .area _HOME
+
+; void fill_rect(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint16_t tile) __z88dk_callee __preserves_regs(iyh, iyl);
+_fill_rect::
+ pop hl ; HL = ret
+ pop bc ; BC = YX
+ pop de ; DE = WH
+ ex (sp), hl ; HL = data
+ ex de, hl ; HL = WH, DE = data
+
+ xor a
+ FAST_MOD8 b #.VDP_MAP_HEIGHT
+
+ ld b, d
+ ld d, a
+
+ ld a, c
+ ld c, e
+ ld e, a ; BC = data, DE = YX
+
+ jp .fill_rect_xy
diff --git a/gbdk/gbdk-lib/libc/targets/z80/msxdos/msx_fill_rect_xy.s b/gbdk/gbdk-lib/libc/targets/z80/msxdos/msx_fill_rect_xy.s
new file mode 100644
index 00000000..3dd0d1f1
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/msxdos/msx_fill_rect_xy.s
@@ -0,0 +1,93 @@
+ .include "global.s"
+
+ .title "VRAM utilities"
+ .module VRAMUtils
+
+ .ez80
+
+ .area _HOME
+
+ ;; Set background tile table from (BC) at XY = DE of size WH = HL
+.fill_rect_xy::
+ push hl
+ ld hl, #.VDP_TILEMAP
+
+ ;; Set background tile from (BC) at YX = DE, size WH on stack, to VRAM from address (HL)
+.fill_rect_xy_tt::
+ push bc ; Store source
+
+ ld a, d
+ rrca ; rrca(3) == rlca(5)
+ rrca
+ rrca
+ ld d, a
+ and #0x07
+ add h
+ ld b, a
+ ld a, #0xE0
+ and d
+ add e
+ ld c, a ; dest BC = HL + ((0x20 * Y) + X
+
+ ld a, b
+ cp #>(.VDP_TILEMAP+0x0300)
+ jr c, 5$
+ ld b, #>.VDP_TILEMAP
+5$:
+ pop hl ; HL = source
+ pop de ; DE = HW
+ push ix ; save IX
+ push de ; store HW
+ ld ixh, b
+ ld ixl, c
+ push ix ; store dest
+
+ DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT
+
+1$: ; copy H rows
+ VDP_WRITE_CMD ixh, ixl
+ ld c, #.VDP_DATA
+2$: ; copy W tiles
+ out (c), l
+
+ ld a, ixl
+ and #0x1F
+ inc a
+ bit 5, a
+ jp z, 3$
+ and #0x1F
+ ld b, a
+ ld a, ixl
+ and #0xE0
+ or b
+ ld ixl, a
+ VDP_WRITE_CMD ixh, ixl
+ dec e
+ jp nz, 2$
+ jp 7$
+3$:
+ inc ixl
+ dec e
+ jp nz, 2$
+7$:
+ pop ix
+ pop de
+
+ dec d
+ jr z, 6$
+
+ push de
+
+ ld bc, #0x20
+ add ix, bc
+ ld a, ixh
+ cp #>(.VDP_TILEMAP+0x0300)
+ jp c, 4$
+ ld ixh, #>.VDP_TILEMAP
+4$:
+ push ix
+ jp 1$
+6$:
+ ENABLE_VBLANK_COPY ; switch ON copy shadow SAT
+ pop ix ; restore IX
+ ret \ No newline at end of file
diff --git a/gbdk/gbdk-lib/libc/targets/z80/msxdos/msx_int.s b/gbdk/gbdk-lib/libc/targets/z80/msxdos/msx_int.s
new file mode 100644
index 00000000..195867c5
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/msxdos/msx_int.s
@@ -0,0 +1,185 @@
+ .include "global.s"
+
+ .title "INT Handler"
+ .module INTHandler
+
+ .globl .sys_time, .vbl_done
+ .globl .OUTI128, __shadow_OAM_base
+
+ .area _GSINIT
+
+ ld a, i
+ ld a, #0xc3
+ di
+ ld (.LS_INT_VECTOR), a
+ ld hl, #_INT_ISR
+ jp po, 1$
+ ei
+1$:
+ ld (.LS_INT_VECTOR + 1), hl
+
+ .area _HOME
+
+_INT_ISR::
+ push af
+ push bc
+ push de
+ push hl
+ push iy
+ push ix
+
+ in a, (.VDP_STAT)
+ and #.STATF_INT_VBL
+ jp z, 2$
+ ;; handle VBlank
+
+ ld hl, (.sys_time)
+ inc hl
+ ld (.sys_time), hl
+
+ ld a, #1
+ ld (.vbl_done), a
+
+ ;; transfer shadow OAM
+ ld a, (__shadow_OAM_OFF) ; check transfer is OFF
+ or a
+ jp nz, 1$
+ ld hl, #__shadow_OAM_base
+ ld h, (hl)
+ ld l, a ; a == 0 here
+ or h
+ jp z, 1$
+
+ ld c, #.VDP_CMD
+ ld a, #<.VDP_SAT
+ out (c), a
+ ld a, #>.VDP_SAT
+ out (c), a
+ dec c ; c == .VDP_DATA
+ call .OUTI128
+1$:
+
+ ;; call user-defined VBlank handlers
+ ld hl, (.VBLANK_HANDLER0)
+ ld a, h
+ or l
+ jp z, 2$
+ CALL_HL
+
+ ld hl, (.VBLANK_HANDLER1)
+ ld a, h
+ or l
+ jp z, 2$
+ CALL_HL
+
+ ld hl, (.VBLANK_HANDLER2)
+ ld a, h
+ or l
+ jp z, 2$
+ CALL_HL
+
+2$:
+ pop ix
+ pop iy
+ pop hl
+ pop de
+ pop bc
+ pop af
+ ei
+ reti
+
+; void add_VBL(int_handler h) __z88dk_fastcall __preserves_regs(d, e, iyh, iyl);
+_add_VBL::
+ ld b, h
+ ld c, l
+
+.add_VBL::
+ ld hl, #.VBLANK_HANDLER0
+
+ ;; Add interrupt routine in BC to the interrupt list in HL
+.add_int::
+1$:
+ ld a, (hl)
+ inc hl
+ or (hl)
+ jr z, 2$
+ inc hl
+ jr 1$
+2$:
+ ld (hl), b
+ dec hl
+ ld (hl), c
+ ret
+
+; void remove_VBL(int_handler h) __z88dk_fastcall __preserves_regs(iyh, iyl);
+_remove_VBL::
+ ld b, h
+ ld c, l
+
+ ;; Remove interrupt routine in BC from the VBL interrupt list
+ ;; falldown to .remove_int
+.remove_VBL::
+ ld hl, #.VBLANK_HANDLER0
+
+ ;; Remove interrupt BC from interrupt list HL if it exists
+ ;; Abort if a 0000 is found (end of list)
+.remove_int::
+1$:
+ ld e, (hl)
+ inc hl
+ ld d, (hl)
+ inc hl
+ ld a, e
+ or d
+ ret z ; No interrupt found
+
+ ld a, e
+ cp c
+ jr nz, 1$
+
+ ld a, d
+ cp b
+ jr nz, 1$
+
+ ld d, h
+ ld e, l
+ dec de
+ dec de
+
+ ;; Now do a memcpy from here until the end of the list
+2$:
+ ld a, (hl)
+ ldi
+ or (hl)
+ ldi
+ jr nz, 2$
+
+_remove_LCD::
+.remove_LCD::
+_add_LCD::
+.add_LCD::
+_remove_TIM::
+_remove_SIO::
+_remove_JOY::
+_add_TIM::
+_add_SIO::
+_add_JOY::
+.empty_function:
+ ret
+
+ .area _INITIALIZED
+
+.VBLANK_HANDLER0:
+ .ds 0x02
+.VBLANK_HANDLER1:
+ .ds 0x02
+.VBLANK_HANDLER2:
+ .ds 0x02
+ .ds 0x02
+
+ .area _INITIALIZER
+
+ .dw 0x0000
+ .dw 0x0000
+ .dw 0x0000
+ .dw 0x0000
diff --git a/gbdk/gbdk-lib/libc/targets/z80/msxdos/msx_metasprites.s b/gbdk/gbdk-lib/libc/targets/z80/msxdos/msx_metasprites.s
new file mode 100644
index 00000000..57b5bbcd
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/msxdos/msx_metasprites.s
@@ -0,0 +1,77 @@
+ .include "global.s"
+
+ .title "Metasprites"
+ .module Metasprites
+
+ .area _DATA
+
+___current_metasprite::
+ .ds 0x02
+___current_base_tile::
+ .ds 0x01
+
+ .area _CODE
+
+; uint8_t __move_metasprite(uint8_t id, uint8_t x, uint8_t y) __z88dk_callee __preserves_regs(iyh,iyl);
+
+___move_metasprite::
+ ld hl, #4
+ add hl, sp
+
+ ld b, (hl)
+ dec hl
+ ld c, (hl)
+ dec hl
+ ld e, (hl)
+
+ ld hl, (___current_metasprite)
+
+ ld a, (___render_shadow_OAM)
+ ld d, a
+1$:
+ ld a, (hl) ; dy
+ inc hl
+ cp #0x80
+ jp z, 2$
+ add b
+ ld b, a
+ cp #0xD0
+ jp nz, 3$
+ ld a, #0xC0
+3$:
+ ld (de), a
+ inc e
+
+ ld a, (hl) ; dx
+ inc hl
+ add c
+ ld c, a
+ ld (de), a
+ inc e
+
+ ld a, (___current_base_tile)
+ add (hl) ; tile
+ inc hl
+ ld (de), a
+ inc e
+
+ ld a, (hl)
+ inc hl
+ ld (de), a
+ inc e
+
+ jp 1$
+2$:
+ pop hl
+ pop bc
+ inc sp
+ push hl
+ ld a, e
+ srl a
+ srl a
+ sub c
+ ld l, a
+ ret
+
+___render_shadow_OAM::
+ .db #>_shadow_OAM
diff --git a/gbdk/gbdk-lib/libc/targets/z80/msxdos/msx_metasprites_hide.s b/gbdk/gbdk-lib/libc/targets/z80/msxdos/msx_metasprites_hide.s
new file mode 100644
index 00000000..93ca1021
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/msxdos/msx_metasprites_hide.s
@@ -0,0 +1,37 @@
+ .include "global.s"
+
+ .title "Metasprites"
+ .module Metasprites
+
+ .globl ___current_metasprite, ___render_shadow_OAM
+
+ .area _CODE
+
+
+; void __hide_metasprite(uint8_t id) __z88dk_fastcall __preserves_regs(iyh,iyl);
+
+___hide_metasprite::
+ ld e, l
+
+ ld hl, (___current_metasprite)
+
+ ld bc, #4
+
+ ld a, (___render_shadow_OAM)
+ ld d, a
+1$:
+ ld a, (hl)
+ cp #0x80
+ ret z
+
+ ld a, #0x1F
+ cp e
+ ret c
+
+ add hl, bc
+
+ ld a, #0xC0
+ ld (de), a
+
+ inc e
+ jp 1$
diff --git a/gbdk/gbdk-lib/libc/targets/z80/msxdos/msx_metasprites_hide_spr.s b/gbdk/gbdk-lib/libc/targets/z80/msxdos/msx_metasprites_hide_spr.s
new file mode 100644
index 00000000..32551556
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/msxdos/msx_metasprites_hide_spr.s
@@ -0,0 +1,39 @@
+ .include "global.s"
+
+ .title "Metasprites"
+ .module Metasprites
+
+ .globl ___render_shadow_OAM
+
+ .area _CODE
+
+; void hide_sprites_range(UINT8 from, UINT8 to) __z88dk_callee __preserves_regs(iyh,iyl);
+
+_hide_sprites_range::
+ pop hl
+ pop de
+ push hl
+
+ ld a, d
+ cp #(32+1)
+ ret nc
+
+ sub e
+ ret c
+ ret z
+ ld b, a
+
+ ld a, e
+ add a
+ add a
+ ld l, a
+
+ ld a, (___render_shadow_OAM)
+ ld h, a
+ ld de, #4
+1$:
+ ld (hl), #0xC0
+ add hl, de
+ djnz 1$
+
+ ret
diff --git a/gbdk/gbdk-lib/libc/targets/z80/msxdos/msx_refresh_oam.s b/gbdk/gbdk-lib/libc/targets/z80/msxdos/msx_refresh_oam.s
new file mode 100644
index 00000000..9e175730
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/msxdos/msx_refresh_oam.s
@@ -0,0 +1,27 @@
+ .include "global.s"
+
+ .title "VRAM utilities"
+ .module VRAMUtils
+
+ .globl __shadow_OAM_base
+
+ .ez80
+
+ .area _HOME
+
+; void refresh_OAM();
+_refresh_OAM::
+ DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT
+ ld de, #.VDP_SAT
+ VDP_WRITE_CMD d, e
+
+ ld h, #>_shadow_OAM
+ ld l, #0
+ ld c, #.VDP_DATA
+ ld b, #128
+1$:
+ outi
+ jp nz, 1$
+
+ ENABLE_VBLANK_COPY ; switch OFF copy shadow SAT
+ ret \ No newline at end of file
diff --git a/gbdk/gbdk-lib/libc/targets/z80/msxdos/msx_set_1bpp_data.s b/gbdk/gbdk-lib/libc/targets/z80/msxdos/msx_set_1bpp_data.s
new file mode 100644
index 00000000..c88669a5
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/msxdos/msx_set_1bpp_data.s
@@ -0,0 +1,77 @@
+ .include "global.s"
+
+ .title "VRAM utilities"
+ .module VRAMUtils
+
+ .ez80
+
+ .area _HOME
+
+; void set_tile_1bpp_data(uint16_t start, uint16_t ntiles, const void *src, uint16_t colors) __z88dk_callee;
+_set_tile_1bpp_data::
+ pop af
+ pop hl
+ pop iy
+ pop de
+ pop bc
+ push af
+
+ push ix
+ ld ixl, c
+
+ add hl, hl
+ add hl, hl
+ add hl, hl
+
+ push hl
+
+ ld bc, #.VDP_COLORDATA0
+ add hl, bc
+ ex (sp), hl
+
+ ld bc, #.VDP_TILEDATA0
+ add hl, bc
+
+ DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT
+
+ ld c, #.VDP_DATA
+ inc iyh
+ inc iyl
+ jr 2$
+
+1$:
+ VDP_WRITE_CMD h, l
+ ex de, hl
+ ld b, #8
+3$:
+ outi
+ jr nz, 3$
+ ex de, hl
+
+ ld a, #8
+ ADD_A_REG16 h, l
+ ex (sp), hl
+
+ VDP_WRITE_CMD h, l
+ ld b, #8
+ ld a, ixl
+4$:
+ out (c), a
+ inc hl
+ dec b
+ jr nz, 4$
+
+ ex (sp), hl
+2$:
+ dec iyl
+ jr nz, 1$
+
+ dec iyh
+ jr nz, 1$
+
+ ENABLE_VBLANK_COPY ; switch ON copy shadow SAT
+
+ pop hl
+ pop ix
+
+ ret
diff --git a/gbdk/gbdk-lib/libc/targets/z80/msxdos/msx_set_1bpp_sprite_data.s b/gbdk/gbdk-lib/libc/targets/z80/msxdos/msx_set_1bpp_sprite_data.s
new file mode 100644
index 00000000..8ddf727d
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/msxdos/msx_set_1bpp_sprite_data.s
@@ -0,0 +1,52 @@
+ .include "global.s"
+
+ .title "VRAM utilities"
+ .module VRAMUtils
+
+ .ez80
+
+ .area _HOME
+
+; void set_sprite_1bpp_data(uint16_t start, uint16_t ntiles, const void *src) __z88dk_callee;
+_set_sprite_1bpp_data::
+ pop af
+ pop hl
+ pop iy
+ pop de
+ push af
+
+ add hl, hl
+ add hl, hl
+ add hl, hl
+
+ ld bc, #.VDP_SPRDATA0
+ add hl, bc
+
+ DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT
+
+ VDP_WRITE_CMD h, l
+
+ ex de, hl
+
+ ld d, iyh
+ ld e, iyl
+
+ ld c, #.VDP_DATA
+ inc d
+ inc e
+ jr 2$
+1$:
+ ld b, #8
+3$:
+ outi
+ jr nz, 3$
+2$:
+ dec e
+ jr nz, 1$
+
+ dec d
+ jr nz, 1$
+
+ ENABLE_VBLANK_COPY ; switch ON copy shadow SAT
+
+ ret
diff --git a/gbdk/gbdk-lib/libc/targets/z80/msxdos/msx_set_native_data.s b/gbdk/gbdk-lib/libc/targets/z80/msxdos/msx_set_native_data.s
new file mode 100644
index 00000000..5c758ecf
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/msxdos/msx_set_native_data.s
@@ -0,0 +1,73 @@
+ .include "global.s"
+
+ .title "VRAM utilities"
+ .module VRAMUtils
+ .ez80
+
+ .area _HOME
+
+; void set_native_tile_data(uint16_t start, uint16_t ntiles, const void *src) __z88dk_callee
+_set_native_tile_data::
+ pop bc
+ pop hl
+ pop iy
+ pop de
+ push bc
+
+ add hl, hl
+ add hl, hl
+ add hl, hl
+
+ push hl
+
+ ld bc, #.VDP_COLORDATA0
+ add hl, bc
+ ex (sp), hl
+
+ ld bc, #.VDP_TILEDATA0
+ add hl, bc
+
+ DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT
+
+ ld c, #.VDP_DATA
+ inc iyh
+ inc iyl
+ jr 2$
+
+1$:
+ VDP_WRITE_CMD h, l
+ ex de, hl
+ ld b, #8
+3$:
+ outi
+ jr nz, 3$
+ ex de, hl
+
+ ld a, #8
+ ADD_A_REG16 h, l
+ ex (sp), hl
+
+ VDP_WRITE_CMD h, l
+ ex de, hl
+ ld b, #8
+4$:
+ outi
+ jr nz, 4$
+ ex de, hl
+
+ ld a, #8
+ ADD_A_REG16 h, l
+ ex (sp), hl
+
+2$:
+ dec iyl
+ jr nz, 1$
+
+ dec iyh
+ jr nz, 1$
+
+ pop hl
+
+ ENABLE_VBLANK_COPY ; switch ON copy shadow SAT
+
+ ret
diff --git a/gbdk/gbdk-lib/libc/targets/z80/msxdos/msx_set_tile_map.s b/gbdk/gbdk-lib/libc/targets/z80/msxdos/msx_set_tile_map.s
new file mode 100644
index 00000000..119bd742
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/msxdos/msx_set_tile_map.s
@@ -0,0 +1,29 @@
+ .include "global.s"
+
+ .title "VRAM utilities"
+ .module VRAMUtils
+
+ .globl .set_tile_map_xy
+
+ .area _HOME
+
+; void set_tile_map(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *tiles) __z88dk_callee __preserves_regs(iyh, iyl);
+_set_tile_map::
+ pop hl ; HL = ret
+ pop bc ; BC = YX
+ pop de ; DE = WH
+ ex (sp), hl ; HL = data
+ ex de, hl ; HL = WH, DE = data
+
+ xor a
+ FAST_MOD8 b #.VDP_MAP_HEIGHT
+
+ ld b, d
+ ld d, a
+
+ ld a, c
+ ld c, e
+ ld e, a ; BC = data, DE = YX
+
+ jp .set_tile_map_xy
+
diff --git a/gbdk/gbdk-lib/libc/targets/z80/msxdos/msx_set_tile_map_xy.s b/gbdk/gbdk-lib/libc/targets/z80/msxdos/msx_set_tile_map_xy.s
new file mode 100644
index 00000000..f1419a69
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/msxdos/msx_set_tile_map_xy.s
@@ -0,0 +1,100 @@
+ .include "global.s"
+
+ .title "VRAM utilities"
+ .module VRAMUtils
+
+ .ez80
+
+ .area _HOME
+
+ ;; Set background tile table from (BC) at XY = DE of size WH = HL
+.set_tile_map_xy::
+ push hl
+ ld hl, #.VDP_TILEMAP
+
+ ;; Set background tile from (BC) at YX = DE, size WH on stack, to VRAM from address (HL)
+.set_tile_map_xy_tt::
+ push bc ; Store source
+
+ ld a, d
+ rrca ; rrca(3) == rlca(5)
+ rrca
+ rrca
+ ld d, a
+ and #0x07
+ add h
+ ld b, a
+ ld a, #0xE0
+ and d
+ add e
+ ld c, a ; dest BC = HL + ((0x20 * Y) + X
+
+ ld a, b
+ cp #>(.VDP_TILEMAP+0x0300)
+ jr c, 5$
+ ld b, #>.VDP_TILEMAP
+5$:
+ pop hl ; HL = source
+ pop de ; DE = HW
+ push ix ; save IX
+ push de ; store HW
+ ld ixh, b
+ ld ixl, c
+ push ix ; store dest
+
+ DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT
+
+1$: ; copy H rows
+ VDP_WRITE_CMD ixh, ixl
+ ld c, #.VDP_DATA
+2$: ; copy W tiles
+ ld a, (__map_tile_offset)
+ add (hl)
+ out (c), a
+ inc hl
+ dec b
+
+ ld a, ixl
+ and #0x1F
+ inc a
+ bit 5, a
+ jp z, 3$
+ and #0x1F
+ ld b, a
+ ld a, ixl
+ and #0xE0
+ or b
+ ld ixl, a
+ VDP_WRITE_CMD ixh, ixl
+ dec e
+ jp nz, 2$
+ jp 7$
+3$:
+ inc ixl
+ dec e
+ jp nz, 2$
+7$:
+ pop ix
+ pop de
+
+ dec d
+ jr z, 6$
+
+ push de
+
+ ld bc, #0x20
+ add ix, bc
+ ld a, ixh
+ cp #>(.VDP_TILEMAP+0x0300)
+ jp c, 4$
+ ld ixh, #>.VDP_TILEMAP
+4$:
+ push ix
+ jp 1$
+6$:
+ ENABLE_VBLANK_COPY ; switch ON copy shadow SAT
+ pop ix ; restore IX
+ ret
+
+__map_tile_offset::
+ .db 0x00
diff --git a/gbdk/gbdk-lib/libc/targets/z80/msxdos/msx_write_vdp.s b/gbdk/gbdk-lib/libc/targets/z80/msxdos/msx_write_vdp.s
new file mode 100644
index 00000000..53f7c9b4
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/msxdos/msx_write_vdp.s
@@ -0,0 +1,14 @@
+ .include "global.s"
+
+ .title "write vdp"
+ .module write_vdp
+
+ .area _CODE
+
+_WRITE_VDP_CMD::
+ VDP_WRITE_CMD h, l
+ ret
+_WRITE_VDP_DATA::
+ VDP_WRITE_DATA h, l
+ ret
+ \ No newline at end of file
diff --git a/gbdk/gbdk-lib/libc/targets/z80/msxdos/pad.s b/gbdk/gbdk-lib/libc/targets/z80/msxdos/pad.s
new file mode 100644
index 00000000..ce73c347
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/msxdos/pad.s
@@ -0,0 +1,66 @@
+ .include "global.s"
+
+ .title "JOYPad utilities"
+ .module JOYPad
+ .area _HOME
+
+ ;; Get Keypad Button Status
+_joypad::
+.jpad::
+ ld a, #0x06 ; ... <code> <caps> <graph> <ctrl> <shift>
+ out (.KBD_SELECT_ROW), a
+ in a, (.KBD_INPUT)
+ cpl
+
+ rrca
+ rl l
+ rrca
+ rrca
+ rl l ; shift graph
+
+ ld a, #0x07 ; <ret>, ...
+ out (.KBD_SELECT_ROW), a
+ in a, (.KBD_INPUT)
+ cpl
+
+ rlca
+ rl l
+ rl l
+ ld a, #0b00001110
+ and l
+ ld l, a
+
+ ld a, #0x08 ; <r><d><u><l><del><ins><home><space>
+ out (.KBD_SELECT_ROW), a
+ in a, (.KBD_INPUT)
+ cpl
+ and #0b11110001
+
+ or l
+ ld l, a ; <r><d><u><l><shift><graph><enter><space>
+
+ ret
+
+ ;; Wait until all buttons have been released
+.padup::
+_waitpadup::
+1$:
+ ld h,#0x7f ; wait for .jpad return zero 127 times in a row
+2$:
+ call .jpad
+ or a ; have all buttons been released?
+ jr nz,1$ ; not yet
+
+ dec h
+ jr nz,2$
+
+ ret
+
+ ;; Wait for the key to be pressed
+_waitpad::
+.wait_pad::
+1$:
+ call .jpad ; read pad
+ and l ; compare with mask?
+ jr z,1$ ; loop if no intersection
+ ret
diff --git a/gbdk/gbdk-lib/libc/targets/z80/outi.s b/gbdk/gbdk-lib/libc/targets/z80/outi.s
new file mode 100644
index 00000000..6a61c17a
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/outi.s
@@ -0,0 +1,20 @@
+ .include "global.s"
+
+ .title "VRAM utilities"
+ .module VRAMUtils
+ .area _HOME
+
+.OUTI128:: ; _OUTI128 label points to a block of 128 OUTI and a RET
+ .rept 64
+ outi
+ .endm
+.OUTI64:: ; _OUTI64 label points to a block of 64 OUTI and a RET
+ .rept 32
+ outi
+ .endm
+.OUTI32:: ; _OUTI32 label points to a block of 32 OUTI and a RET
+ .rept 32
+ outi
+ .endm
+.OUTI_END:: ; _outi_block label points to END of OUTI block
+ ret
diff --git a/gbdk/gbdk-lib/libc/targets/z80/putchar.s b/gbdk/gbdk-lib/libc/targets/z80/putchar.s
new file mode 100644
index 00000000..22c5ce98
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/putchar.s
@@ -0,0 +1,126 @@
+ .include "global.s"
+
+ .title "putchar"
+ .module putchar
+
+ .globl font_current, font_set, font_load_ibm
+ .globl .scroll_viewport
+
+ ; Structure offsets
+ sfont_handle_sizeof = 3
+ sfont_handle_font = 1
+ sfont_handle_first_tile = 0
+
+ ; Encoding types - lower 2 bits of font
+ FONT_256ENCODING = 0
+ FONT_128ENCODING = 1
+ FONT_NOENCODING = 2
+
+ .area _INITIALIZED
+ ; The current font
+.curx::
+ .ds 1
+.cury::
+ .ds 1
+
+ .area _INITIALIZER
+ .db #.SCREEN_X_OFS ; .curx
+ .db #.SCREEN_Y_OFS ; .cury
+
+ .area _HOME
+
+_setchar::
+_putchar::
+ pop hl
+ pop de
+ push de
+ push hl
+
+ ld a, e
+ cp #.CR
+ jr nz, 0$
+
+ ld a, #.SCREEN_X_OFS
+ ld (.curx), a
+ jp 2$
+0$:
+ ld hl, (font_current+sfont_handle_font)
+ ld a, h
+ or l
+ jr nz, 6$
+
+ push de
+ call font_load_ibm
+ ld a, h
+ or l
+ ret z
+ call font_set
+ pop de
+ ld hl, (font_current+sfont_handle_font)
+6$:
+ ld a, (hl)
+ and #3
+ cp #FONT_NOENCODING
+ jr z, 4$
+ inc hl
+ inc hl
+ ld d, #0
+ add hl, de
+ ld e, (hl)
+4$:
+ ld a, (font_current)
+ add a, e
+ ld e, a
+
+ ld a, (.cury)
+ ld l, a
+ ld h, #0
+ add hl, hl
+ add hl, hl
+ add hl, hl
+ add hl, hl
+ add hl, hl
+ add hl, hl
+ ld a, (.curx)
+ add a
+ add l
+ ld l, a
+ adc h
+ sub l
+ ld h, a
+
+ ld bc, #.VDP_TILEMAP
+ add hl, bc
+
+ DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT
+ WRITE_VDP_CMD_HL
+
+ ld a, e
+ out (.VDP_DATA), a
+ VDP_DELAY
+ xor a
+ out (.VDP_DATA), a
+
+ ENABLE_VBLANK_COPY ; switch ON copy shadow SAT
+
+ ld a, (.curx)
+ inc a
+ cp #(.SCREEN_X_OFS + .SCREEN_WIDTH)
+ jr c, 5$
+ ld a, #.SCREEN_X_OFS
+5$:
+ ld (.curx), a
+ ret nz
+2$:
+ ld a, (.cury)
+ inc a
+ cp #(.SCREEN_Y_OFS + .SCREEN_HEIGHT)
+ jr c, 3$
+ ld a, #(.SCREEN_Y_OFS + .SCREEN_HEIGHT - 1)
+ ld (.cury), a
+
+ call .scroll_viewport
+ ret
+3$:
+ ld (.cury), a
+ ret
diff --git a/gbdk/gbdk-lib/libc/targets/z80/rle_decompress.s b/gbdk/gbdk-lib/libc/targets/z80/rle_decompress.s
new file mode 100644
index 00000000..d34d0bf3
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/rle_decompress.s
@@ -0,0 +1,100 @@
+ .include "global.s"
+
+ .module RLE_DECOMPRESS
+
+ .area _DATA
+
+rle_cursor:
+ .ds 0x02
+rle_counter:
+ .ds 0x01
+rle_current:
+ .ds 0x01
+
+ .area _CODE
+
+_rle_init::
+ ld (rle_cursor), hl
+ xor a
+ ld hl, #rle_counter
+ ld (hl), a
+ inc hl
+ ld (hl), a
+ ld l, #1
+ ret
+
+_rle_decompress::
+ ;; Pop the return address
+ pop hl
+ pop de
+ dec sp
+ ex (sp), hl
+ ld b, h
+
+ ld hl, (rle_cursor)
+
+ ld a, l
+ or h
+ ret z
+
+ ld a, (rle_counter)
+ or a
+ ld c, a
+ jr z, 1$
+
+ ld a, (rle_current)
+ bit 7, c
+ jr nz, 10$
+ jr 11$
+1$:
+ ;; Fetch the run
+ ld c, (hl)
+ inc hl
+ ;; Negative means a run
+8$:
+ bit 7, c
+ jr z, 2$
+ ;; Expanding a run
+ ld a, (hl)
+ inc hl
+3$:
+ ld (de), a
+ inc de
+
+ dec b
+ jr z, 6$
+10$:
+ inc c
+ jr NZ, 3$
+ jr 1$
+2$:
+ ;; Zero means end of a block
+ inc c
+ dec c
+ jr z, 4$
+ ;; Expanding a block
+5$:
+ ldi
+ inc bc
+
+ dec b
+ jr z, 6$
+11$:
+ dec c
+ jr NZ, 5$
+ jr 1$
+4$:
+ ;; save state and exit
+ ld hl, #0
+ ld (rle_cursor), hl
+ ld (rle_counter), hl
+ ret
+6$:
+ ;; save state and exit
+ ld (rle_cursor), hl
+ ld hl, #rle_counter
+ ld (hl), c
+ inc hl
+ ld (hl), a
+ ld l, #1
+ ret \ No newline at end of file
diff --git a/gbdk/gbdk-lib/libc/targets/z80/scroll.s b/gbdk/gbdk-lib/libc/targets/z80/scroll.s
new file mode 100644
index 00000000..47306d6b
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/scroll.s
@@ -0,0 +1,61 @@
+ .include "global.s"
+
+ .title "console utilities"
+ .module ConsoleUtils
+
+ .globl .curx, .cury
+
+ .area _HOME
+
+.scroll_viewport::
+ DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT
+ ld hl, #(.VDP_TILEMAP + ((.SCREEN_Y_OFS + 1) * .VDP_MAP_WIDTH * 2))
+
+ ld bc, #((.SCREEN_HEIGHT - 1) * .VDP_MAP_WIDTH * 2)
+ inc b
+ inc c
+ jr 1$
+2$:
+ res 6, h
+ WRITE_VDP_CMD_HL
+ nop
+ nop
+ in a, (.VDP_DATA)
+ ld e, a
+
+ ld a, l
+ sub #(.VDP_MAP_WIDTH * 2)
+ ld l, a
+ ld a, h
+ sbc #0
+ ld h, a
+
+ set 6, h
+ WRITE_VDP_CMD_HL
+ nop
+ ld a, e
+ out (.VDP_DATA), a
+
+ ld a, #((.VDP_MAP_WIDTH * 2) + 1)
+ add l
+ ld l, a
+ adc h
+ sub l
+ ld h, a
+
+1$:
+ dec c
+ jr nz, 2$
+ djnz 2$
+
+ ld hl, #(.VDP_TILEMAP + ((.SCREEN_Y_OFS + .SCREEN_HEIGHT - 1) * .VDP_MAP_WIDTH * 2))
+ WRITE_VDP_CMD_HL
+
+ ld hl, #.SPACE
+ ld b, #.VDP_MAP_WIDTH
+3$:
+ WRITE_VDP_DATA_HL
+ djnz 3$
+
+ ENABLE_VBLANK_COPY ; switch ON copy shadow SAT
+ ret \ No newline at end of file
diff --git a/gbdk/gbdk-lib/libc/targets/z80/set_interrupts.s b/gbdk/gbdk-lib/libc/targets/z80/set_interrupts.s
new file mode 100644
index 00000000..1135e529
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/set_interrupts.s
@@ -0,0 +1,46 @@
+ .include "global.s"
+
+ .title "Set interrupts"
+ .module SetInterrupts
+
+ .globl _shadow_VDP_R0
+ .globl _shadow_VDP_R1
+
+ .area _HOME
+
+_set_interrupts::
+ ld a, i
+ di
+ push af
+
+ ld a, (_shadow_VDP_R1)
+ bit 0, l
+ jr z, 1$
+ or #.R1_IE
+ jr 2$
+1$:
+ and #~.R1_IE
+2$:
+ ld (_shadow_VDP_R1), a
+ out (.VDP_CMD), a
+ ld a, #.VDP_R1
+ out (.VDP_CMD), a
+
+ ld a, (_shadow_VDP_R0)
+ bit 1, l
+ jr z, 3$
+ or #.R0_IE1
+ jr 4$
+3$:
+ and #~.R0_IE1
+4$:
+ ld (_shadow_VDP_R0), a
+ out (.VDP_CMD), a
+ ld a, #.VDP_R0
+ out (.VDP_CMD), a
+
+ pop af
+ jp po, 5$
+ ei
+5$:
+ ret
diff --git a/gbdk/gbdk-lib/libc/targets/z80/set_palette.s b/gbdk/gbdk-lib/libc/targets/z80/set_palette.s
new file mode 100644
index 00000000..07579211
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/set_palette.s
@@ -0,0 +1,23 @@
+ ;; SMS palette routines
+
+ .include "global.s"
+
+ .title "CRAM SMS Palettes"
+ .module CRAMUtils
+
+ .globl .CRT_DEFAULT_PALETTE, _set_palette
+
+ .area _HOME
+
+_set_default_palette::
+ ld hl, #.CRT_DEFAULT_PALETTE
+ push hl
+ ld hl, #0x0100
+ push hl
+ call _set_palette
+ ld hl, #.CRT_DEFAULT_PALETTE
+ push hl
+ ld hl, #0x0101
+ push hl
+ call _set_palette
+ ret
diff --git a/gbdk/gbdk-lib/libc/targets/z80/set_tile.s b/gbdk/gbdk-lib/libc/targets/z80/set_tile.s
new file mode 100644
index 00000000..9f2b410d
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/set_tile.s
@@ -0,0 +1,70 @@
+ .include "global.s"
+
+ .title "VRAM utilities"
+ .module VRAMUtils
+
+ .globl .coords_to_address
+
+ .area _HOME
+
+; void set_vram_byte(uint8_t * addr, uint8_t v) __z88dk_callee __preserves_regs(iyh, iyl);
+_set_vram_byte::
+ pop de
+ pop hl
+ DISABLE_VBLANK_COPY
+ WRITE_VDP_CMD_HL
+ ex de, hl
+ dec sp
+ ex (sp), hl
+ ld a, h
+ out (.VDP_DATA), a
+ ENABLE_VBLANK_COPY
+ ret
+
+; uint8_t * set_attributed_tile_xy(uint8_t x, uint8_t y, uint16_t t) __z88dk_callee __preserves_regs(iyh, iyl);
+_set_attributed_tile_xy::
+ pop hl ; HL = ret
+ pop de ; DE = YX
+ ex (sp), hl ; HL = data
+
+ ld a, d
+
+ ld bc, #.VDP_TILEMAP
+ call .coords_to_address
+ ex de, hl
+
+ DISABLE_VBLANK_COPY
+ WRITE_VDP_CMD_HL
+
+ ld c, #.VDP_DATA
+ out (c), e
+ VDP_DELAY
+ out (c), d
+
+ ENABLE_VBLANK_COPY
+ ret
+
+; uint8_t * set_tile_xy(uint8_t x, uint8_t y, uint8_t t) __z88dk_callee __preserves_regs(iyh, iyl);
+_set_tile_xy::
+ pop hl ; HL = ret
+ pop de ; DE = YX
+ dec sp
+ ex (sp), hl ; HL = data
+
+ ld a, d
+
+ ld bc, #.VDP_TILEMAP
+ call .coords_to_address
+ ex de, hl
+
+ ld a, (.vdp_shift)
+ ADD_A_REG16 h, l
+
+ DISABLE_VBLANK_COPY
+ WRITE_VDP_CMD_HL
+
+ ld a, d
+ out (.VDP_DATA), a
+
+ ENABLE_VBLANK_COPY
+ ret
diff --git a/gbdk/gbdk-lib/libc/targets/z80/set_tile_map.s b/gbdk/gbdk-lib/libc/targets/z80/set_tile_map.s
new file mode 100644
index 00000000..514106b9
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/set_tile_map.s
@@ -0,0 +1,33 @@
+ .include "global.s"
+
+ .title "VRAM utilities"
+ .module VRAMUtils
+
+ .globl .set_tile_map_xy
+
+ .area _HOME
+
+; void set_tile_map(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *tiles) __z88dk_callee __preserves_regs(iyh, iyl);
+_set_tile_map::
+ pop hl ; HL = ret
+ pop bc ; BC = YX
+ pop de ; DE = WH
+ ex (sp), hl ; HL = data
+ ex de, hl ; HL = WH, DE = data
+
+ ld a, b
+ ld b, d
+
+ add #.SCREEN_Y_OFS
+ ld d, a
+ xor a
+ FAST_MOD8 d #28
+ ld d, a
+
+ ld a, c
+ add #.SCREEN_X_OFS
+ and #0x1f
+ ld c, e
+ ld e, a ; BC = data, DE = YX
+
+ jp .set_tile_map_xy
diff --git a/gbdk/gbdk-lib/libc/targets/z80/set_tile_map_compat.s b/gbdk/gbdk-lib/libc/targets/z80/set_tile_map_compat.s
new file mode 100644
index 00000000..5160ccd8
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/set_tile_map_compat.s
@@ -0,0 +1,33 @@
+ .include "global.s"
+
+ .title "VRAM utilities"
+ .module VRAMUtils
+
+ .globl .set_tile_map_xy
+
+ .area _HOME
+
+; void set_tile_map(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *tiles) __z88dk_callee __preserves_regs(iyh, iyl);
+_set_tile_map_compat::
+ pop hl ; HL = ret
+ pop bc ; BC = YX
+ pop de ; DE = WH
+ ex (sp), hl ; HL = data
+ ex de, hl ; HL = WH, DE = data
+
+ ld a, b
+ ld b, d
+
+ add #.SCREEN_Y_OFS
+ ld d, a
+ xor a
+ FAST_MOD8 d #28
+ ld d, a
+
+ ld a, c
+ add #.SCREEN_X_OFS
+ and #0x1f
+ ld c, e
+ ld e, a ; BC = data, DE = YX
+
+ jp .set_tile_map_xy_compat
diff --git a/gbdk/gbdk-lib/libc/targets/z80/set_tile_map_xy.s b/gbdk/gbdk-lib/libc/targets/z80/set_tile_map_xy.s
new file mode 100644
index 00000000..7e028e2c
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/set_tile_map_xy.s
@@ -0,0 +1,98 @@
+ .include "global.s"
+
+ .title "VRAM utilities"
+ .module VRAMUtils
+
+ .ez80
+
+ .area _HOME
+
+ ;; Set background tile table from (BC) at XY = DE of size WH = HL
+.set_tile_map_xy::
+ push hl
+ ld hl, #.VDP_TILEMAP
+
+ ;; Set background tile from (BC) at YX = DE, size WH on stack, to VRAM from address (HL)
+.set_tile_map_xy_tt::
+ push bc ; Store source
+
+ ld a, d
+ rrca ; rrca(2) == rlca(6)
+ rrca
+ ld d, a
+ and #0x07
+ add h
+ ld b, a
+ ld a, #0xC0
+ and d
+ sla e
+ add e
+ ld c, a ; dest BC = HL + ((0x20 * Y) * 2) + (X * 2)
+
+ ld a, b
+ cp #>(.VDP_TILEMAP+0x0700)
+ jr c, 5$
+ ld b, #>.VDP_TILEMAP
+5$:
+ pop hl ; HL = source
+ pop de ; DE = HW
+ push ix ; save IX
+ push de ; store HW
+
+ ld ixh, b
+ ld ixl, c
+ push ix ; store dest
+
+ DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT
+
+1$: ; copy H rows
+ VDP_WRITE_CMD ixh, ixl
+ ld c, #.VDP_DATA
+2$: ; copy W tiles
+ outi
+ VDP_DELAY
+ outi
+
+ ld a, ixl
+ and #0x3F
+ inc a
+ inc a
+ bit 6, a
+ jp z, 3$
+ and #0x3F
+ ld b, a
+ ld a, ixl
+ and #0xC0
+ or b
+ ld ixl, a
+ VDP_WRITE_CMD ixh, ixl
+ dec e
+ jp nz, 2$
+ jp 7$
+3$:
+ inc ixl
+ inc ixl
+ dec e
+ jp nz, 2$
+7$:
+ pop ix
+ pop de
+
+ dec d
+ jr z, 6$
+
+ push de
+
+ ld bc, #0x40
+ add ix, bc
+ ld a, ixh
+ cp #>(.VDP_TILEMAP+0x0700)
+ jp c, 4$
+ ld ixh, #>.VDP_TILEMAP
+4$:
+ push ix
+ jp 1$
+6$:
+ ENABLE_VBLANK_COPY ; switch ON copy shadow SAT
+ pop ix ; restore IX
+ ret \ No newline at end of file
diff --git a/gbdk/gbdk-lib/libc/targets/z80/set_tile_map_xy_compat.s b/gbdk/gbdk-lib/libc/targets/z80/set_tile_map_xy_compat.s
new file mode 100644
index 00000000..eb630dc2
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/set_tile_map_xy_compat.s
@@ -0,0 +1,115 @@
+ .include "global.s"
+
+ .globl .vdp_shift
+
+ .title "VRAM utilities"
+ .module VRAMUtils
+
+ .ez80
+
+ .area _INITIALIZED
+
+__map_tile_offset::
+ .ds 0x01
+
+ .area _INITIALIZER
+
+ .db 0x00
+
+ .area _HOME
+
+ ;; Set background tile table from (BC) at XY = DE of size WH = HL
+.set_tile_map_xy_compat::
+ push hl
+ ld hl, #.VDP_TILEMAP
+
+ ;; Set background tile from (BC) at YX = DE, size WH on stack, to VRAM from address (HL)
+.set_tile_map_xy_tt_compat::
+ push bc ; Store source
+
+ ld a, d
+ rrca ; rrca(2) == rlca(6)
+ rrca
+ ld d, a
+ and #0x07
+ add h
+ ld b, a
+ ld a, #0xC0
+ and d
+ sla e
+ add e
+ ld hl, #.vdp_shift
+ add (hl)
+ ld c, a ; dest BC = HL + ((0x20 * Y) * 2) + (X * 2)
+
+ ld a, b
+ cp #>(.VDP_TILEMAP+0x0700)
+ jr c, 5$
+ ld b, #>.VDP_TILEMAP
+5$:
+ pop hl ; HL = source
+ pop de ; DE = HW
+ push ix ; save IX
+ push de ; store HW
+ ld ixh, b
+ ld ixl, c
+ push ix ; store dest
+
+ DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT
+
+1$: ; copy H rows
+ VDP_WRITE_CMD ixh, ixl
+ ld c, #.VDP_DATA
+2$: ; copy W tiles
+ ld a, (__map_tile_offset)
+ add (hl)
+ out (c), a
+ inc hl
+ dec b
+ jr 8$ ; delay
+8$:
+ in a, (c) ; skip next byte
+
+ ld a, ixl
+ and #0x3F
+ inc a
+ inc a
+ bit 6, a
+ jp z, 3$
+ and #0x3F
+ ld b, a
+ ld a, ixl
+ and #0xC0
+ or b
+ ld ixl, a
+ VDP_WRITE_CMD ixh, ixl
+ dec e
+ jp nz, 2$
+ jp 7$
+3$:
+ inc ixl
+ inc ixl
+ dec e
+ jp nz, 2$
+7$:
+ pop ix
+ pop de
+
+ dec d
+ jr z, 6$
+
+ push de
+
+ ld bc, #0x40
+ add ix, bc
+ ld a, ixh
+ cp #>(.VDP_TILEMAP+0x0700)
+ jp c, 4$
+ ld ixh, #>.VDP_TILEMAP
+4$:
+ push ix
+ jp 1$
+6$:
+ ENABLE_VBLANK_COPY ; switch ON copy shadow SAT
+ pop ix ; restore IX
+ ret \ No newline at end of file
diff --git a/gbdk/gbdk-lib/libc/targets/z80/set_tile_submap.s b/gbdk/gbdk-lib/libc/targets/z80/set_tile_submap.s
new file mode 100644
index 00000000..198bf0d0
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/set_tile_submap.s
@@ -0,0 +1,156 @@
+ .include "global.s"
+
+ .title "VRAM utilities"
+ .module VRAMUtils
+
+ .ez80
+
+ .area _DATA
+
+.image_tile_width::
+ .ds 0x01
+
+ .area _HOME
+
+; void set_tile_submap(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t map_w, const uint8_t *map) __z88dk_callee __preserves_regs(iyh, iyl);
+_set_tile_submap::
+ pop hl ; HL = ret
+ pop bc ; BC = YX
+ pop de ; DE = WH
+
+ dec sp
+ pop af
+ sub e
+ ld (.image_tile_width), a ; .image_tile_width contains corrected width
+
+ ex (sp), hl ; HL = data
+ ex de, hl ; HL = WH, DE = data
+
+ push hl
+ push de
+
+ add l
+ ld e, a
+ ld d, #0
+ ld a, b
+ MUL_DE_BY_A_RET_HL
+ ld a, c
+ ADD_A_REG16 h, l
+ add hl, hl
+
+ pop de
+ add hl, de
+ ex de, hl
+
+ pop hl
+
+ ld a, b
+ ld b, d
+
+ add #.SCREEN_Y_OFS
+ ld d, a
+ xor a
+ FAST_MOD8 d #28
+ ld d, a
+
+ ld a, c
+ add #.SCREEN_X_OFS
+ and #0x1f
+ ld c, e
+ ld e, a ; BC = data, DE = YX
+
+ ;; Set background tile table from (BC) at XY = DE of size WH = HL
+.set_tile_submap_xy::
+ push hl
+ ld hl, #.VDP_TILEMAP
+
+ ;; Set background tile from (BC) at YX = DE, size WH on stack, to VRAM from address (HL)
+.set_tile_submap_xy_tt::
+ push bc ; Store source
+
+ ld a, d
+ rrca ; rrca(2) == rlca(6)
+ rrca
+ ld d, a
+ and #0x07
+ add h
+ ld b, a
+ ld a, #0xC0
+ and d
+ sla e
+ add e
+ ld c, a ; dest BC = HL + ((0x20 * Y) * 2) + (X * 2)
+
+ ld a, b
+ cp #>(.VDP_TILEMAP+0x0700)
+ jr c, 5$
+ ld b, #>.VDP_TILEMAP
+5$:
+ pop hl ; HL = source
+ pop de ; DE = HW
+ push ix ; save IX
+ push de ; store HW
+
+ ld ixh, b
+ ld ixl, c
+ push ix ; store dest
+
+ DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT
+
+1$: ; copy H rows
+ VDP_WRITE_CMD ixh, ixl
+ ld c, #.VDP_DATA
+2$: ; copy W tiles
+ outi
+ VDP_DELAY
+ outi
+
+ ld a, ixl
+ and #0x3F
+ inc a
+ inc a
+ bit 6, a
+ jp z, 3$
+ and #0x3F
+ ld b, a
+ ld a, ixl
+ and #0xC0
+ or b
+ ld ixl, a
+ VDP_WRITE_CMD ixh, ixl
+ dec e
+ jp nz, 2$
+ jp 7$
+3$:
+ inc ixl
+ inc ixl
+ dec e
+ jp nz, 2$
+7$:
+ pop ix
+ pop de
+
+ dec d
+ jr z, 6$
+
+ push de
+
+ ld b, #0
+ ld a, (.image_tile_width)
+ ld c, a
+ add hl, bc
+ add hl, bc
+
+ ld bc, #0x40
+ add ix, bc
+ ld a, ixh
+ cp #>(.VDP_TILEMAP+0x0700)
+ jp c, 4$
+ ld ixh, #>.VDP_TILEMAP
+4$:
+ push ix
+ jp 1$
+6$:
+ ENABLE_VBLANK_COPY ; switch ON copy shadow SAT
+ pop ix ; restore IX
+ ret
diff --git a/gbdk/gbdk-lib/libc/targets/z80/set_tile_submap_compat.s b/gbdk/gbdk-lib/libc/targets/z80/set_tile_submap_compat.s
new file mode 100644
index 00000000..477dde97
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/set_tile_submap_compat.s
@@ -0,0 +1,168 @@
+ .include "global.s"
+
+ .title "VRAM utilities"
+ .module VRAMUtils
+
+ .ez80
+
+ .area _DATA
+
+.image_tile_width_compat::
+ .ds 0x01
+
+ .area _INITIALIZED
+
+__submap_tile_offset::
+ .ds 0x01
+
+ .area _INITIALIZER
+
+ .db 0x00
+
+ .area _HOME
+
+; void set_tile_submap_compat(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t map_w, const uint8_t *map) __z88dk_callee __preserves_regs(iyh, iyl);
+_set_tile_submap_compat::
+ pop hl ; HL = ret
+ pop bc ; BC = YX
+ pop de ; DE = WH
+
+ dec sp
+ pop af
+ sub e
+ ld (.image_tile_width_compat), a ; .image_tile_width_compat contains corrected width
+
+ ex (sp), hl ; HL = data
+ ex de, hl ; HL = WH, DE = data
+
+ push hl
+ push de
+
+ add l
+ ld e, a
+ ld d, #0
+ ld a, b
+ MUL_DE_BY_A_RET_HL
+ ld a, c
+ ADD_A_REG16 h, l
+
+ pop de
+ add hl, de
+ ex de, hl
+
+ pop hl
+
+ ld a, b
+ ld b, d
+
+ add #.SCREEN_Y_OFS
+ ld d, a
+ xor a
+ FAST_MOD8 d #28
+ ld d, a
+
+ ld a, c
+ add #.SCREEN_X_OFS
+ and #0x1f
+ ld c, e
+ ld e, a ; BC = data, DE = YX
+
+ ;; Set background tile table from (BC) at XY = DE of size WH = HL
+.set_tile_submap_xy_compat::
+ push hl
+ ld hl, #.VDP_TILEMAP
+
+ ;; Set background tile from (BC) at YX = DE, size WH on stack, to VRAM from address (HL)
+.set_tile_submap_xy_tt_compat::
+ push bc ; Store source
+
+ ld a, d
+ rrca ; rrca(2) == rlca(6)
+ rrca
+ ld d, a
+ and #0x07
+ add h
+ ld b, a
+ ld a, #0xC0
+ and d
+ sla e
+ add e
+ ld hl, #.vdp_shift
+ add (hl)
+ ld c, a ; dest BC = HL + ((0x20 * Y) * 2) + (X * 2)
+
+ ld a, b
+ cp #>(.VDP_TILEMAP+0x0700)
+ jr c, 5$
+ ld b, #>.VDP_TILEMAP
+5$:
+ pop hl ; HL = source
+ pop de ; DE = HW
+ push ix ; save IX
+ push de ; store HW
+
+ ld ixh, b
+ ld ixl, c
+ push ix ; store dest
+
+ DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT
+
+1$: ; copy H rows
+ VDP_WRITE_CMD ixh, ixl
+ ld c, #.VDP_DATA
+2$: ; copy W tiles
+ ld a, (__map_tile_offset)
+ add (hl)
+ out (c), a
+ inc hl
+ dec b
+ jr 8$ ; delay
+8$:
+ in a, (c) ; skip next byte
+
+ ld a, ixl
+ and #0x3F
+ inc a
+ inc a
+ bit 6, a
+ jp z, 3$
+ and #0x3F
+ ld b, a
+ ld a, ixl
+ and #0xC0
+ or b
+ ld ixl, a
+ VDP_WRITE_CMD ixh, ixl
+ dec e
+ jp nz, 2$
+ jp 7$
+3$:
+ inc ixl
+ inc ixl
+ dec e
+ jp nz, 2$
+7$:
+ pop ix
+ pop de
+
+ dec d
+ jr z, 6$
+
+ push de
+
+ ld a, (.image_tile_width_compat)
+ ADD_A_REG16 h, l
+
+ ld bc, #0x40
+ add ix, bc
+ ld a, ixh
+ cp #>(.VDP_TILEMAP+0x0700)
+ jp c, 4$
+ ld ixh, #>.VDP_TILEMAP
+4$:
+ push ix
+ jp 1$
+6$:
+ ENABLE_VBLANK_COPY ; switch ON copy shadow SAT
+ pop ix ; restore IX
+ ret
diff --git a/gbdk/gbdk-lib/libc/targets/z80/sms/Makefile b/gbdk/gbdk-lib/libc/targets/z80/sms/Makefile
new file mode 100644
index 00000000..34074067
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/sms/Makefile
@@ -0,0 +1,44 @@
+# GB specific Makefile
+
+TOPDIR = ../../../..
+
+THIS = sms
+PORT = z80
+
+CSRC = crlf.c
+
+ASSRC = set_interrupts.s \
+ outi.s vmemcpy.s \
+ sms_refresh_oam.s \
+ sms_set_native_data.s sms_set_1bpp_data.s sms_set_2bpp_data.s \
+ set_tile_map.s set_tile_map_xy.s set_tile_map_compat.s set_tile_map_xy_compat.s \
+ set_tile_submap.s set_tile_submap_compat.s \
+ coords_to_address.s \
+ set_tile.s \
+ sms_fill_rect.s sms_fill_rect_xy.s sms_fill_rect_compat.s sms_fill_rect_xy_compat.s \
+ sms_metasprites.s sms_metasprites_hide.s sms_metasprites_hide_spr.s \
+ f_ibm_full.s f_ibm_sh.s f_italic.s f_min.s f_spect.s \
+ font.s color.s \
+ putchar.s \
+ scroll.s cls.s gotoxy.s \
+ palette.s set_palette.s \
+ pad.s pad_ex.s \
+ sms_int.s nmi.s \
+ mode.s clock.s \
+ delay.s \
+ emu_debug_printf.s \
+ memset_small.s \
+ far_ptr.s \
+ gb_decompress.s \
+ rle_decompress.s \
+ heap.s \
+ __sdcc_bcall.s \
+ crt0.s
+
+CRT0 = crt0.s
+
+include $(TOPDIR)/Makefile.common
+
+AS = $(AS_Z80)
+
+include ../../../Makefile.platform
diff --git a/gbdk/gbdk-lib/libc/targets/z80/sms/__sdcc_bcall.s b/gbdk/gbdk-lib/libc/targets/z80/sms/__sdcc_bcall.s
new file mode 100644
index 00000000..60ebd504
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/sms/__sdcc_bcall.s
@@ -0,0 +1,68 @@
+ .include "global.s"
+
+ .area _CODE
+
+ .globl ___sdcc_bcall
+ .globl ___sdcc_bcall_abc
+ .globl ___sdcc_bcall_ehl
+;
+; trampoline to call banked functions
+; used when legacy banking is enabled only
+; Usage:
+; call ___sdcc_bcall
+; .dw <function>
+; .dw <function_bank>
+;
+___sdcc_bcall::
+ ex (sp), hl
+ ld c, (hl)
+ inc hl
+ ld b, (hl)
+ inc hl
+ ld a, (hl)
+ inc hl
+ inc hl
+ ex (sp), hl
+;
+; trampoline to call banked functions with __z88dk_fastcall calling convention
+; Usage:
+; ld a, #<function_bank>
+; ld bc, #<function>
+; call ___sdcc_bcall_abc
+;
+___sdcc_bcall_abc::
+ push hl
+ ld l, a
+ ld a, (#.MAP_FRAME1)
+ ld h, a
+ ld a, l
+ ld (#.MAP_FRAME1), a
+ ex (sp), hl
+ inc sp
+ call ___sdcc_bjump_abc
+ dec sp
+ pop af
+ ld (#.MAP_FRAME1), a
+ ret
+;
+___sdcc_bjump_abc:
+ push bc
+ ret
+;
+; default trampoline to call banked functions
+; Usage:
+; ld e, #<function_bank>
+; ld hl, #<function>
+; call ___sdcc_bcall_ehl
+;
+___sdcc_bcall_ehl::
+ ld a, (#.MAP_FRAME1)
+ push af
+ inc sp
+ ld a, e
+ ld (#.MAP_FRAME1), a
+ CALL_HL
+ dec sp
+ pop af
+ ld (#.MAP_FRAME1), a
+ ret
diff --git a/gbdk/gbdk-lib/libc/targets/z80/sms/crlf.c b/gbdk/gbdk-lib/libc/targets/z80/sms/crlf.c
new file mode 100644
index 00000000..aca6ec82
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/sms/crlf.c
@@ -0,0 +1 @@
+const char * const __crlf = "\n"; \ No newline at end of file
diff --git a/gbdk/gbdk-lib/libc/targets/z80/sms/crt0.s b/gbdk/gbdk-lib/libc/targets/z80/sms/crt0.s
new file mode 100644
index 00000000..55823330
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/sms/crt0.s
@@ -0,0 +1,275 @@
+ .include "global.s"
+
+ .title "Runtime"
+ .module Runtime
+ .area _HEADER (ABS)
+
+ .globl _set_default_palette
+
+ .org 0x00 ; Reset 00h
+ di ; disable interrupt
+ im 1 ; interrupt mode 1 (this won't change)
+ jp .init
+
+; .org 0x08 ; --profile handler
+
+ .org 0x10 ; RST 0x10: VDP_WRITE_CMD
+
+_WRITE_VDP_CMD::
+ VDP_WRITE_CMD h, l
+ ret
+
+; .org 0x18 ; unusable
+
+ .org 0x20 ; RST 0x20: VDP_WRITE_DATA
+
+_WRITE_VDP_DATA::
+ VDP_WRITE_DATA h, l
+ ret
+
+; .org 0x28 ; unusable
+
+ .org 0x30 ; RST 0x30: call HL
+.call_hl::
+ jp (HL)
+
+ .org 0x38 ; handle IRQ
+ jp _INT_ISR
+
+ .org 0x66 ; handle NMI
+ jp _NMI_ISR
+
+ .org 0x80
+
+.init::
+ ld sp, #.STACK ; set stack pointer at end of RAM
+
+ ld a, (#.BIOS)
+ push af
+
+ xor a
+ ld bc, #l__DATA
+ ld hl, #s__DATA
+ call .memset_simple ; initialize veriables in RAM with zero
+
+ pop af
+ ld (#__BIOS), a ; save BIOS value
+
+ ld hl, #_shadow_OAM
+ ld de, #(_shadow_OAM + 1)
+ ld bc, #64
+ ld (hl), #0xc0
+ ldir
+ ld (hl), #0
+ ld bc, #(128 - 1)
+ ldir
+
+ ld hl,#0x0000 ; initialize mappers
+ ld (#.RAM_CONTROL),hl ; [.RAM_CONTROL]=$00, [.MAP_FRAME0]=$00
+ ld hl,#0x0201
+ ld (#.MAP_FRAME1),hl ; [.MAP_FRAME1]=$01, [.MAP_FRAME2]=$02
+
+ ;; Initialise global variables
+ call .gsinit
+
+ ;; Initialize VDP
+ ld c, #.VDP_CMD
+ ld b, #(.shadow_VDP_end - .shadow_VDP)
+ ld hl,#(.shadow_VDP_end - 1)
+1$:
+ outd
+
+ ld a, b
+ or #.VDP_REG_MASK
+ out (c), a
+
+ ld a, b
+ or a
+ jr nz, 1$
+
+ ;; detect PAL/NTSC
+ ld c, #.VDP_VCOUNTER
+2$: in a, (c)
+ cp #0x80
+ jr nz, 2$
+3$: ld b, a
+ in a, (c)
+ cp b
+ jr nc, 3$
+
+ ld a, b
+ cp #0xE8
+ ld a, #.SYSTEM_NTSC
+ jr c, 4$
+ ld a, #.SYSTEM_PAL
+4$:
+ ld (#__SYSTEM), a
+
+ call .clear_VRAM
+
+ call _set_default_palette
+
+ VDP_CANCEL_INT
+
+ ei ; re-enable interrupts before going to main()
+ call _main
+10$:
+ halt
+ jr 10$
+
+ ;; Ordering of segments for the linker.
+ .area _HOME
+ .area _BASE
+ .area _CODE
+ .area _CODE_0
+ .area _LIT
+ .area _INITIALIZER
+ .area _GSINIT
+ .area _GSFINAL
+
+ .area _DATA
+ .area _INITIALIZED
+ .area _BSEG
+ .area _BSS
+ .area _HEAP
+ .area _HEAP_END
+
+ .area _CODE
+ .area _GSINIT
+.gsinit::
+ ;; initialize static storage variables
+ ld bc, #l__INITIALIZER
+ ld hl, #s__INITIALIZER
+ ld de, #s__INITIALIZED
+ call .memcpy_simple
+
+ .area _GSFINAL
+ ret
+
+ .area _HOME
+
+.clear_VRAM:
+ ld a, #<.VDP_VRAM
+ out (#.VDP_CMD), a
+ ld a, #>.VDP_VRAM
+ out (#.VDP_CMD), a
+ xor a
+ ld bc, #0x4101
+ jr 6$
+5$:
+ out (.VDP_DATA), a
+6$:
+ dec c
+ jr nz, 5$
+ dec b
+ jr nz, 5$
+ ret
+
+ ;; fills memory at HL of length BC with A, clobbers DE
+.memset_simple::
+ ld e, a
+ ld a, c
+ or b
+ ret z
+ ld (hl), e
+ dec bc
+ ld d, h
+ ld e, l
+ inc de
+
+ ;; copies BC bytes from HL into DE
+.memcpy_simple::
+ ld a, c
+ or b
+ ret z
+ ldir
+ ret
+
+ ;; Wait for VBL interrupt to be finished
+.wait_vbl_done::
+_wait_vbl_done::
+ ld a, (_shadow_VDP_R1)
+ and #.R1_DISP_ON
+ ret z
+
+ xor a
+ ld (.vbl_done), a
+1$:
+ halt
+ ld a, (.vbl_done)
+ or a
+ jr z, 1$
+ ret
+
+ .area _DATA
+
+.start_crt_globals:
+__BIOS::
+ .ds 0x01 ; GB type (GB, PGB, CGB)
+__SYSTEM::
+ .ds 0x01 ; PAL/NTSC
+.end_crt_globals:
+
+ .area _INITIALIZED
+.shadow_VDP:
+_shadow_VDP_R0::
+ .ds 0x01
+_shadow_VDP_R1::
+ .ds 0x01
+_shadow_VDP_R2::
+ .ds 0x01
+_shadow_VDP_R3::
+ .ds 0x01
+_shadow_VDP_R4::
+ .ds 0x01
+_shadow_VDP_R5::
+ .ds 0x01
+_shadow_VDP_R6::
+ .ds 0x01
+_shadow_VDP_R7::
+_shadow_VDP_RBORDER::
+ .ds 0x01
+_shadow_VDP_R8::
+_shadow_VDP_RSCX::
+ .ds 0x01
+_shadow_VDP_R9::
+_shadow_VDP_RSCY::
+ .ds 0x01
+_shadow_VDP_R10::
+ .ds 0x01
+.shadow_VDP_end::
+
+.sys_time::
+_sys_time::
+ .ds 0x02
+.vbl_done::
+ .ds 0x01
+_VDP_ATTR_SHIFT::
+.vdp_shift::
+ .ds 0x01
+__shadow_OAM_base::
+ .ds 0x01
+__shadow_OAM_OFF::
+ .ds 0x01
+.mode::
+ .ds 0x01 ; Current mode
+
+ .area _INITIALIZER
+
+ .db .R0_DEFAULT
+ .db #(.R1_DEFAULT | .R1_DISP_ON | .R1_IE) ; VBLANK
+ .db .R2_MAP_0x3800
+ .db 0xFF
+ .db 0xFF
+ .db .R5_SAT_0x3F00
+ .db .R6_DATA_0x2000
+ .db #(0 | .R7_COLOR_MASK)
+ .db 0 ; SCX
+ .db 0 ; SCY
+ .db .R10_INT_OFF
+ .dw 0x0000 ; .sys_time
+ .db 0 ; .vbl_done
+ .db 0 ; _VDP_ATTR_SHIFT
+ .db #>_shadow_OAM ; __shadow_OAM_base
+ .db 0 ; __shadow_OAM_OFF
+ .db .T_MODE_INOUT ; .mode \ No newline at end of file
diff --git a/gbdk/gbdk-lib/libc/targets/z80/sms/global.s b/gbdk/gbdk-lib/libc/targets/z80/sms/global.s
new file mode 100644
index 00000000..e4b09bcc
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/sms/global.s
@@ -0,0 +1,310 @@
+ .MEMORY_CTL = 0x3E
+
+ .MEMCTL_JOYON = 0b00000000
+ .MEMCTL_JOYOFF = 0b00000100
+ .MEMCTL_BASEON = 0b00000000
+ .MEMCTL_BASEOFF = 0b00001000
+ .MEMCTL_RAMON = 0b00000000
+ .MEMCTL_RAMOFF = 0b00010000
+ .MEMCTL_CROMON = 0b00000000
+ .MEMCTL_CROMOFF = 0b00100000
+ .MEMCTL_ROMON = 0b00000000
+ .MEMCTL_ROMOFF = 0b01000000
+ .MEMCTL_EXTON = 0b00000000
+ .MEMCTL_EXTOFF = 0b10000000
+
+ .JOY_CTL = 0x3F
+
+ .JOY_P1_LATCH = 0b00000010
+ .JOY_P2_LATCH = 0b00001000
+
+ .VDP_VRAM = 0x4000
+ .VDP_TILEMAP = 0x7800
+ .VDP_CRAM = 0xC000
+ .VDP_SAT = 0x7F00
+
+ .VDP_SAT_TERM = 0xD0
+
+ .VDP_VCOUNTER = 0x7E
+ .VDP_PSG = 0x7F
+ .VDP_HCOUNTER = 0x7F
+
+ .VDP_DATA = 0xBE
+ .VDP_CMD = 0xBF
+ .VDP_STAT = 0xBF
+
+ .STATF_INT_VBL = 0b10000000
+ .STATF_9_SPR = 0b01000000
+ .STATF_SPR_COLL = 0b00100000
+
+ .VDP_REG_MASK = 0b10000000
+ .VDP_R0 = 0b10000000
+
+ .R0_VSCRL = 0b00000000
+ .R0_VSCRL_INH = 0b10000000
+ .R0_HSCRL = 0b00000000
+ .R0_HSCRL_INH = 0b01000000
+ .R0_NO_LCB = 0b00000000
+ .R0_LCB = 0b00100000
+ .R0_IE1_OFF = 0b00000000
+ .R0_IE1 = 0b00010000
+ .R0_SS_OFF = 0b00000000
+ .R0_SS = 0b00001000
+ .R0_DEFAULT = 0b00000110
+ .R0_ES_OFF = 0b00000000
+ .R0_ES = 0b00000001
+
+ .VDP_R1 = 0b10000001
+
+ .R1_DEFAULT = 0b10000000
+ .R1_DISP_OFF = 0b00000000
+ .R1_DISP_ON = 0b01000000
+ .R1_IE_OFF = 0b00000000
+ .R1_IE = 0b00100000
+ .R1_SPR_8X8 = 0b00000000
+ .R1_SPR_8X16 = 0b00000010
+
+ .VDP_R2 = 0b10000010
+
+ .R2_MAP_0x3800 = 0xFF
+ .R2_MAP_0x3000 = 0xFD
+ .R2_MAP_0x2800 = 0xFB
+ .R2_MAP_0x2000 = 0xF9
+ .R2_MAP_0x1800 = 0xF7
+ .R2_MAP_0x1000 = 0xF5
+ .R2_MAP_0x0800 = 0xF3
+ .R2_MAP_0x0000 = 0xF1
+
+ .VDP_R3 = 0b10000011
+ .VDP_R4 = 0b10000100
+ .VDP_R5 = 0b10000101
+
+ .R5_SAT_0x3F00 = 0xFF
+ .R5_SAT_MASK = 0b10000001
+
+ .VDP_R6 = 0b10000110
+
+ .R6_BANK0 = 0xFB
+ .R6_DATA_0x0000 = 0xFB
+ .R6_BANK1 = 0xFF
+ .R6_DATA_0x2000 = 0xFF
+
+ .VDP_R7 = 0b10000111
+ .VDP_RBORDER = 0b10000111
+
+ .R7_COLOR_MASK = 0b11110000
+
+ .VDP_R8 = 0b10001000
+ .VDP_RSCX = 0b10001000
+
+ .VDP_R9 = 0b10001001
+ .VDP_RSCY = 0b10001001
+
+ .VDP_R10 = 0b10001010
+
+ .R10_INT_OFF = 0xFF
+ .R10_INT_EVERY = 0x00
+
+ .UP = 0b00000001
+ .DOWN = 0b00000010
+ .LEFT = 0b00000100
+ .RIGHT = 0b00001000
+ .A = 0b00010000
+ .B = 0b00100000
+ .SELECT = 0b00100000 ; map to B
+ .START = 0b00010000 ; map to A
+
+ .JOYPAD_COUNT = 2
+
+ .JOY_PORT1 = 0xDC
+
+ .JOY_P1_UP = 0b00000001
+ .JOY_P1_DOWN = 0b00000010
+ .JOY_P1_LEFT = 0b00000100
+ .JOY_P1_RIGHT = 0b00001000
+ .JOY_P1_SW1 = 0b00010000
+ .JOY_P1_TRIGGER = 0b00010000
+ .JOY_P1_SW2 = 0b00100000
+ .JOY_P2_UP = 0b01000000
+ .JOY_P2_DOWN = 0b10000000
+
+ .JOY_PORT2 = 0xDD
+
+ .JOY_P2_LEFT = 0b00000001
+ .JOY_P2_RIGHT = 0b00000010
+ .JOY_P2_SW1 = 0b00000100
+ .JOY_P2_TRIGGER = 0b00000100
+ .JOY_P2_SW2 = 0b00001000
+ .JOY_RESET = 0b00010000
+ .JOY_P1_LIGHT = 0b01000000
+ .JOY_P2_LIGHT = 0b10000000
+
+ .FMADDRESS = 0xF0
+ .FMDATA = 0xF1
+ .AUDIOCTRL = 0xF2
+
+ .RAM_CONTROL = 0xfffc
+
+ .RAMCTL_BANK = 0b00000100
+ .RAMCTL_ROM = 0b00000000
+ .RAMCTL_RAM = 0b00001000
+ .RAMCTL_RO = 0b00010000
+ .RAMCTL_PROT = 0b10000000
+
+ .GLASSES_3D = 0xfff8
+
+ .MAP_FRAME0 = 0xfffd
+ .MAP_FRAME1 = 0xfffe
+ .MAP_FRAME2 = 0xffff
+
+ .BIOS = 0xC000
+
+ .SYSTEM_PAL = 0x00
+ .SYSTEM_NTSC = 0x01
+
+ .CPU_CLOCK = 3579545
+
+ ;; GBDK library screen modes
+
+ .T_MODE = 0x02 ; Text mode (bit 2)
+ .T_MODE_OUT = 0x02 ; Text mode output only
+ .T_MODE_INOUT = 0x03 ; Text mode with input
+ .M_NO_SCROLL = 0x04 ; Disables scrolling of the screen in text mode
+ .M_NO_INTERP = 0x08 ; Disables special character interpretation
+
+ ;; Screen dimentions in tiles
+
+ .SCREEN_X_OFS = 0
+ .SCREEN_Y_OFS = 0
+ .SCREEN_WIDTH = 32
+ .SCREEN_HEIGHT = 24
+ .VDP_MAP_HEIGHT = 28
+ .VDP_MAP_WIDTH = 32
+
+ ;; Interrupt flags
+
+ .VBL_IFLAG = 0x01
+ .LCD_IFLAG = 0x02
+
+ ; characters
+ .CR = 0x0A
+ .SPACE = 0x00
+
+ ;; Global variables
+ .globl .mode
+
+ ;; Interrupt routines
+ .globl _INT_ISR
+ .globl _NMI_ISR
+
+ ;; Symbols defined at link time
+ .globl .STACK
+ .globl _shadow_OAM
+ .globl __shadow_OAM_OFF
+
+ ;; Main user routine
+ .globl _main
+
+ ;; Macro definitions
+
+.macro VDP_WRITE_DATA regH regL ?lbl
+ ld a, i
+ ld a, regL
+ di
+ out (#.VDP_DATA), a ; 11
+ ld a, regH ; 4
+ jp po, lbl ; 7/12
+ ei ; 4 (total: 26/27)
+lbl:
+ out (#.VDP_DATA), a
+.endm
+
+.macro VDP_WRITE_CMD regH regL ?lbl
+ ld a, i
+ ld a, regL
+ di
+ out (#.VDP_CMD), a
+ ld a, regH
+ jp po, lbl
+ ei
+lbl:
+ out (#.VDP_CMD), a
+.endm
+
+.macro VDP_DELAY ?lbl
+ nop
+ jr lbl
+lbl:
+.endm
+
+.macro VDP_CANCEL_INT
+ in a, (.VDP_STAT) ; cancel pending VDP interrupts
+.endm
+
+.macro WRITE_VDP_CMD_HL
+ rst 0x10
+.endm
+
+.macro WRITE_VDP_DATA_HL
+ rst 0x20
+.endm
+
+.macro CALL_HL
+ rst 0x30
+.endm
+
+.macro DISABLE_VBLANK_COPY
+ ld a, #1
+ ld (__shadow_OAM_OFF), a
+.endm
+
+.macro ENABLE_VBLANK_COPY
+ xor a
+ ld (__shadow_OAM_OFF), a
+.endm
+
+.macro ADD_A_REG16 regH regL
+ add regL
+ ld regL, a
+ adc regH
+ sub regL
+ ld regH, a
+.endm
+
+.macro MUL_DE_BY_A_RET_HL ?lbl1 ?lbl2
+ ; Multiply DE by A, return result in HL; preserves: BC
+ ld hl, #0
+lbl1:
+ srl a
+ jp nc, lbl2
+ add hl, de
+lbl2:
+ sla e
+ rl d
+ or a
+ jp nz, lbl1
+.endm
+
+.macro DIV_PART divident divisor ?lbl
+ rl divident
+ rla
+ sub divisor
+ jr nc, lbl
+ add divisor
+lbl:
+.endm
+.macro FAST_DIV8 divident divisor
+ ; returns modulus in A
+ .rept 8
+ DIV_PART divident divisor
+ .endm
+ ld a, divident
+ cpl
+.endm
+.macro FAST_MOD8 divident divisor
+ ; returns modulus in A
+ .rept 8
+ DIV_PART divident divisor
+ .endm
+.endm
+
diff --git a/gbdk/gbdk-lib/libc/targets/z80/sms/nmi.s b/gbdk/gbdk-lib/libc/targets/z80/sms/nmi.s
new file mode 100644
index 00000000..d61b5ded
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/sms/nmi.s
@@ -0,0 +1,8 @@
+ .include "global.s"
+
+ .title "NMI Handler"
+ .module NMIHandler
+ .area _HOME
+
+_NMI_ISR::
+ retn \ No newline at end of file
diff --git a/gbdk/gbdk-lib/libc/targets/z80/sms/pad.s b/gbdk/gbdk-lib/libc/targets/z80/sms/pad.s
new file mode 100644
index 00000000..579bae79
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/sms/pad.s
@@ -0,0 +1,38 @@
+ .include "global.s"
+
+ .title "JOYPad utilities"
+ .module JOYPad
+ .area _HOME
+
+ ;; Get Keypad Button Status
+_joypad::
+.jpad::
+ in a, (.JOY_PORT1)
+ cpl
+ and #0b00111111
+ ld l, a
+ ret
+
+ ;; Wait until all buttons have been released
+.padup::
+_waitpadup::
+1$:
+ ld h,#0x7f ; wait for .jpad return zero 127 times in a row
+2$:
+ call .jpad
+ or a ; have all buttons been released?
+ jr nz,1$ ; not yet
+
+ dec h
+ jr nz,2$
+
+ ret
+
+ ;; Wait for the key to be pressed
+_waitpad::
+.wait_pad::
+1$:
+ call .jpad ; read pad
+ and l ; compare with mask?
+ jr z,1$ ; loop if no intersection
+ ret
diff --git a/gbdk/gbdk-lib/libc/targets/z80/sms/pad_ex.s b/gbdk/gbdk-lib/libc/targets/z80/sms/pad_ex.s
new file mode 100644
index 00000000..0d864360
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/sms/pad_ex.s
@@ -0,0 +1,71 @@
+ .include "global.s"
+
+ .title "JOYPad utilities"
+ .module JOYPad
+ .area _HOME
+
+; uint8_t joypad_init(uint8_t npads, joypads_t * joypads) __z88dk_callee;
+_joypad_init::
+ ld hl, #2
+ add hl, sp
+ ld a, (hl)
+ or a
+ jr nz, 1$
+ ld a, #1
+ jr 2$
+1$:
+ cp #(.JOYPAD_COUNT + 1)
+ jr c, 2$
+ ld a, #.JOYPAD_COUNT
+2$:
+ inc hl
+ ld e, (hl)
+ inc hl
+ ld d, (hl)
+
+ inc hl
+ pop bc ; pop return address
+ ld sp, hl ; dispose params
+ push bc ; push return address back
+
+ ld (de), a ; number of joypads
+ ld l, a ; return number of joypads in l
+ xor a
+ inc de
+ ld (de), a
+ inc de
+ ld (de), a
+ inc de
+ ld (de), a
+ inc de
+ ld (de), a
+
+ ret
+
+;void joypad_ex(joypads_t * joypads) __z88dk_fastcall;
+
+_joypad_ex::
+ ld c, #.JOY_PORT1
+ in e, (c)
+ inc c
+ in d, (c)
+ ld a, e
+ rla
+ rl d
+ rla
+ rl d
+ ld a, e
+ cpl
+ and #0b00111111
+ ld e, a
+ ld a, d
+ cpl
+ and #0b01111111
+ ld d, a
+
+ inc hl
+ ld (hl), e
+ inc hl
+ ld (hl), d
+
+ ret \ No newline at end of file
diff --git a/gbdk/gbdk-lib/libc/targets/z80/sms/palette.s b/gbdk/gbdk-lib/libc/targets/z80/sms/palette.s
new file mode 100644
index 00000000..1e0a791d
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/sms/palette.s
@@ -0,0 +1,103 @@
+ ;; SMS palette routines
+
+ .include "global.s"
+
+ .title "CRAM SMS Palettes"
+ .module CRAMUtils
+ .area _HOME
+
+; void set_palette_entry(uint8_t palette, uint8_t entry, uint16_t rgb_data) __z88dk_callee;
+_set_palette_entry::
+ pop de
+ pop bc
+ ld hl, #.VDP_CRAM
+ bit 0, c
+ jr z, 1$
+ set 4, b
+1$:
+ ld c, b
+ ld b, #0
+ add hl, bc
+ pop bc
+
+ ld a, i
+ di
+ ld a, l
+ out (#.VDP_CMD), a
+ ld a, h
+ out (#.VDP_CMD), a
+ ld a, c
+ jp po, 2$
+ ei
+2$:
+ out (#.VDP_DATA), a
+
+ ld h, d
+ ld l, e
+ jp (hl)
+
+; void set_palette(uint8_t first_palette, uint8_t nb_palettes, uint16_t *rgb_data) __z88dk_callee;
+_set_palette::
+ pop de
+ pop bc
+ ld hl, #.VDP_CRAM
+ bit 0, c
+ ld a, b
+ ld bc, #0
+ jr z, 1$
+ ld c, #0x10
+1$:
+ add hl, bc
+
+ ld c, a
+
+ DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT
+
+ ld a, i
+ di
+ ld a, l
+ out (#.VDP_CMD), a
+ ld a, h
+ out (#.VDP_CMD), a
+ jp po, 2$
+ ei
+2$:
+ ld a, c
+ or a
+ jr z, 3$
+
+ pop hl
+ ld c, #.VDP_DATA
+5$:
+ ld b, #0x10
+4$:
+ outi
+ jr nz, 4$
+
+ dec a
+ jr nz, 5$
+3$:
+ ENABLE_VBLANK_COPY ; switch ON copy shadow SAT
+
+ ld h, d
+ ld l, e
+ jp (hl)
+
+.CRT_DEFAULT_PALETTE::
+ .db 0b00111111
+ .db 0b00101010
+ .db 0b00010101
+ .db 0b00000000
+ .db 0b00000010
+ .db 0b00001000
+ .db 0b00100000
+ .db 0b00001010
+ .db 0b00101000
+ .db 0b00100010
+ .db 0b00000011
+ .db 0b00001100
+ .db 0b00110000
+ .db 0b00001111
+ .db 0b00111100
+ .db 0b00110011
+
diff --git a/gbdk/gbdk-lib/libc/targets/z80/sms_fill_rect.s b/gbdk/gbdk-lib/libc/targets/z80/sms_fill_rect.s
new file mode 100644
index 00000000..3eeb48ca
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/sms_fill_rect.s
@@ -0,0 +1,30 @@
+ .include "global.s"
+
+ .globl .fill_rect_xy
+
+ .area _HOME
+
+; void fill_rect(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint16_t tile) __z88dk_callee __preserves_regs(iyh, iyl);
+_fill_rect::
+ pop hl ; HL = ret
+ pop bc ; BC = YX
+ pop de ; DE = WH
+ ex (sp), hl ; HL = data
+ ex de, hl ; HL = WH, DE = data
+
+ ld a, b
+ ld b, d
+
+ add #.SCREEN_Y_OFS
+ ld d, a
+ xor a
+ FAST_MOD8 d #28
+ ld d, a
+
+ ld a, c
+ add #.SCREEN_X_OFS
+ and #0x1f
+ ld c, e
+ ld e, a ; BC = data, DE = YX
+
+ jp .fill_rect_xy
diff --git a/gbdk/gbdk-lib/libc/targets/z80/sms_fill_rect_compat.s b/gbdk/gbdk-lib/libc/targets/z80/sms_fill_rect_compat.s
new file mode 100644
index 00000000..e6e8dba4
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/sms_fill_rect_compat.s
@@ -0,0 +1,30 @@
+ .include "global.s"
+
+ .globl .set_tile_map_xy
+
+ .area _HOME
+
+; void fill_rect_compat(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint16_t tile) __z88dk_callee __preserves_regs(iyh, iyl);
+_fill_rect_compat::
+ pop hl ; HL = ret
+ pop bc ; BC = YX
+ pop de ; DE = WH
+ ex (sp), hl ; HL = data
+ ex de, hl ; HL = WH, DE = data
+
+ ld a, b
+ ld b, d
+
+ add #.SCREEN_Y_OFS
+ ld d, a
+ xor a
+ FAST_MOD8 d #28
+ ld d, a
+
+ ld a, c
+ add #.SCREEN_X_OFS
+ and #0x1f
+ ld c, e
+ ld e, a ; BC = data, DE = YX
+
+ jp .fill_rect_xy_compat
diff --git a/gbdk/gbdk-lib/libc/targets/z80/sms_fill_rect_xy.s b/gbdk/gbdk-lib/libc/targets/z80/sms_fill_rect_xy.s
new file mode 100644
index 00000000..02325cbe
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/sms_fill_rect_xy.s
@@ -0,0 +1,98 @@
+ .include "global.s"
+
+ .title "VRAM utilities"
+ .module VRAMUtils
+
+ .ez80
+
+ .area _HOME
+
+ ;; Set background tile table from (BC) at XY = DE of size WH = HL
+.fill_rect_xy::
+ push hl
+ ld hl, #.VDP_TILEMAP
+
+ ;; Set background tile from (BC) at YX = DE, size WH on stack, to VRAM from address (HL)
+.fill_rect_xy_tt::
+ push bc ; Store source
+
+ ld a, d
+ rrca ; rrca(2) == rlca(6)
+ rrca
+ ld d, a
+ and #0x07
+ add h
+ ld b, a
+ ld a, #0xC0
+ and d
+ sla e
+ add e
+ ld c, a ; dest BC = HL + ((0x20 * Y) * 2) + (X * 2)
+
+ ld a, b
+ cp #>(.VDP_TILEMAP+0x0700)
+ jr c, 5$
+ ld b, #>.VDP_TILEMAP
+5$:
+ pop hl ; HL = source
+ pop de ; DE = HW
+ push ix ; save IX
+ push de ; store HW
+
+ ld ixh, b
+ ld ixl, c
+ push ix ; store dest
+
+ DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT
+
+1$: ; copy H rows
+ VDP_WRITE_CMD ixh, ixl
+ ld c, #.VDP_DATA
+2$: ; copy W tiles
+ out (c), l
+ VDP_DELAY
+ out (c), h
+
+ ld a, ixl
+ and #0x3F
+ inc a
+ inc a
+ bit 6, a
+ jp z, 3$
+ and #0x3F
+ ld b, a
+ ld a, ixl
+ and #0xC0
+ or b
+ ld ixl, a
+ VDP_WRITE_CMD ixh, ixl
+ dec e
+ jp nz, 2$
+ jp 7$
+3$:
+ inc ixl
+ inc ixl
+ dec e
+ jp nz, 2$
+7$:
+ pop ix
+ pop de
+
+ dec d
+ jr z, 6$
+
+ push de
+
+ ld bc, #0x40
+ add ix, bc
+ ld a, ixh
+ cp #>(.VDP_TILEMAP+0x0700)
+ jp c, 4$
+ ld ixh, #>.VDP_TILEMAP
+4$:
+ push ix
+ jp 1$
+6$:
+ ENABLE_VBLANK_COPY ; switch ON copy shadow SAT
+ pop ix ; restore IX
+ ret \ No newline at end of file
diff --git a/gbdk/gbdk-lib/libc/targets/z80/sms_fill_rect_xy_compat.s b/gbdk/gbdk-lib/libc/targets/z80/sms_fill_rect_xy_compat.s
new file mode 100644
index 00000000..7183ff9d
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/sms_fill_rect_xy_compat.s
@@ -0,0 +1,101 @@
+ .include "global.s"
+
+ .globl .vdp_shift
+
+ .title "VRAM utilities"
+ .module VRAMUtils
+
+ .ez80
+
+ .area _HOME
+
+ ;; Set background tile table from (BC) at XY = DE of size WH = HL
+.fill_rect_xy_compat::
+ push hl
+ ld hl, #.VDP_TILEMAP
+
+ ;; Set background tile from (BC) at YX = DE, size WH on stack, to VRAM from address (HL)
+.fill_rect_xy_tt_compat::
+ push bc ; Store source
+
+ ld a, d
+ rrca ; rrca(2) == rlca(6)
+ rrca
+ ld d, a
+ and #0x07
+ add h
+ ld b, a
+ ld a, #0xC0
+ and d
+ sla e
+ add e
+ ld hl, #.vdp_shift
+ add (hl)
+ ld c, a ; dest BC = HL + ((0x20 * Y) * 2) + (X * 2)
+
+ ld a, b
+ cp #>(.VDP_TILEMAP+0x0700)
+ jr c, 5$
+ ld b, #>.VDP_TILEMAP
+5$:
+ pop hl ; HL = source
+ pop de ; DE = HW
+ push ix ; save IX
+ push de ; store HW
+ ld ixh, b
+ ld ixl, c
+ push ix ; store dest
+
+ DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT
+
+1$: ; copy H rows
+ VDP_WRITE_CMD ixh, ixl
+ ld c, #.VDP_DATA
+2$: ; copy W tiles
+ out (c), l
+ VDP_DELAY
+ in a, (c) ; skip next byte
+
+ ld a, ixl
+ and #0x3F
+ inc a
+ inc a
+ bit 6, a
+ jp z, 3$
+ and #0x3F
+ ld b, a
+ ld a, ixl
+ and #0xC0
+ or b
+ ld ixl, a
+ VDP_WRITE_CMD ixh, ixl
+ dec e
+ jp nz, 2$
+ jp 7$
+3$:
+ inc ixl
+ inc ixl
+ dec e
+ jp nz, 2$
+7$:
+ pop ix
+ pop de
+
+ dec d
+ jr z, 6$
+
+ push de
+
+ ld bc, #0x40
+ add ix, bc
+ ld a, ixh
+ cp #>(.VDP_TILEMAP+0x0700)
+ jp c, 4$
+ ld ixh, #>.VDP_TILEMAP
+4$:
+ push ix
+ jp 1$
+6$:
+ ENABLE_VBLANK_COPY ; switch ON copy shadow SAT
+ pop ix ; restore IX
+ ret \ No newline at end of file
diff --git a/gbdk/gbdk-lib/libc/targets/z80/sms_int.s b/gbdk/gbdk-lib/libc/targets/z80/sms_int.s
new file mode 100644
index 00000000..3de09db0
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/sms_int.s
@@ -0,0 +1,197 @@
+ .include "global.s"
+
+ .title "INT Handler"
+ .module INTHandler
+
+ .globl .sys_time, .vbl_done
+ .globl .OUTI128, .OUTI64, __shadow_OAM_base
+
+ .area _HOME
+
+_INT_ISR::
+ push af
+ push bc
+ push de
+ push hl
+ push iy
+ push ix
+
+ in a, (.VDP_STAT)
+ and #.STATF_INT_VBL
+ jp z, 2$
+ ;; handle VBlank
+
+ ld hl, (.sys_time)
+ inc hl
+ ld (.sys_time), hl
+
+ ld a, #1
+ ld (.vbl_done), a
+
+ ;; transfer shadow OAM
+ ld a, (__shadow_OAM_OFF) ; check transfer is OFF
+ or a
+ jp nz, 1$
+ ld hl, #__shadow_OAM_base
+ ld h, (hl)
+ ld l, a ; a == 0 here
+ or h
+ jp z, 1$
+
+ ld c, #.VDP_CMD
+ ld a, #<.VDP_SAT
+ out (c), a
+ ld a, #>.VDP_SAT
+ out (c), a
+ dec c ; c == .VDP_DATA
+ call .OUTI64
+ inc c ; c == .VDP_CMD
+ ld a, #<(.VDP_SAT + 0x80)
+ out (c), a
+ ld a, #>(.VDP_SAT + 0x80)
+ out (c), a
+ dec c ; c == .VDP_DATA
+ call .OUTI128
+1$:
+
+ ;; call user-defined VBlank handlers
+ ld hl, (.VBLANK_HANDLER0)
+ ld a, h
+ or l
+ jp z, 3$
+ CALL_HL
+
+ ld hl, (.VBLANK_HANDLER1)
+ ld a, h
+ or l
+ jp z, 3$
+ CALL_HL
+
+ ld hl, (.VBLANK_HANDLER2)
+ ld a, h
+ or l
+ jp z, 3$
+ CALL_HL
+ jp 3$
+
+ ;; handle HBlank
+2$:
+ ld hl, (.HBLANK_HANDLER0)
+ CALL_HL
+
+3$:
+ pop ix
+ pop iy
+ pop hl
+ pop de
+ pop bc
+ pop af
+ ei
+ reti
+
+; void remove_LCD (int_handler h) __z88dk_fastcall __preserves_regs(b, c, iyh, iyl);
+_remove_LCD::
+.remove_LCD::
+ ld hl, #.empty_function
+
+; void add_LCD (int_handler h) __z88dk_fastcall __preserves_regs(b, c, iyh, iyl);
+_add_LCD::
+.add_LCD::
+ ld (.HBLANK_HANDLER0), hl
+ ret
+
+; void add_VBL(int_handler h) __z88dk_fastcall __preserves_regs(d, e, iyh, iyl);
+_add_VBL::
+ ld b, h
+ ld c, l
+
+.add_VBL::
+ ld hl, #.VBLANK_HANDLER0
+
+ ;; Add interrupt routine in BC to the interrupt list in HL
+.add_int::
+1$:
+ ld a, (hl)
+ inc hl
+ or (hl)
+ jr z, 2$
+ inc hl
+ jr 1$
+2$:
+ ld (hl), b
+ dec hl
+ ld (hl), c
+ ret
+
+; void remove_VBL(int_handler h) __z88dk_fastcall __preserves_regs(iyh, iyl);
+_remove_VBL::
+ ld b, h
+ ld c, l
+
+ ;; Remove interrupt routine in BC from the VBL interrupt list
+ ;; falldown to .remove_int
+.remove_VBL::
+ ld hl, #.VBLANK_HANDLER0
+
+ ;; Remove interrupt BC from interrupt list HL if it exists
+ ;; Abort if a 0000 is found (end of list)
+.remove_int::
+1$:
+ ld e, (hl)
+ inc hl
+ ld d, (hl)
+ inc hl
+ ld a, e
+ or d
+ ret z ; No interrupt found
+
+ ld a, e
+ cp c
+ jr nz, 1$
+
+ ld a, d
+ cp b
+ jr nz, 1$
+
+ ld d, h
+ ld e, l
+ dec de
+ dec de
+
+ ;; Now do a memcpy from here until the end of the list
+2$:
+ ld a, (hl)
+ ldi
+ or (hl)
+ ldi
+ jr nz, 2$
+ ret
+
+_remove_TIM::
+_remove_SIO::
+_remove_JOY::
+_add_TIM::
+_add_SIO::
+_add_JOY::
+.empty_function:
+ ret
+
+ .area _INITIALIZED
+
+.HBLANK_HANDLER0:
+ .ds 0x02
+.VBLANK_HANDLER0:
+ .ds 0x02
+.VBLANK_HANDLER1:
+ .ds 0x02
+.VBLANK_HANDLER2:
+ .ds 0x02
+ .ds 0x02
+
+ .area _INITIALIZER
+
+ .dw .empty_function
+ .dw 0x0000
+ .dw 0x0000
+ .dw 0x0000
+ .dw 0x0000 \ No newline at end of file
diff --git a/gbdk/gbdk-lib/libc/targets/z80/sms_metasprites.s b/gbdk/gbdk-lib/libc/targets/z80/sms_metasprites.s
new file mode 100644
index 00000000..92b313a1
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/sms_metasprites.s
@@ -0,0 +1,82 @@
+ .include "global.s"
+
+ .title "Metasprites"
+ .module Metasprites
+
+ .area _DATA
+
+___current_metasprite::
+ .ds 0x02
+___current_base_tile::
+ .ds 0x01
+
+ .area _INITIALIZED
+___render_shadow_OAM::
+ .ds 0x01
+
+ .area _INITIALIZER
+ .db #>_shadow_OAM
+
+ .area _CODE
+
+; uint8_t __move_metasprite(uint8_t id, uint8_t x, uint8_t y) __z88dk_callee __preserves_regs(iyh,iyl);
+
+___move_metasprite::
+ ld hl, #4
+ add hl, sp
+
+ ld b, (hl)
+ dec hl
+ ld c, (hl)
+ dec hl
+ ld e, (hl)
+
+ ld hl, (___current_metasprite)
+
+ ld a, (___render_shadow_OAM)
+ ld d, a
+1$:
+ ld a, (hl) ; dy
+ inc hl
+ cp #0x80
+ jp z, 2$
+ add b
+ ld b, a
+ cp #0xD0
+ jp nz, 3$
+ ld a, #0xC0
+3$:
+ ld (de), a
+
+ push de
+
+ ld a, e
+ add a
+ add #0x40
+ ld e, a
+
+ ld a, (hl) ; dx
+ inc hl
+ add c
+ ld c, a
+ ld (de), a
+ inc e
+
+ ld a, (___current_base_tile)
+ add (hl) ; tile
+ inc hl
+ ld (de), a
+
+ pop de
+ inc e
+
+ jp 1$
+2$:
+ pop hl
+ pop bc
+ inc sp
+ push hl
+ ld a, e
+ sub c
+ ld l, a
+ ret
diff --git a/gbdk/gbdk-lib/libc/targets/z80/sms_metasprites_hide.s b/gbdk/gbdk-lib/libc/targets/z80/sms_metasprites_hide.s
new file mode 100644
index 00000000..21eacfe9
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/sms_metasprites_hide.s
@@ -0,0 +1,37 @@
+ .include "global.s"
+
+ .title "Metasprites"
+ .module Metasprites
+
+ .globl ___current_metasprite, ___render_shadow_OAM
+
+ .area _CODE
+
+
+; void __hide_metasprite(uint8_t id) __z88dk_fastcall __preserves_regs(iyh,iyl);
+
+___hide_metasprite::
+ ld e, l
+
+ ld hl, (___current_metasprite)
+
+ ld bc, #3
+
+ ld a, (___render_shadow_OAM)
+ ld d, a
+1$:
+ ld a, (hl)
+ cp #0x80
+ ret z
+
+ ld a, #0x3F
+ cp e
+ ret c
+
+ add hl, bc
+
+ ld a, #0xC0
+ ld (de), a
+
+ inc e
+ jp 1$
diff --git a/gbdk/gbdk-lib/libc/targets/z80/sms_metasprites_hide_spr.s b/gbdk/gbdk-lib/libc/targets/z80/sms_metasprites_hide_spr.s
new file mode 100644
index 00000000..789a190b
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/sms_metasprites_hide_spr.s
@@ -0,0 +1,41 @@
+ .include "global.s"
+
+ .title "Metasprites"
+ .module Metasprites
+
+ .globl ___render_shadow_OAM
+
+ .area _CODE
+
+; void hide_sprites_range(UINT8 from, UINT8 to) __z88dk_callee __preserves_regs(iyh,iyl);
+
+_hide_sprites_range::
+ pop hl
+ pop de
+ push hl
+
+ ld a, d
+ cp #(64+1)
+ ret nc
+
+ sub e
+ ret c
+ ret z
+
+ ld c, a
+ xor a
+ ld b, a
+
+ ld hl, #___render_shadow_OAM
+ ld h, (hl)
+ ld l, e
+
+ ld d, h
+ inc e
+ ld (hl), #0xC0
+
+ dec c
+ ret z
+
+ ldir
+ ret
diff --git a/gbdk/gbdk-lib/libc/targets/z80/sms_refresh_oam.s b/gbdk/gbdk-lib/libc/targets/z80/sms_refresh_oam.s
new file mode 100644
index 00000000..e107563b
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/sms_refresh_oam.s
@@ -0,0 +1,34 @@
+ .include "global.s"
+
+ .title "VRAM utilities"
+ .module VRAMUtils
+
+ .globl __shadow_OAM_base
+
+ .ez80
+
+ .area _HOME
+
+; void refresh_OAM();
+_refresh_OAM::
+ DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT
+ ld de, #.VDP_SAT
+ VDP_WRITE_CMD d, e
+
+ ld h, #>_shadow_OAM
+ ld l, #0
+ ld c, #.VDP_DATA
+ ld b, #64
+1$:
+ outi
+ jp nz, 1$
+
+ ld de, #(.VDP_SAT + 0x80)
+ VDP_WRITE_CMD d, e
+ ld b, #128
+2$:
+ outi
+ jp nz, 2$
+
+ ENABLE_VBLANK_COPY ; switch OFF copy shadow SAT
+ ret \ No newline at end of file
diff --git a/gbdk/gbdk-lib/libc/targets/z80/sms_set_1bpp_data.s b/gbdk/gbdk-lib/libc/targets/z80/sms_set_1bpp_data.s
new file mode 100644
index 00000000..52662d96
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/sms_set_1bpp_data.s
@@ -0,0 +1,108 @@
+ .include "global.s"
+
+ .title "VRAM utilities"
+ .module VRAMUtils
+
+ .ez80
+
+ .area _HOME
+
+; void set_tile_1bpp_data(uint16_t start, uint16_t ntiles, const void *src, uint16_t colors) __z88dk_callee __preserves_regs(iyh,iyl);
+_set_tile_1bpp_data::
+ pop de ; pop ret address
+ pop hl
+
+ add hl, hl
+ add hl, hl
+ add hl, hl
+ add hl, hl
+ add hl, hl
+
+ ld bc, #.VDP_VRAM
+ add hl, bc
+
+ DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT
+
+ VDP_WRITE_CMD h, l
+
+ ex de, hl ; hl = ret
+
+ pop bc ; bc = ntiles
+ pop de ; de = src
+ ex (sp), hl ; hl = palette
+
+ ex de, hl
+
+ inc b
+ inc c
+ push ix
+
+ ld ixh, d
+ ld ixl, e ; ix == palette
+
+ push iy
+ ld iy, #-4
+ add iy, sp
+ ld sp, iy
+ push bc
+ jr 2$
+
+1$:
+ ex (sp), hl
+
+ ld d, #8
+6$:
+ ld c, (hl)
+ inc hl
+
+ ld e, #8
+5$:
+ srl c
+
+ jr c, 10$
+ ld a, ixh
+ jr 11$
+10$:
+ ld a, ixl
+11$:
+ rra
+ rr 0 (iy)
+ rra
+ rr 1 (iy)
+ rra
+ rr 2 (iy)
+ rra
+ rr 3 (iy)
+
+ dec e
+ jr nz, 5$
+
+ ld a, 0 (iy)
+ out (.VDP_DATA), a
+ ld a, 1 (iy)
+ out (.VDP_DATA), a
+ ld a, 2 (iy)
+ out (.VDP_DATA), a
+ ld a, 3 (iy)
+ out (.VDP_DATA), a
+
+ dec d
+ jr nz, 6$
+2$:
+ ex (sp), hl
+
+ dec l
+ jr nz, 1$
+
+ dec h
+ jr nz, 1$
+
+ ld iy, #6
+ add iy, sp
+ ld sp, iy
+ pop iy
+ pop ix
+
+ ENABLE_VBLANK_COPY ; switch ON copy shadow SAT
+
+ ret
diff --git a/gbdk/gbdk-lib/libc/targets/z80/sms_set_2bpp_data.s b/gbdk/gbdk-lib/libc/targets/z80/sms_set_2bpp_data.s
new file mode 100644
index 00000000..a77e08fe
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/sms_set_2bpp_data.s
@@ -0,0 +1,144 @@
+ .include "global.s"
+
+ .title "VRAM utilities"
+ .module VRAMUtils
+
+ .ez80
+
+ .area _INITIALIZED
+__current_2bpp_palette::
+ .ds 0x02
+
+ .area _INITIALIZER
+ .dw 0b0011001000010000
+
+ .area _HOME
+
+; void set_tile_2bpp_data(uint16_t start, uint16_t ntiles, const void *src, uint16_t palette) __z88dk_callee __preserves_regs(iyh,iyl);
+_set_tile_2bpp_data::
+ pop de ; pop ret address
+ pop hl
+
+ add hl, hl
+ add hl, hl
+ add hl, hl
+ add hl, hl
+ add hl, hl
+
+ ld bc, #.VDP_VRAM
+ add hl, bc
+
+ DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT
+
+ VDP_WRITE_CMD h, l
+
+ ex de, hl ; hl = ret
+
+ pop bc ; bc = ntiles
+ pop de ; de = src
+ ex (sp), hl ; hl = palette
+
+ ex de, hl
+
+ inc b
+ inc c
+ push ix
+ push iy
+ ld iy, #-4
+ add iy, sp
+ ld sp, iy
+ push bc
+ jr 2$
+
+1$:
+ ex (sp), hl
+
+ ld ixh, #8
+6$:
+ ld c, (hl)
+ inc hl
+ ld b, (hl)
+ inc hl
+
+ ld ixl, #8
+5$:
+ xor a
+ srl b
+ rla
+ srl c
+ rla
+
+ push de ; save palette
+
+ inc a
+ dec a
+ jr nz, 10$
+ ; zero
+ ld a, e
+ jr 13$
+10$:
+ dec a
+ jr nz, 11$
+ ; one
+ ld a, e
+ jr 14$
+11$:
+ dec a
+ jr nz, 12$
+ ; two
+ ld a, d
+ jr 13$
+12$:
+ ;three
+ ld a, d
+14$:
+ rra
+ rra
+ rra
+ rra
+13$:
+ and #0x0F
+
+ rra
+ rr 0 (iy)
+ rra
+ rr 1 (iy)
+ rra
+ rr 2 (iy)
+ rra
+ rr 3 (iy)
+
+ pop de ; restore palette
+
+ dec ixl
+ jr nz, 5$
+
+ ld a, 0 (iy)
+ out (.VDP_DATA), a
+ ld a, 1 (iy)
+ out (.VDP_DATA), a
+ ld a, 2 (iy)
+ out (.VDP_DATA), a
+ ld a, 3 (iy)
+ out (.VDP_DATA), a
+
+ dec ixh
+ jr nz, 6$
+2$:
+ ex (sp), hl
+
+ dec l
+ jr nz, 1$
+
+ dec h
+ jr nz, 1$
+
+ ld iy, #6
+ add iy, sp
+ ld sp, iy
+ pop iy
+ pop ix
+
+ ENABLE_VBLANK_COPY ; switch ON copy shadow SAT
+
+ ret
diff --git a/gbdk/gbdk-lib/libc/targets/z80/sms_set_native_data.s b/gbdk/gbdk-lib/libc/targets/z80/sms_set_native_data.s
new file mode 100644
index 00000000..bcd418f1
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/sms_set_native_data.s
@@ -0,0 +1,51 @@
+ .include "global.s"
+
+ .title "VRAM utilities"
+ .module VRAMUtils
+ .area _HOME
+
+; void set_native_tile_data(uint16_t start, uint16_t ntiles, const void *src) __z88dk_callee __preserves_regs(iyh,iyl);
+_set_native_tile_data::
+ pop de ; pop ret address
+ pop hl
+
+ add hl, hl
+ add hl, hl
+ add hl, hl
+ add hl, hl
+ add hl, hl
+
+ ld bc, #.VDP_VRAM
+ add hl, bc
+
+ DISABLE_VBLANK_COPY ; switch OFF copy shadow SAT
+
+ VDP_WRITE_CMD h, l
+
+ pop bc
+ pop hl
+ push de
+
+ ld e, c
+ ld d, b
+
+ ld c, #.VDP_DATA
+ inc d
+ inc e
+ jr 2$
+
+1$:
+ ld b, #32
+3$:
+ outi
+ jr nz, 3$
+2$:
+ dec e
+ jr nz, 1$
+
+ dec d
+ jr nz, 1$
+
+ ENABLE_VBLANK_COPY ; switch ON copy shadow SAT
+
+ ret
diff --git a/gbdk/gbdk-lib/libc/targets/z80/vmemcpy.s b/gbdk/gbdk-lib/libc/targets/z80/vmemcpy.s
new file mode 100644
index 00000000..8c420059
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/targets/z80/vmemcpy.s
@@ -0,0 +1,45 @@
+ .include "global.s"
+
+ .title "VRAM utilities"
+ .module VRAMUtils
+ .area _HOME
+
+; void vmemcpy (unsigned int dst, const void *src, unsigned int size) __z88dk_callee __preserves_regs(iyh,iyl);
+_set_data::
+_vmemcpy::
+ pop de ; pop ret address
+ pop hl ; dst
+
+ DISABLE_VBLANK_COPY
+
+ VDP_WRITE_CMD h, l
+
+ pop hl ; src
+ pop bc ; size
+
+ ld a, b ; HI(size)
+ ld b, c ; LO(size)
+
+ ld c, #.VDP_DATA
+
+ rlc b
+ rrc b ; check b is zero
+ jr z, 2$
+1$:
+ outi
+ jp nz, 1$ ; 10 = 26 (VRAM safe)
+2$:
+ inc a
+ jp 4$
+3$:
+ outi
+ jp nz, 3$ ; 10 = 26 (VRAM safe)
+4$:
+ dec a
+ jp nz, 3$
+
+ ENABLE_VBLANK_COPY
+
+ ld h, d
+ ld l, e
+ jp (hl)
diff --git a/gbdk/gbdk-lib/libc/time.c b/gbdk/gbdk-lib/libc/time.c
new file mode 100644
index 00000000..b6801760
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/time.c
@@ -0,0 +1,17 @@
+/*
+ time.c
+ Simple, not completely conformant implementation of time routines
+*/
+
+#include <stdint.h>
+
+/* clock() is in clock.s */
+#include <time.h>
+
+time_t time(time_t *t) {
+ uint16_t ret;
+ /* Should be relative to 0:00 1970 GMT but hey */
+ ret = clock() / CLOCKS_PER_SEC;
+ if (t) *t = ret;
+ return ret;
+}
diff --git a/gbdk/gbdk-lib/libc/tolower.c b/gbdk/gbdk-lib/libc/tolower.c
new file mode 100644
index 00000000..9a730d50
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/tolower.c
@@ -0,0 +1,5 @@
+#include <stdint.h>
+
+char tolower (char c) {
+ return ((uint8_t)((uint8_t)c - 'A') < ('Z' - 'A' + 1)) ? c + 32u : c;
+}
diff --git a/gbdk/gbdk-lib/libc/toupper.c b/gbdk/gbdk-lib/libc/toupper.c
new file mode 100644
index 00000000..661eb0ca
--- /dev/null
+++ b/gbdk/gbdk-lib/libc/toupper.c
@@ -0,0 +1,5 @@
+#include <stdint.h>
+
+char toupper(char c) {
+ return ((uint8_t)((uint8_t)c - 'a') < ('z' - 'a' + 1)) ? c - 32u : c;
+}