├── .github └── workflows │ └── green.yml ├── .gitignore ├── .vscode ├── settings.json └── tasks.json ├── LICENSE ├── Makefile ├── README.md ├── demo ├── Makefile ├── cross │ ├── Makefile │ ├── README.md │ ├── android │ │ ├── .gitignore │ │ ├── app │ │ │ ├── .gitignore │ │ │ ├── CMakeLists.txt │ │ │ ├── build.gradle │ │ │ ├── local.properties │ │ │ ├── proguard-rules.pro │ │ │ └── src │ │ │ │ ├── androidTest │ │ │ │ └── java │ │ │ │ │ └── com │ │ │ │ │ └── juhang │ │ │ │ │ └── green │ │ │ │ │ └── ApplicationTest.java │ │ │ │ ├── main │ │ │ │ ├── AndroidManifest.xml │ │ │ │ ├── assets │ │ │ │ │ ├── enemy.png │ │ │ │ │ ├── gameover.ogg │ │ │ │ │ ├── ingame.ogg │ │ │ │ │ ├── player.png │ │ │ │ │ └── tiles.png │ │ │ │ ├── ic_launcher-web.png │ │ │ │ ├── java │ │ │ │ │ ├── com │ │ │ │ │ │ └── juhang │ │ │ │ │ │ │ ├── green │ │ │ │ │ │ │ ├── MyGame.java │ │ │ │ │ │ │ └── StartActivity.java │ │ │ │ │ │ │ └── util │ │ │ │ │ │ │ └── VirtualKeypad.java │ │ │ │ │ └── org │ │ │ │ │ │ └── libsdl │ │ │ │ │ │ └── app │ │ │ │ │ │ ├── HIDDevice.java │ │ │ │ │ │ ├── HIDDeviceBLESteamController.java │ │ │ │ │ │ ├── HIDDeviceManager.java │ │ │ │ │ │ ├── HIDDeviceUSB.java │ │ │ │ │ │ ├── SDL.java │ │ │ │ │ │ ├── SDLActivity.java │ │ │ │ │ │ ├── SDLAudioManager.java │ │ │ │ │ │ └── SDLControllerManager.java │ │ │ │ └── res │ │ │ │ │ ├── drawable-hdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ ├── drawable-mdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ ├── drawable-xhdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ ├── drawable-xxhdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ ├── drawable │ │ │ │ │ ├── background_gradient.xml │ │ │ │ │ ├── blue_pushed.png │ │ │ │ │ ├── blue_unpushed.png │ │ │ │ │ ├── boarder.xml │ │ │ │ │ ├── button.png │ │ │ │ │ ├── down_arrow.png │ │ │ │ │ ├── gra_white.xml │ │ │ │ │ ├── green_pushed.png │ │ │ │ │ ├── green_unpushed.png │ │ │ │ │ ├── ic_launcher_background.xml │ │ │ │ │ ├── image_button.png │ │ │ │ │ ├── image_button_bg.png │ │ │ │ │ ├── imgbtn_states.xml │ │ │ │ │ ├── imgbtn_states2.xml │ │ │ │ │ ├── imgbtn_states3.xml │ │ │ │ │ ├── joystick_inner.png │ │ │ │ │ ├── joystick_outer.png │ │ │ │ │ ├── left_arrow.png │ │ │ │ │ ├── menu_background_color.xml │ │ │ │ │ ├── pad.png │ │ │ │ │ ├── red_pushed.png │ │ │ │ │ ├── red_unpushed.png │ │ │ │ │ ├── right_arrow.png │ │ │ │ │ ├── stars.png │ │ │ │ │ ├── toolbar_shadow.xml │ │ │ │ │ └── up_arrow.png │ │ │ │ │ ├── layout │ │ │ │ │ ├── jumpbutton.xml │ │ │ │ │ ├── layout.xml │ │ │ │ │ └── main.xml │ │ │ │ │ ├── values-ko-rKR │ │ │ │ │ └── strings.xml │ │ │ │ │ └── values │ │ │ │ │ ├── colors.xml │ │ │ │ │ ├── strings.xml │ │ │ │ │ └── styles.xml │ │ │ │ └── test │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── juhang │ │ │ │ └── green │ │ │ │ └── ExampleUnitTest.java │ │ ├── build.gradle │ │ ├── gradle.properties │ │ ├── gradle │ │ │ └── wrapper │ │ │ │ ├── gradle-wrapper.jar │ │ │ │ └── gradle-wrapper.properties │ │ ├── gradlew │ │ ├── gradlew.bat │ │ └── settings.gradle │ ├── data │ │ ├── Makefile │ │ ├── effects.aks │ │ ├── enemy.png │ │ ├── enemy3.png │ │ ├── gameover.ogg │ │ ├── ingame.ogg │ │ ├── map.json │ │ ├── map_conf.json │ │ ├── player.png │ │ ├── song.aks │ │ ├── tiles.png │ │ └── tiles2.png │ ├── msvc │ │ ├── .gitignore │ │ ├── apultra │ │ │ ├── apultra.vcxproj │ │ │ ├── apultra.vcxproj.filters │ │ │ └── apultra.vcxproj.user │ │ ├── green4dos.sln │ │ ├── green4dos │ │ │ ├── .gitignore │ │ │ ├── green.dsp │ │ │ ├── green.dsw │ │ │ ├── green4dos.vcxproj │ │ │ ├── green4dos.vcxproj.filters │ │ │ └── green4dos.vcxproj.user │ │ ├── green4win32.sln │ │ ├── green4win32 │ │ │ ├── green4win32.vcxproj │ │ │ ├── green4win32.vcxproj.filters │ │ │ └── green4win32.vcxproj.user │ │ └── src │ │ │ ├── ubox_mplayer_sdl.c │ │ │ ├── ubox_sdl.c │ │ │ └── ubox_spman_sdl.cpp │ ├── src │ │ ├── Makefile │ │ ├── Makefile.deps │ │ ├── akm.z80 │ │ ├── crt0.z80 │ │ ├── data.c │ │ ├── effects.asm │ │ ├── effects_playerconfig.asm │ │ ├── game.c │ │ ├── game.h │ │ ├── helpers.c │ │ ├── helpers.h │ │ ├── main.c │ │ ├── main.h │ │ ├── song.asm │ │ └── song_playerconfig.asm │ └── yuza │ │ ├── .gitignore │ │ ├── apultra │ │ ├── apultra.vcxproj │ │ ├── apultra.vcxproj.filters │ │ └── apultra.vcxproj.user │ │ ├── green4yuza.sln │ │ └── green4yuza │ │ ├── green4yuza.vcxproj │ │ ├── green4yuza.vcxproj.filters │ │ ├── green4yuza.vcxproj.user │ │ └── yuza_sdl.props ├── pyramid │ ├── Makefile │ ├── data │ │ ├── Makefile │ │ ├── effects.aks │ │ ├── enemy.png │ │ ├── foothold.png │ │ ├── ladder.png │ │ ├── map1.json │ │ ├── map10.json │ │ ├── map11.json │ │ ├── map2.json │ │ ├── map3.json │ │ ├── map4.json │ │ ├── map5.json │ │ ├── map6.json │ │ ├── map7.json │ │ ├── map8.json │ │ ├── map9.json │ │ ├── map_conf.json │ │ ├── player.png │ │ ├── player1.png │ │ ├── song.aks │ │ ├── tiles.png │ │ ├── tiles_backup.png │ │ └── tiles_backup3.png │ ├── src │ │ ├── Makefile │ │ ├── Makefile.deps │ │ ├── akm.z80 │ │ ├── crt0.z80 │ │ ├── data.c │ │ ├── effects.asm │ │ ├── effects_playerconfig.asm │ │ ├── enemy_logic.c │ │ ├── enemy_logic.h │ │ ├── exit_logic.c │ │ ├── exit_logic.h │ │ ├── foothold_logic.c │ │ ├── foothold_logic.h │ │ ├── game.c │ │ ├── game.h │ │ ├── game_util.c │ │ ├── game_util.h │ │ ├── helpers.c │ │ ├── helpers.h │ │ ├── item_logic.c │ │ ├── item_logic.h │ │ ├── main.c │ │ ├── main.h │ │ ├── player_logic.c │ │ ├── player_logic.h │ │ ├── song.asm │ │ ├── song_playerconfig.asm │ │ ├── warp_logic.c │ │ └── warp_logic.h │ └── tools │ │ ├── map.py │ │ ├── map_generate.py │ │ ├── map_summary.py │ │ ├── mkdeps.py │ │ ├── png2sprites.py │ │ └── png2tiles.py └── scroll │ ├── Makefile │ ├── README.md │ ├── data │ ├── Makefile │ ├── effects.aks │ ├── enemy.png │ ├── enemy3.png │ ├── gameover.ogg │ ├── ingame.ogg │ ├── map.json │ ├── map_conf.json │ ├── player.png │ ├── song.aks │ ├── test.json │ ├── tiles.png │ └── tiles_ori.png │ └── src │ ├── Makefile │ ├── Makefile.deps │ ├── Makefile_ │ ├── akm.z80 │ ├── crt0.z80 │ ├── data.c │ ├── effects.asm │ ├── effects_playerconfig.asm │ ├── game.c │ ├── game.h │ ├── helpers.c │ ├── helpers.h │ ├── main.c │ ├── main.h │ ├── song.asm │ └── song_playerconfig.asm ├── docs ├── Makefile ├── extra.md ├── footer.md ├── header.html ├── images │ └── player.png ├── monokai.css ├── mplayer.md ├── spman.md ├── tools.md └── water.css ├── emul_start_config.txt ├── examples ├── 01_hello │ ├── .vscode │ │ └── tasks.json │ ├── Makefile │ ├── emul_start_config.txt │ └── src │ │ ├── Makefile │ │ ├── crt0.z80 │ │ ├── main.c │ │ └── tiles.h ├── 02_consolehello │ ├── Makefile │ └── src │ │ ├── Makefile │ │ ├── crt0.z80 │ │ ├── main.c │ │ └── printf.z80 ├── 03_timer │ ├── Makefile │ └── src │ │ ├── Makefile │ │ ├── crt0.z80 │ │ ├── main.c │ │ ├── main.h │ │ └── tiles.h ├── 04_clibrary │ ├── Makefile │ └── src │ │ ├── Makefile │ │ ├── crt0.z80 │ │ ├── main.c │ │ ├── main.h │ │ ├── printf.c │ │ ├── printf.h │ │ └── tiles.h ├── 05_music │ ├── Makefile │ └── src │ │ ├── Makefile │ │ ├── akm.z80 │ │ ├── alienall.asm │ │ ├── alienall_playerconfig.asm │ │ ├── crt0.z80 │ │ ├── main.c │ │ └── tiles.h ├── 06_sound │ ├── .vscode │ │ └── settings.json │ ├── Makefile │ └── src │ │ ├── Makefile │ │ ├── akm.z80 │ │ ├── crt0.z80 │ │ ├── effects.asm │ │ ├── effects_playerconfig.asm │ │ ├── main.c │ │ ├── song.asm │ │ ├── song_playerconfig.asm │ │ └── tiles.h ├── 07_snakebyte │ ├── .vscode │ │ └── settings.json │ ├── Makefile │ └── src │ │ ├── Makefile │ │ ├── crt0.z80 │ │ ├── game.c │ │ ├── game.h │ │ ├── main.c │ │ ├── tiles.h │ │ ├── util.c │ │ └── util.h ├── 08_socoban │ ├── Makefile │ └── src │ │ ├── Makefile │ │ ├── crt0.z80 │ │ ├── game.c │ │ ├── game.h │ │ ├── main.c │ │ ├── tiles.h │ │ ├── util.c │ │ └── util.h ├── 09_tetris │ ├── .vscode │ │ ├── c_cpp_properties.json │ │ └── settings.json │ ├── Makefile │ └── src │ │ ├── Makefile │ │ ├── crt0.z80 │ │ ├── game.c │ │ ├── game.h │ │ ├── main.c │ │ ├── tiles.h │ │ ├── util.c │ │ └── util.h ├── 10_breakout │ ├── .vscode │ │ ├── c_cpp_properties.json │ │ └── settings.json │ ├── Makefile │ └── src │ │ ├── Makefile │ │ ├── crt0.z80 │ │ ├── game.c │ │ ├── game.h │ │ ├── main.c │ │ ├── tiles.h │ │ ├── util.c │ │ └── util.h ├── 11_log │ ├── Makefile │ └── src │ │ ├── Makefile │ │ ├── crt0.z80 │ │ ├── main.c │ │ └── tiles.h ├── 12_debugger │ ├── Makefile │ ├── src │ │ ├── Makefile │ │ ├── crt0.z80 │ │ ├── main.c │ │ └── tiles.h │ └── symbol_conversion.py └── Makefile ├── game ├── Makefile ├── README.md ├── data │ ├── Makefile │ ├── effects.aks │ ├── enemy.png │ ├── map.json │ ├── map_conf.json │ ├── player.png │ ├── song.aks │ ├── symbol_conversion.py │ └── tiles.png ├── src │ ├── Makefile │ ├── Makefile.deps │ ├── akm.z80 │ ├── crt0.z80 │ ├── data.c │ ├── effects.asm │ ├── effects_playerconfig.asm │ ├── game.c │ ├── game.h │ ├── helpers.c │ ├── helpers.h │ ├── main.c │ ├── main.h │ ├── song.asm │ └── song_playerconfig.asm └── symbol_conversion.py ├── img ├── breakout.png ├── example11.png ├── socoban.png └── tetris2.png ├── include ├── ap.h ├── mplayer.h ├── spman.h └── ubox.h ├── src ├── ap │ ├── Makefile │ └── ap.z80 ├── mplayer │ ├── Makefile │ ├── akm │ │ ├── LICENSE.txt │ │ ├── Makefile │ │ ├── PlayerAkm.asm │ │ ├── PlayerAkm_SoundEffects.asm │ │ ├── README.md │ │ └── akm_ubox.asm │ ├── mplayer_init.z80 │ ├── mplayer_init_effects.z80 │ ├── mplayer_is_sound_effect_on.z80 │ ├── mplayer_play.z80 │ ├── mplayer_play_effect.z80 │ ├── mplayer_play_effect_p.z80 │ ├── mplayer_stop.z80 │ └── mplayer_stop_effect_channel.z80 ├── spman │ ├── .gitignore │ ├── Makefile │ └── spman.c └── ubox │ ├── Makefile │ ├── ubox_disable_screen.z80 │ ├── ubox_enable_screen.z80 │ ├── ubox_fill_screen.z80 │ ├── ubox_get_tile.z80 │ ├── ubox_get_vsync_freq.z80 │ ├── ubox_isr.z80 │ ├── ubox_put_tile.z80 │ ├── ubox_read_ctl.z80 │ ├── ubox_read_keys.z80 │ ├── ubox_read_vm.z80 │ ├── ubox_reset_tick.z80 │ ├── ubox_select_ctl.z80 │ ├── ubox_set_colors.z80 │ ├── ubox_set_mode.z80 │ ├── ubox_set_sprite_attr.z80 │ ├── ubox_set_sprite_pat16.z80 │ ├── ubox_set_sprite_pat16_flip.z80 │ ├── ubox_set_sprite_pat8.z80 │ ├── ubox_set_sprite_pat8_flip.z80 │ ├── ubox_set_tiles.z80 │ ├── ubox_set_tiles_colors.z80 │ ├── ubox_set_user_isr.z80 │ ├── ubox_wait.z80 │ ├── ubox_wait_for.z80 │ ├── ubox_write_vm.z80 │ └── ubox_wvdp.z80 └── tools ├── Makefile ├── apultra ├── .gitignore ├── LICENSE ├── LICENSE.cc0.md ├── LICENSE.zlib.md ├── Makefile ├── README.md ├── VS2017 │ ├── apultra.sln │ ├── apultra.vcxproj │ ├── apultra.vcxproj.filters │ └── apultra.vcxproj.user ├── asm │ ├── 6502 │ │ ├── aplib_6502.asm │ │ └── aplib_6502_b.asm │ ├── 6809 │ │ ├── unaplib.s │ │ ├── unaplib_6309.s │ │ ├── unaplib_6309_b.s │ │ └── unaplib_b.s │ ├── 8088 │ │ ├── aplib_8088_fast.S │ │ └── aplib_8088_small.S │ ├── 68000 │ │ └── unaplib_68000.S │ ├── ARM7TDMI │ │ └── aplib_arm.s │ ├── Z80 │ │ ├── unaplib_fast.asm │ │ └── unaplib_small.asm │ └── x86 │ │ ├── aplib_x86_fast.asm │ │ └── aplib_x86_small.asm └── src │ ├── apultra.c │ ├── expand.c │ ├── expand.h │ ├── format.h │ ├── libapultra.h │ ├── libdivsufsort │ ├── CHANGELOG.md │ ├── CMakeLists.txt │ ├── CMakeModules │ │ ├── AppendCompilerFlags.cmake │ │ ├── CheckFunctionKeywords.cmake │ │ ├── CheckLFS.cmake │ │ ├── ProjectCPack.cmake │ │ └── cmake_uninstall.cmake.in │ ├── LICENSE │ ├── README.md │ ├── VERSION.cmake │ ├── examples │ │ ├── CMakeLists.txt │ │ ├── bwt.c │ │ ├── mksary.c │ │ ├── sasearch.c │ │ ├── suftest.c │ │ └── unbwt.c │ ├── include │ │ ├── CMakeLists.txt │ │ ├── config.h.cmake │ │ ├── divsufsort.h │ │ ├── divsufsort.h.cmake │ │ ├── divsufsort_config.h │ │ ├── divsufsort_private.h │ │ └── lfs.h.cmake │ ├── lib │ │ ├── CMakeLists.txt │ │ ├── divsufsort.c │ │ ├── divsufsort_utils.c │ │ ├── sssort.c │ │ └── trsort.c │ └── pkgconfig │ │ ├── CMakeLists.txt │ │ └── libdivsufsort.pc.cmake │ ├── matchfinder.c │ ├── matchfinder.h │ ├── shrink.c │ └── shrink.h ├── chksize ├── hdoc.py ├── hex2bin-2.0 ├── Makefile ├── doc │ ├── CRC list.txt │ ├── ChangeLog_hex2bin │ ├── ChangeLog_mot2bin │ ├── README │ ├── S-record.txt │ ├── formats.txt │ ├── intelhex.spc │ └── srec.txt └── src │ ├── binary.c │ ├── binary.h │ ├── common.c │ ├── common.h │ ├── hex2bin.1 │ ├── hex2bin.c │ ├── hex2bin.pod │ ├── libcrc.c │ ├── libcrc.h │ └── mot2bin.c ├── map.py ├── mkdeps.py ├── pandocfilter-pygments.py ├── png2sprites.py ├── png2tiles.py ├── rasm ├── Makefile ├── decrunch │ ├── aplib_z80_todo.asm │ ├── deexo.asm │ ├── dzx7_turbo.asm │ ├── exomizer3megachur.asm │ ├── lz48decrunch_v006.asm │ ├── lz49decrunch_v001.asm │ └── lz4_docent.asm ├── exomizer.h ├── lz4.h ├── minilib.h ├── rasm.h ├── rasm_v0120.c └── zx7.h └── tilesconverter ├── .gitignore ├── IMG_save.h ├── IMG_saveend.h ├── IMG_savepng.c ├── IMG_savepng.h ├── tilesconverter.cpp ├── tilesconverter.sln ├── tilesconverter.vcxproj ├── tilesconverter.vcxproj.filters └── tilesconverter.vcxproj.user /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Object files 5 | *.o 6 | *.ko 7 | *.obj 8 | *.elf 9 | 10 | # Linker output 11 | *.ilk 12 | *.map 13 | *.exp 14 | 15 | # Precompiled Headers 16 | *.gch 17 | *.pch 18 | 19 | # Libraries 20 | *.lib 21 | *.a 22 | *.la 23 | *.lo 24 | 25 | # Shared objects (inc. Windows DLLs) 26 | *.dll 27 | *.so 28 | *.so.* 29 | *.dylib 30 | 31 | # Executables 32 | *.exe 33 | *.out 34 | *.app 35 | *.i*86 36 | *.x86_64 37 | *.hex 38 | 39 | # Debug files 40 | *.dSYM/ 41 | *.su 42 | *.idb 43 | *.pdb 44 | 45 | # Kernel Module Compile Results 46 | *.mod* 47 | *.cmd 48 | .tmp_versions/ 49 | modules.order 50 | Module.symvers 51 | Mkfile.old 52 | dkms.conf 53 | 54 | bin 55 | build 56 | generated 57 | *.lst 58 | *.sym 59 | *.rel 60 | *.bak 61 | 62 | .DS_Store -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "game.h": "c", 4 | "string.h": "c", 5 | "spman.h": "c", 6 | "ubox.h": "c", 7 | "map4.h": "c", 8 | "enemy.h": "c", 9 | "player.h": "c", 10 | "foothold.h": "c", 11 | "stdint.h": "c", 12 | "map": "c", 13 | "map5.h": "c", 14 | "map_summary.h": "c", 15 | "map1.h": "c", 16 | "enemy_logic.h": "c" 17 | } 18 | } -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | 5 | { 6 | "type": "shell", 7 | "label": "Compile", 8 | "command": "make", 9 | "args": ["clean", "game"], 10 | "group": { 11 | "kind": "build", 12 | "isDefault": true 13 | } 14 | }, 15 | { 16 | "type": "shell", 17 | "label": "Run", 18 | "command": "openmsx.exe", 19 | "args": [ 20 | "-script", 21 | "emul_start_config.txt" 22 | ], 23 | "group": { 24 | "kind": "test", 25 | "isDefault": true 26 | } 27 | 28 | } 29 | ], 30 | } -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | all: libs 2 | 3 | export PATH := $(PWD)/bin:$(PATH) 4 | 5 | libs: lib ubox spman mplayer ap 6 | 7 | game: bin libs 8 | make -C tools 9 | make -C game 10 | 11 | 12 | docs: 13 | make -C docs 14 | 15 | ubox: 16 | make -C src/ubox 17 | 18 | spman: 19 | make -C src/spman 20 | 21 | mplayer: 22 | make -C src/mplayer 23 | 24 | ap: 25 | make -C src/ap 26 | 27 | bin/apultra: bin 28 | make -C tools ../bin/apultra 29 | 30 | .PHONY: clean cleanall docs libs game 31 | clean: 32 | make -C src/ubox clean 33 | make -C src/spman clean 34 | make -C src/mplayer clean 35 | make -C src/ap clean 36 | make -C game clean 37 | 38 | lib: 39 | mkdir -p ./lib 40 | 41 | bin: 42 | mkdir -p ./bin 43 | 44 | cleanall: clean 45 | rm -rf ./bin ./lib 46 | make -C docs clean 47 | 48 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ubox_example 2 | this is ubox msx library example for msx game development. 3 | ubox msx library was created by Juan J. Martinez 4 | 5 | [ubox MSX lib](https://www.usebox.net/jjm/ubox-msx-lib/) 6 | 7 | ubox MSX lib 8 | Copyright (C) 2020-2021 by Juan J. Martinez 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in 18 | all copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | THE SOFTWARE. 27 | 28 | 29 | ## example games 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /demo/Makefile: -------------------------------------------------------------------------------- 1 | all: pyramid cross scroll 2 | 3 | export PATH := $(PWD)/../bin:$(PATH) 4 | 5 | pyramid: bin 6 | make -C pyramid 7 | 8 | cross: cross 9 | make -C cross 10 | 11 | scroll: scroll 12 | make -C scroll 13 | 14 | .PHONY: clean cleanall pyramid cross scroll 15 | clean: 16 | make -C pyramid clean 17 | make -C cross clean 18 | make -C scroll clean 19 | 20 | bin: 21 | mkdir -p ./bin 22 | 23 | cleanall: clean 24 | rm -rf ./bin -------------------------------------------------------------------------------- /demo/cross/Makefile: -------------------------------------------------------------------------------- 1 | export PATH := $(PWD)/../../bin:$(PATH) 2 | 3 | all: generated bin build 4 | make -C data 5 | cd src && python ../../../tools/mkdeps.py -b ../build -I ../generated:../../../include ./ Makefile.deps 6 | make -C src 7 | 8 | generated: 9 | mkdir -p ./generated 10 | 11 | bin: 12 | mkdir -p ./bin 13 | 14 | build: 15 | mkdir -p ./build 16 | 17 | .PHONY: all clean 18 | clean: 19 | rm -rf ./generated ./bin ./build 20 | make -C src clean 21 | make -C data clean 22 | 23 | -------------------------------------------------------------------------------- /demo/cross/android/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | /.idea 10 | /jni 11 | /libs 12 | -------------------------------------------------------------------------------- /demo/cross/android/app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | .cxx 3 | .idea -------------------------------------------------------------------------------- /demo/cross/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.application' 3 | } 4 | 5 | android { 6 | compileSdk 30 7 | 8 | defaultConfig { 9 | applicationId "com.juhang.green" 10 | minSdk 21 11 | targetSdk 30 12 | versionCode 1 13 | versionName "1.0" 14 | 15 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 16 | externalNativeBuild { 17 | cmake { 18 | abiFilters 'arm64-v8a' 19 | } 20 | } 21 | } 22 | 23 | buildTypes { 24 | release { 25 | minifyEnabled false 26 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 27 | } 28 | } 29 | compileOptions { 30 | sourceCompatibility JavaVersion.VERSION_1_8 31 | targetCompatibility JavaVersion.VERSION_1_8 32 | } 33 | 34 | externalNativeBuild { 35 | cmake { 36 | path file('CMakeLists.txt') 37 | version '3.10.2' 38 | } 39 | } 40 | buildFeatures { 41 | viewBinding true 42 | } 43 | } 44 | 45 | dependencies { 46 | 47 | implementation 'com.android.support:appcompat-v7:26.1.0' 48 | implementation 'com.github.erz05:JoyStick:1.1.0' 49 | } -------------------------------------------------------------------------------- /demo/cross/android/app/local.properties: -------------------------------------------------------------------------------- 1 | ## This file must *NOT* be checked into Version Control Systems, 2 | # as it contains information specific to your local configuration. 3 | # 4 | # Location of the SDK. This is only used by Gradle. 5 | # For customization when using a Version Control System, please read the 6 | # header note. 7 | #Thu Oct 28 00:38:52 KST 2021 8 | sdk.dir=C\:\\Dev\\android 9 | -------------------------------------------------------------------------------- /demo/cross/android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/ryan/Develop/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /demo/cross/android/app/src/androidTest/java/com/juhang/green/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.juhang.green; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /demo/cross/android/app/src/main/assets/enemy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/cross/android/app/src/main/assets/enemy.png -------------------------------------------------------------------------------- /demo/cross/android/app/src/main/assets/gameover.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/cross/android/app/src/main/assets/gameover.ogg -------------------------------------------------------------------------------- /demo/cross/android/app/src/main/assets/ingame.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/cross/android/app/src/main/assets/ingame.ogg -------------------------------------------------------------------------------- /demo/cross/android/app/src/main/assets/player.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/cross/android/app/src/main/assets/player.png -------------------------------------------------------------------------------- /demo/cross/android/app/src/main/assets/tiles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/cross/android/app/src/main/assets/tiles.png -------------------------------------------------------------------------------- /demo/cross/android/app/src/main/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/cross/android/app/src/main/ic_launcher-web.png -------------------------------------------------------------------------------- /demo/cross/android/app/src/main/java/com/juhang/green/MyGame.java: -------------------------------------------------------------------------------- 1 | package com.juhang.green; 2 | 3 | import org.libsdl.app.SDLActivity; 4 | 5 | /** 6 | * A sample wrapper class that just calls SDLActivity 7 | */ 8 | 9 | public class MyGame extends SDLActivity { 10 | 11 | } 12 | -------------------------------------------------------------------------------- /demo/cross/android/app/src/main/java/org/libsdl/app/HIDDevice.java: -------------------------------------------------------------------------------- 1 | package org.libsdl.app; 2 | 3 | interface HIDDevice 4 | { 5 | public int getId(); 6 | public int getVendorId(); 7 | public int getProductId(); 8 | public String getSerialNumber(); 9 | public int getVersion(); 10 | public String getManufacturerName(); 11 | public String getProductName(); 12 | public boolean open(); 13 | public int sendFeatureReport(byte[] report); 14 | public int sendOutputReport(byte[] report); 15 | public boolean getFeatureReport(byte[] report); 16 | public void setFrozen(boolean frozen); 17 | public void close(); 18 | public void shutdown(); 19 | } 20 | -------------------------------------------------------------------------------- /demo/cross/android/app/src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/cross/android/app/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/cross/android/app/src/main/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/cross/android/app/src/main/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/cross/android/app/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/cross/android/app/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/cross/android/app/src/main/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/cross/android/app/src/main/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/cross/android/app/src/main/res/drawable/background_gradient.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 7 | 8 | 12 | 13 | -------------------------------------------------------------------------------- /demo/cross/android/app/src/main/res/drawable/blue_pushed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/cross/android/app/src/main/res/drawable/blue_pushed.png -------------------------------------------------------------------------------- /demo/cross/android/app/src/main/res/drawable/blue_unpushed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/cross/android/app/src/main/res/drawable/blue_unpushed.png -------------------------------------------------------------------------------- /demo/cross/android/app/src/main/res/drawable/boarder.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /demo/cross/android/app/src/main/res/drawable/button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/cross/android/app/src/main/res/drawable/button.png -------------------------------------------------------------------------------- /demo/cross/android/app/src/main/res/drawable/down_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/cross/android/app/src/main/res/drawable/down_arrow.png -------------------------------------------------------------------------------- /demo/cross/android/app/src/main/res/drawable/gra_white.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | -------------------------------------------------------------------------------- /demo/cross/android/app/src/main/res/drawable/green_pushed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/cross/android/app/src/main/res/drawable/green_pushed.png -------------------------------------------------------------------------------- /demo/cross/android/app/src/main/res/drawable/green_unpushed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/cross/android/app/src/main/res/drawable/green_unpushed.png -------------------------------------------------------------------------------- /demo/cross/android/app/src/main/res/drawable/image_button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/cross/android/app/src/main/res/drawable/image_button.png -------------------------------------------------------------------------------- /demo/cross/android/app/src/main/res/drawable/image_button_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/cross/android/app/src/main/res/drawable/image_button_bg.png -------------------------------------------------------------------------------- /demo/cross/android/app/src/main/res/drawable/imgbtn_states.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 9 | 10 | 12 | 13 | -------------------------------------------------------------------------------- /demo/cross/android/app/src/main/res/drawable/imgbtn_states2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 9 | 10 | 12 | 13 | -------------------------------------------------------------------------------- /demo/cross/android/app/src/main/res/drawable/imgbtn_states3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 9 | 10 | 12 | 13 | -------------------------------------------------------------------------------- /demo/cross/android/app/src/main/res/drawable/joystick_inner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/cross/android/app/src/main/res/drawable/joystick_inner.png -------------------------------------------------------------------------------- /demo/cross/android/app/src/main/res/drawable/joystick_outer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/cross/android/app/src/main/res/drawable/joystick_outer.png -------------------------------------------------------------------------------- /demo/cross/android/app/src/main/res/drawable/left_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/cross/android/app/src/main/res/drawable/left_arrow.png -------------------------------------------------------------------------------- /demo/cross/android/app/src/main/res/drawable/menu_background_color.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /demo/cross/android/app/src/main/res/drawable/pad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/cross/android/app/src/main/res/drawable/pad.png -------------------------------------------------------------------------------- /demo/cross/android/app/src/main/res/drawable/red_pushed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/cross/android/app/src/main/res/drawable/red_pushed.png -------------------------------------------------------------------------------- /demo/cross/android/app/src/main/res/drawable/red_unpushed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/cross/android/app/src/main/res/drawable/red_unpushed.png -------------------------------------------------------------------------------- /demo/cross/android/app/src/main/res/drawable/right_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/cross/android/app/src/main/res/drawable/right_arrow.png -------------------------------------------------------------------------------- /demo/cross/android/app/src/main/res/drawable/stars.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/cross/android/app/src/main/res/drawable/stars.png -------------------------------------------------------------------------------- /demo/cross/android/app/src/main/res/drawable/toolbar_shadow.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 8 | -------------------------------------------------------------------------------- /demo/cross/android/app/src/main/res/drawable/up_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/cross/android/app/src/main/res/drawable/up_arrow.png -------------------------------------------------------------------------------- /demo/cross/android/app/src/main/res/layout/jumpbutton.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /demo/cross/android/app/src/main/res/layout/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /demo/cross/android/app/src/main/res/values-ko-rKR/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Green 4 | -------------------------------------------------------------------------------- /demo/cross/android/app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | #ffffff 8 | #FFF 9 | 10 | -------------------------------------------------------------------------------- /demo/cross/android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Green 4 | 5 | -------------------------------------------------------------------------------- /demo/cross/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /demo/cross/android/app/src/test/java/com/juhang/green/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.juhang.green; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } -------------------------------------------------------------------------------- /demo/cross/android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | google() 6 | mavenCentral() 7 | } 8 | dependencies { 9 | classpath "com.android.tools.build:gradle:7.0.3" 10 | 11 | // NOTE: Do not place your application dependencies here; they belong 12 | // in the individual module build.gradle files 13 | // classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' 14 | } 15 | } 16 | 17 | allprojects { 18 | repositories { 19 | google() // and here 20 | jcenter() 21 | } 22 | } 23 | 24 | task clean(type: Delete) { 25 | delete rootProject.buildDir 26 | } 27 | -------------------------------------------------------------------------------- /demo/cross/android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | # VERSION_NAME 21 | VERSION=1.9.7 22 | 23 | # VERSION_CODE={yyMMdd}$BUILD e.g. The second build of National Day: 16100102 24 | BUILD=09 -------------------------------------------------------------------------------- /demo/cross/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/cross/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /demo/cross/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Jan 03 17:32:07 KST 2023 2 | distributionBase=GRADLE_USER_HOME 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /demo/cross/android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /demo/cross/data/Makefile: -------------------------------------------------------------------------------- 1 | OUTPUT := ../generated 2 | GENERATED := $(OUTPUT)/tiles.h $(OUTPUT)/player.h $(OUTPUT)/enemy.h $(OUTPUT)/map.h 3 | 4 | all: $(GENERATED) 5 | 6 | $(OUTPUT)/tiles.h: tiles.png 7 | python3.9 ../../../tools/png2tiles.py -i tiles $< > $@ 8 | 9 | $(OUTPUT)/player.h: player.png 10 | python3.9 ../../../tools/png2sprites.py -i player_sprite $< > $@ 11 | 12 | $(OUTPUT)/enemy.h: enemy.png 13 | python3.9 ../../../tools/png2sprites.py -i enemy_sprite $< > $@ 14 | 15 | $(OUTPUT)/map.h: map.json map_conf.json 16 | python3.9 ../../../tools/map.py --aplib --max-ents 11 --room-height 21 map.json map > $@ 17 | 18 | .PHONY: all clean 19 | clean: 20 | rm -f $(OUTPUT)/* 21 | 22 | -------------------------------------------------------------------------------- /demo/cross/data/effects.aks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/cross/data/effects.aks -------------------------------------------------------------------------------- /demo/cross/data/enemy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/cross/data/enemy.png -------------------------------------------------------------------------------- /demo/cross/data/enemy3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/cross/data/enemy3.png -------------------------------------------------------------------------------- /demo/cross/data/gameover.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/cross/data/gameover.ogg -------------------------------------------------------------------------------- /demo/cross/data/ingame.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/cross/data/ingame.ogg -------------------------------------------------------------------------------- /demo/cross/data/map_conf.json: -------------------------------------------------------------------------------- 1 | { 2 | "entities": [ 3 | { 4 | "bytes": 0, 5 | "name": "unused", 6 | "w": 1 7 | }, 8 | { 9 | "bytes": 0, 10 | "name": "player", 11 | "w": 1 12 | }, 13 | { 14 | "bytes": 0, 15 | "name": "enemy", 16 | "w": 1 17 | } 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /demo/cross/data/player.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/cross/data/player.png -------------------------------------------------------------------------------- /demo/cross/data/song.aks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/cross/data/song.aks -------------------------------------------------------------------------------- /demo/cross/data/tiles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/cross/data/tiles.png -------------------------------------------------------------------------------- /demo/cross/data/tiles2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/cross/data/tiles2.png -------------------------------------------------------------------------------- /demo/cross/msvc/.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Object files 5 | *.o 6 | *.ko 7 | *.obj 8 | *.elf 9 | 10 | # Linker output 11 | *.ilk 12 | *.map 13 | *.exp 14 | 15 | # Precompiled Headers 16 | *.gch 17 | *.pch 18 | 19 | # Libraries 20 | *.lib 21 | *.a 22 | *.la 23 | *.lo 24 | 25 | # Shared objects (inc. Windows DLLs) 26 | *.dll 27 | *.so 28 | *.so.* 29 | *.dylib 30 | 31 | # Executables 32 | *.exe 33 | *.out 34 | *.app 35 | *.i*86 36 | *.x86_64 37 | *.hex 38 | 39 | # Debug files 40 | *.dSYM/ 41 | *.su 42 | *.idb 43 | *.pdb 44 | 45 | # Kernel Module Compile Results 46 | *.mod* 47 | *.cmd 48 | .tmp_versions/ 49 | modules.order 50 | Module.symvers 51 | Mkfile.old 52 | dkms.conf 53 | 54 | bin 55 | build 56 | generated 57 | *.lst 58 | *.sym 59 | *.rel 60 | *.bak 61 | Debug 62 | .vs 63 | Release -------------------------------------------------------------------------------- /demo/cross/msvc/green4dos/.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Object files 5 | *.o 6 | *.ko 7 | *.obj 8 | *.elf 9 | 10 | # Linker output 11 | *.ilk 12 | *.map 13 | *.exp 14 | 15 | # Precompiled Headers 16 | *.gch 17 | *.pch 18 | 19 | # Libraries 20 | *.lib 21 | *.a 22 | *.la 23 | *.lo 24 | 25 | # Shared objects (inc. Windows DLLs) 26 | *.dll 27 | *.so 28 | *.so.* 29 | *.dylib 30 | 31 | # Executables 32 | *.exe 33 | *.out 34 | *.app 35 | *.i*86 36 | *.x86_64 37 | *.hex 38 | 39 | # Debug files 40 | *.dSYM/ 41 | *.su 42 | *.idb 43 | *.pdb 44 | 45 | # Kernel Module Compile Results 46 | *.mod* 47 | *.cmd 48 | .tmp_versions/ 49 | modules.order 50 | Module.symvers 51 | Mkfile.old 52 | dkms.conf 53 | 54 | bin 55 | build 56 | generated 57 | *.lst 58 | *.sym 59 | *.rel 60 | *.bak 61 | Debug 62 | .vs 63 | Release 64 | thirdparty -------------------------------------------------------------------------------- /demo/cross/msvc/green4dos/green.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "green"=.\green.dsp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Global: 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<3> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | -------------------------------------------------------------------------------- /demo/cross/msvc/green4dos/green4dos.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | ../../data 5 | WindowsLocalDebugger 6 | 7 | 8 | ../../data 9 | WindowsLocalDebugger 10 | 11 | -------------------------------------------------------------------------------- /demo/cross/msvc/green4win32/green4win32.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(ProjectDir)/../../data 5 | WindowsLocalDebugger 6 | 7 | 8 | $(ProjectDir)/../../data 9 | WindowsLocalDebugger 10 | 11 | -------------------------------------------------------------------------------- /demo/cross/msvc/src/ubox_mplayer_sdl.c: -------------------------------------------------------------------------------- 1 | #include "mplayer.h" 2 | #if defined(WIN32) && !defined(HXWIN32) 3 | #include 4 | #include "SDL2/SDL_mixer.h" 5 | #else 6 | #include 7 | #include "SDL_mixer.h" 8 | #endif 9 | #include "main.h" 10 | 11 | uint8_t SONG[] = { 0,0,0,0,0 }; 12 | uint8_t EFFECTS[] = { 0,0,0,0,0 }; 13 | 14 | Mix_Music* ingame = 0; 15 | Mix_Music* gameover = 0; 16 | 17 | void mplayer_init(uint8_t* song, uint8_t sub_song) 18 | { 19 | #if !defined(HXWIN32) 20 | if (Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 1024) < 0) { 21 | SDL_QuitSubSystem(SDL_INIT_AUDIO); 22 | return; 23 | } 24 | 25 | if (SONG_IN_GAME == sub_song) 26 | { 27 | if (!ingame) 28 | ingame = Mix_LoadMUS("ingame.ogg"); 29 | 30 | if (Mix_PlayMusic(ingame, -1) == -1) 31 | { 32 | return; 33 | } 34 | } 35 | else if (SONG_GAME_OVER == sub_song) 36 | { 37 | if (!gameover) 38 | gameover = Mix_LoadMUS("gameover.ogg"); 39 | 40 | if (Mix_PlayMusic(gameover, 0) == -1) 41 | { 42 | return; 43 | } 44 | } 45 | else if (SONG_SILENCE == sub_song) 46 | { 47 | Mix_HaltMusic(); 48 | } 49 | #endif 50 | 51 | } 52 | 53 | void mplayer_init_effects(uint8_t* effects) 54 | { 55 | 56 | } 57 | 58 | void mplayer_play() 59 | { 60 | 61 | } 62 | 63 | void mplayer_stop() 64 | { 65 | 66 | } 67 | 68 | 69 | void mplayer_play_effect(uint8_t effect_no, uint8_t chan, uint8_t inv_vol) 70 | { 71 | 72 | } 73 | 74 | 75 | void mplayer_play_effect_p(uint8_t effect_no, uint8_t chan, uint8_t inv_vol) 76 | { 77 | 78 | } 79 | 80 | void mplayer_stop_effect_channel(uint8_t chan) 81 | { 82 | 83 | } 84 | 85 | uint8_t mplayer_is_sound_effect_on(uint8_t chan) 86 | { 87 | return 0; 88 | } 89 | -------------------------------------------------------------------------------- /demo/cross/src/Makefile.deps: -------------------------------------------------------------------------------- 1 | ../build/data.rel: data.c ../generated/tiles.h ../generated/player.h \ 2 | ../generated/enemy.h ../generated/map.h 3 | ../build/game.rel: game.c ../../../include/ubox.h ../../../include/spman.h \ 4 | ../../../include/ubox.h ../../../include/mplayer.h ../../../include/ap.h \ 5 | helpers.h main.h game.h ../generated/map.h ../generated/player.h \ 6 | ../generated/enemy.h 7 | ../build/helpers.rel: helpers.c ../../../include/ubox.h helpers.h 8 | ../build/main.rel: main.c ../../../include/ubox.h ../../../include/mplayer.h \ 9 | helpers.h game.h main.h ../generated/tiles.h -------------------------------------------------------------------------------- /demo/cross/src/akm.z80: -------------------------------------------------------------------------------- 1 | ; 2 | ; to build the custom AKM player with song + effects 3 | ; 4 | 5 | include "song_playerconfig.asm" 6 | include "effects_playerconfig.asm" 7 | 8 | include "../../../src/mplayer/akm/akm_ubox.asm" 9 | 10 | songDisarkGenerateExternalLabel: 11 | include "song.asm" 12 | 13 | effectsDisarkGenerateExternalLabel: 14 | include "effects.asm" 15 | 16 | -------------------------------------------------------------------------------- /demo/cross/src/crt0.z80: -------------------------------------------------------------------------------- 1 | .module crt0 2 | .globl _main 3 | 4 | .area _HOME 5 | .area _CODE 6 | .area _INITIALIZER 7 | .area _GSINIT 8 | .area _GSFINAL 9 | 10 | .area _DATA 11 | .area _INITIALIZED 12 | .area _BSEG 13 | .area _BSS 14 | .area _HEAP 15 | 16 | .area _CODE 17 | 18 | ENASLT = 0x0024 19 | RSLREG = 0x0138 20 | CLIKSW = 0xf3db 21 | 22 | ; ROM header 23 | .str "AB" 24 | .dw _main_init 25 | .db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 26 | 27 | _main_init:: 28 | 29 | ; init the stack 30 | di 31 | ld sp, #0xf380 32 | ei 33 | 34 | ; setup memory 35 | ; ref: https://www.msx.org/forum/msx-talk/development/memory-pages-again 36 | 37 | call RSLREG 38 | rrca 39 | rrca 40 | and #3 41 | ld c, a 42 | add a, #0xc1 43 | ld l, a 44 | ld h, #0xfc 45 | ld a, (hl) 46 | and #0x80 47 | or c 48 | ld c, a 49 | inc l 50 | inc l 51 | inc l 52 | inc l 53 | ld a, (hl) 54 | and #0x0c 55 | or c 56 | ld h, #0x80 57 | call ENASLT 58 | 59 | ; disable key click sound 60 | xor a 61 | ld (CLIKSW), a 62 | 63 | call gsinit 64 | call _main 65 | 66 | halt0: 67 | halt 68 | jr halt0 69 | 70 | .area _GSINIT 71 | gsinit:: 72 | ld bc, #l__INITIALIZER 73 | ld a, b 74 | or a, c 75 | jr Z, gsinit_next 76 | ld de, #s__INITIALIZED 77 | ld hl, #s__INITIALIZER 78 | ldir 79 | gsinit_next: 80 | 81 | .area _GSFINAL 82 | ret 83 | -------------------------------------------------------------------------------- /demo/cross/src/data.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Module storing the generated data. 3 | */ 4 | 5 | #define LOCAL 6 | #include "tiles.h" 7 | #include "player.h" 8 | #include "enemy.h" 9 | #include "map.h" 10 | 11 | 12 | #if defined(HXWIN32) 13 | 14 | #ifdef _M_IX86 // following functions are needed only for 32-bit architecture 15 | 16 | __declspec(naked) void _ftol2() 17 | { 18 | __asm 19 | { 20 | fistp qword ptr[esp - 8] 21 | mov edx, [esp - 4] 22 | mov eax, [esp - 8] 23 | ret 24 | } 25 | } 26 | 27 | __declspec(naked) void _ftol2_sse() 28 | { 29 | __asm 30 | { 31 | fistp dword ptr[esp - 4] 32 | mov eax, [esp - 4] 33 | ret 34 | } 35 | } 36 | 37 | #endif 38 | #endif 39 | -------------------------------------------------------------------------------- /demo/cross/src/effects_playerconfig.asm: -------------------------------------------------------------------------------- 1 | ; Configuration that can be included to Arkos Tracker 2 players. 2 | ; It indicates what parts of code are useful to the song/sound effects, to save both memory and CPU. 3 | ; The players may or may not take advantage of these flags, it is up to them. 4 | 5 | ; You can either: 6 | ; - Include this to the source that also includes the player (BEFORE the player is included) (recommended solution). 7 | ; - Include this at the beginning of the player code. 8 | ; - Copy/paste this directly in the player. 9 | ; If you use one player but several songs, don't worry, these declarations will stack up. 10 | ; If no configuration is used, the player will use default values (full code used). 11 | 12 | PLY_CFG_SFX_ConfigurationIsPresent = 1 13 | PLY_CFG_SFX_SoftOnly = 1 14 | PLY_CFG_SFX_SoftOnly_Noise = 1 15 | -------------------------------------------------------------------------------- /demo/cross/src/helpers.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "ubox.h" 4 | 5 | #include "helpers.h" 6 | 7 | /** 8 | * Put a zero terminated string on the screen using tiles. 9 | * 10 | * The font starts on the tileset on tile 128 and the fist char in our has 11 | * ASCII value 31, so it is adjusted so we can use ASCII *uppercase* directly 12 | * in our C code. 13 | */ 14 | void put_text(uint8_t x, uint8_t y, const uint8_t *text) 15 | { 16 | while (*text) 17 | ubox_put_tile(x++, y, *text++ + 128 - 31); 18 | } 19 | -------------------------------------------------------------------------------- /demo/cross/src/helpers.h: -------------------------------------------------------------------------------- 1 | #ifndef _HELPERS_H 2 | #define _HELPERS_H 3 | 4 | #include 5 | 6 | /** 7 | * Auxiliary functions. 8 | */ 9 | 10 | void put_text(uint8_t x, uint8_t y, const uint8_t *text); 11 | 12 | #endif // _HELPERS_H 13 | -------------------------------------------------------------------------------- /demo/cross/src/main.h: -------------------------------------------------------------------------------- 1 | #ifndef _MAIN_H 2 | #define _MAIN_H 3 | 4 | #include 5 | 6 | #ifndef LOCAL 7 | #define LOCAL extern 8 | #endif 9 | 10 | #define WHITESPACE_TILE 129 11 | 12 | // sub-songs matching our Arkos song 13 | // configure the song to use MSX AY 14 | enum songs 15 | { 16 | SONG_SILENCE = 0, 17 | SONG_IN_GAME, 18 | SONG_GAME_OVER, 19 | }; 20 | 21 | // we will use 0 and 1 for the music 22 | #define EFX_CHAN_NO 2 23 | 24 | // sound effects matching our Arkos efx song 25 | // configure the song to use MSX AY 26 | enum effects 27 | { 28 | EFX_NONE = 0, 29 | EFX_START, 30 | EFX_BATTERY, 31 | EFX_ELEVATOR, 32 | EFX_HIT, 33 | EFX_DEAD, 34 | }; 35 | 36 | void draw_end_game(); 37 | void draw_menu(); 38 | 39 | // store the selected control 40 | LOCAL uint8_t ctl; 41 | 42 | // Arkos data 43 | extern uint8_t SONG[]; 44 | extern uint8_t EFFECTS[]; 45 | 46 | #ifdef LOCAL 47 | #undef LOCAL 48 | #endif 49 | 50 | #endif // _MAIN_H 51 | -------------------------------------------------------------------------------- /demo/cross/src/song_playerconfig.asm: -------------------------------------------------------------------------------- 1 | ; Configuration that can be included to Arkos Tracker 2 players. 2 | ; It indicates what parts of code are useful to the song/sound effects, to save both memory and CPU. 3 | ; The players may or may not take advantage of these flags, it is up to them. 4 | 5 | ; You can either: 6 | ; - Include this to the source that also includes the player (BEFORE the player is included) (recommended solution). 7 | ; - Include this at the beginning of the player code. 8 | ; - Copy/paste this directly in the player. 9 | ; If you use one player but several songs, don't worry, these declarations will stack up. 10 | ; If no configuration is used, the player will use default values (full code used). 11 | 12 | PLY_CFG_ConfigurationIsPresent = 1 13 | PLY_CFG_NoSoftNoHard = 1 14 | PLY_CFG_SoftOnly = 1 15 | PLY_CFG_SoftOnly_Noise = 1 16 | PLY_CFG_SoftOnly_SoftwareArpeggio = 1 17 | PLY_CFG_SoftOnly_SoftwarePitch = 1 18 | -------------------------------------------------------------------------------- /demo/cross/yuza/.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Object files 5 | *.o 6 | *.ko 7 | *.obj 8 | *.elf 9 | 10 | # Linker output 11 | *.ilk 12 | *.map 13 | *.exp 14 | 15 | # Precompiled Headers 16 | *.gch 17 | *.pch 18 | 19 | # Libraries 20 | *.lib 21 | *.a 22 | *.la 23 | *.lo 24 | 25 | # Shared objects (inc. Windows DLLs) 26 | *.dll 27 | *.so 28 | *.so.* 29 | *.dylib 30 | 31 | # Executables 32 | *.exe 33 | *.out 34 | *.app 35 | *.i*86 36 | *.x86_64 37 | *.hex 38 | 39 | # Debug files 40 | *.dSYM/ 41 | *.su 42 | *.idb 43 | *.pdb 44 | 45 | # Kernel Module Compile Results 46 | *.mod* 47 | *.cmd 48 | .tmp_versions/ 49 | modules.order 50 | Module.symvers 51 | Mkfile.old 52 | dkms.conf 53 | 54 | bin 55 | build 56 | generated 57 | *.lst 58 | *.sym 59 | *.rel 60 | *.bak 61 | Debug 62 | .vs 63 | Release -------------------------------------------------------------------------------- /demo/cross/yuza/green4yuza/green4yuza.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(YUZA_ROOT)/bin 5 | WindowsLocalDebugger 6 | $(YUZA_ROOT)/bin/yuza.exe 7 | 8 | 9 | $(ProjectDir)/../../data 10 | WindowsLocalDebugger 11 | 12 | -------------------------------------------------------------------------------- /demo/pyramid/Makefile: -------------------------------------------------------------------------------- 1 | export PATH := $(PWD)/../../bin:$(PATH) 2 | 3 | all: generated bin build 4 | make -C data 5 | cd src && python ../tools/mkdeps.py -b ../build -I ../generated:../../../include ./ Makefile.deps 6 | make -C src 7 | 8 | generated: 9 | mkdir -p ./generated 10 | 11 | bin: 12 | mkdir -p ./bin 13 | 14 | build: 15 | mkdir -p ./build 16 | 17 | .PHONY: all clean 18 | clean: 19 | rm -rf ./generated ./bin ./build 20 | make -C src clean 21 | make -C data clean 22 | 23 | -------------------------------------------------------------------------------- /demo/pyramid/data/Makefile: -------------------------------------------------------------------------------- 1 | OUTPUT := ../generated 2 | GENERATED := $(OUTPUT)/tiles.h $(OUTPUT)/player.h $(OUTPUT)/enemy.h $(OUTPUT)/foothold.h $(OUTPUT)/map.h $(OUTPUT)/map_summary.h 3 | 4 | all: $(GENERATED) 5 | 6 | $(OUTPUT)/tiles.h: tiles.png 7 | python ../tools/png2tiles.py -i tiles $< > $@ 8 | 9 | $(OUTPUT)/player.h: player.png 10 | python ../tools/png2sprites.py -i player_sprite $< > $@ 11 | 12 | $(OUTPUT)/enemy.h: enemy.png 13 | python ../tools/png2sprites.py -i enemy_sprite $< > $@ 14 | 15 | $(OUTPUT)/foothold.h: foothold.png 16 | python ../tools/png2sprites.py -i foothold $< > $@ 17 | 18 | $(OUTPUT)/map.h: 19 | python ../tools/map_generate.py > $@ 20 | 21 | $(OUTPUT)/map_summary.h: 22 | python ../tools/map_summary.py map_summary > $@ 23 | 24 | .PHONY: all clean 25 | clean: 26 | rm -f $(OUTPUT)/* 27 | 28 | -------------------------------------------------------------------------------- /demo/pyramid/data/effects.aks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/pyramid/data/effects.aks -------------------------------------------------------------------------------- /demo/pyramid/data/enemy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/pyramid/data/enemy.png -------------------------------------------------------------------------------- /demo/pyramid/data/foothold.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/pyramid/data/foothold.png -------------------------------------------------------------------------------- /demo/pyramid/data/ladder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/pyramid/data/ladder.png -------------------------------------------------------------------------------- /demo/pyramid/data/map_conf.json: -------------------------------------------------------------------------------- 1 | { 2 | "entities": [ 3 | { 4 | "bytes": 0, 5 | "name": "unused", 6 | "w": 1 7 | }, 8 | { 9 | "bytes": 0, 10 | "name": "player", 11 | "w": 1 12 | }, 13 | { 14 | "bytes": 0, 15 | "name": "enemy", 16 | "w": 1 17 | }, 18 | { 19 | "bytes": 0, 20 | "name": "exit", 21 | "w": 1 22 | }, 23 | { 24 | "bytes": 0, 25 | "name": "key", 26 | "w": 1 27 | }, 28 | { 29 | "bytes": 0, 30 | "name": "warp", 31 | "w": 1 32 | }, 33 | { 34 | "bytes": 0, 35 | "name": "foothold", 36 | "w": 1 37 | } 38 | ] 39 | } 40 | -------------------------------------------------------------------------------- /demo/pyramid/data/player.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/pyramid/data/player.png -------------------------------------------------------------------------------- /demo/pyramid/data/player1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/pyramid/data/player1.png -------------------------------------------------------------------------------- /demo/pyramid/data/song.aks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/pyramid/data/song.aks -------------------------------------------------------------------------------- /demo/pyramid/data/tiles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/pyramid/data/tiles.png -------------------------------------------------------------------------------- /demo/pyramid/data/tiles_backup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/pyramid/data/tiles_backup.png -------------------------------------------------------------------------------- /demo/pyramid/data/tiles_backup3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/pyramid/data/tiles_backup3.png -------------------------------------------------------------------------------- /demo/pyramid/src/Makefile.deps: -------------------------------------------------------------------------------- 1 | ../build/data.rel: data.c ../generated/tiles.h ../generated/player.h \ 2 | ../generated/enemy.h ../generated/foothold.h ../generated/map_summary.h \ 3 | ../generated/map.h 4 | ../build/enemy_logic.rel: enemy_logic.c enemy_logic.h game.h game_util.h \ 5 | ../../../include/spman.h ../../../include/ubox.h \ 6 | ../../../include/mplayer.h main.h 7 | ../build/exit_logic.rel: exit_logic.c exit_logic.h game.h game_util.h \ 8 | ../../../include/spman.h ../../../include/ubox.h 9 | ../build/foothold_logic.rel: foothold_logic.c game.h game_util.h \ 10 | ../../../include/spman.h ../../../include/ubox.h 11 | ../build/game.rel: game.c ../../../include/ubox.h ../../../include/spman.h \ 12 | ../../../include/ubox.h ../../../include/mplayer.h ../../../include/ap.h \ 13 | helpers.h main.h game.h ../generated/map_summary.h ../generated/player.h \ 14 | ../generated/enemy.h ../generated/foothold.h foothold_logic.h \ 15 | enemy_logic.h player_logic.h exit_logic.h warp_logic.h item_logic.h 16 | ../build/game_util.rel: game_util.c game_util.h game.h ../../../include/ubox.h 17 | ../build/helpers.rel: helpers.c ../../../include/ubox.h helpers.h 18 | ../build/item_logic.rel: item_logic.c item_logic.h game_util.h 19 | ../build/main.rel: main.c ../../../include/ubox.h ../../../include/mplayer.h \ 20 | helpers.h game.h ../generated/map_summary.h ../generated/tiles.h main.h 21 | ../build/player_logic.rel: player_logic.c player_logic.h game.h game_util.h \ 22 | ../../../include/spman.h ../../../include/ubox.h \ 23 | ../../../include/mplayer.h main.h foothold_logic.h 24 | ../build/warp_logic.rel: warp_logic.c warp_logic.h game_util.h -------------------------------------------------------------------------------- /demo/pyramid/src/akm.z80: -------------------------------------------------------------------------------- 1 | ; 2 | ; to build the custom AKM player with song + effects 3 | ; 4 | 5 | include "song_playerconfig.asm" 6 | include "effects_playerconfig.asm" 7 | 8 | include "../../../src/mplayer/akm/akm_ubox.asm" 9 | 10 | songDisarkGenerateExternalLabel: 11 | include "song.asm" 12 | 13 | effectsDisarkGenerateExternalLabel: 14 | include "effects.asm" 15 | 16 | -------------------------------------------------------------------------------- /demo/pyramid/src/crt0.z80: -------------------------------------------------------------------------------- 1 | .module crt0 2 | .globl _main 3 | 4 | .area _HOME 5 | .area _CODE 6 | .area _INITIALIZER 7 | .area _GSINIT 8 | .area _GSFINAL 9 | 10 | .area _DATA 11 | .area _INITIALIZED 12 | .area _BSEG 13 | .area _BSS 14 | .area _HEAP 15 | 16 | .area _CODE 17 | 18 | ENASLT = 0x0024 19 | RSLREG = 0x0138 20 | CLIKSW = 0xf3db 21 | 22 | ; ROM header 23 | .str "AB" 24 | .dw _main_init 25 | .db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 26 | 27 | _main_init:: 28 | 29 | ; init the stack 30 | di 31 | ld sp, #0xf380 32 | ei 33 | 34 | ; setup memory 35 | ; ref: https://www.msx.org/forum/msx-talk/development/memory-pages-again 36 | 37 | call RSLREG 38 | rrca 39 | rrca 40 | and #3 41 | ld c, a 42 | add a, #0xc1 43 | ld l, a 44 | ld h, #0xfc 45 | ld a, (hl) 46 | and #0x80 47 | or c 48 | ld c, a 49 | inc l 50 | inc l 51 | inc l 52 | inc l 53 | ld a, (hl) 54 | and #0x0c 55 | or c 56 | ld h, #0x80 57 | call ENASLT 58 | 59 | ; disable key click sound 60 | xor a 61 | ld (CLIKSW), a 62 | 63 | call gsinit 64 | call _main 65 | 66 | halt0: 67 | halt 68 | jr halt0 69 | 70 | .area _GSINIT 71 | gsinit:: 72 | ld bc, #l__INITIALIZER 73 | ld a, b 74 | or a, c 75 | jr Z, gsinit_next 76 | ld de, #s__INITIALIZED 77 | ld hl, #s__INITIALIZER 78 | ldir 79 | gsinit_next: 80 | 81 | .area _GSFINAL 82 | ret 83 | -------------------------------------------------------------------------------- /demo/pyramid/src/data.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Module storing the generated data. 3 | */ 4 | 5 | #define LOCAL 6 | #include "tiles.h" 7 | #include "player.h" 8 | #include "enemy.h" 9 | #include "foothold.h" 10 | #include "map_summary.h" 11 | 12 | -------------------------------------------------------------------------------- /demo/pyramid/src/effects_playerconfig.asm: -------------------------------------------------------------------------------- 1 | ; Configuration that can be included to Arkos Tracker 2 players. 2 | ; It indicates what parts of code are useful to the song/sound effects, to save both memory and CPU. 3 | ; The players may or may not take advantage of these flags, it is up to them. 4 | 5 | ; You can either: 6 | ; - Include this to the source that also includes the player (BEFORE the player is included) (recommended solution). 7 | ; - Include this at the beginning of the player code. 8 | ; - Copy/paste this directly in the player. 9 | ; If you use one player but several songs, don't worry, these declarations will stack up. 10 | ; If no configuration is used, the player will use default values (full code used). 11 | 12 | PLY_CFG_SFX_ConfigurationIsPresent = 1 13 | PLY_CFG_SFX_SoftOnly = 1 14 | PLY_CFG_SFX_SoftOnly_Noise = 1 15 | -------------------------------------------------------------------------------- /demo/pyramid/src/enemy_logic.h: -------------------------------------------------------------------------------- 1 | #ifndef _ENEMY_LOGIC_H 2 | #define _ENEMY_LOGIC_H 3 | #include 4 | 5 | void update_enemy(); 6 | 7 | #endif -------------------------------------------------------------------------------- /demo/pyramid/src/exit_logic.c: -------------------------------------------------------------------------------- 1 | #include "exit_logic.h" 2 | #include 3 | #include "game.h" 4 | #include "game_util.h" 5 | #include 6 | 7 | void update_exit() 8 | { 9 | if (jewels != 0) 10 | return; 11 | 12 | if (self->roomId != g_cur_room_id) 13 | return; 14 | 15 | static uint8_t index = 0; 16 | if (self->delay++ == FRAME_WAIT) 17 | { 18 | self->delay = 0; 19 | index++; 20 | if (index > 1) 21 | index = 0; 22 | 23 | if (index == 1) 24 | { 25 | ubox_put_tile((self->x >> 3), (self->y >> 3), WARP_TILE + 2); 26 | ubox_put_tile((self->x >> 3) + 1, (self->y >> 3), WARP_TILE + 3); 27 | ubox_put_tile((self->x >> 3), (self->y >> 3) + 1, WARP_TILE); 28 | ubox_put_tile((self->x >> 3) + 1, (self->y >> 3) + 1, WARP_TILE + 1); 29 | } 30 | 31 | else 32 | { 33 | ubox_put_tile((self->x >> 3), (self->y >> 3), EXIT_TILE + 2); 34 | ubox_put_tile((self->x >> 3) + 1, (self->y >> 3), EXIT_TILE + 3); 35 | ubox_put_tile((self->x >> 3), (self->y >> 3) + 1, EXIT_TILE); 36 | ubox_put_tile((self->x >> 3) + 1, (self->y >> 3) + 1, EXIT_TILE + 1); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /demo/pyramid/src/exit_logic.h: -------------------------------------------------------------------------------- 1 | #ifndef _EXIT_LOGIC_H 2 | #define _EXIT_LOGIC_H 3 | 4 | void update_exit(); 5 | 6 | #endif -------------------------------------------------------------------------------- /demo/pyramid/src/foothold_logic.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "game.h" 3 | #include "game_util.h" 4 | #include 5 | 6 | 7 | #define FOOTHOLD_DELAY 36 8 | 9 | void update_foothold() 10 | { 11 | if (self->delay > 0) 12 | { 13 | self->delay--; 14 | } 15 | else 16 | { 17 | if (self->dir) 18 | { 19 | if (is_map_blocked(self->x, self->y + 7)) 20 | { 21 | self->delay = FOOTHOLD_DELAY; 22 | self->dir ^= 1; 23 | } 24 | else 25 | self->x -= 1; 26 | } 27 | else 28 | { 29 | if (is_map_blocked(self->x + 15, self->y + 7)) 30 | { 31 | self->delay = FOOTHOLD_DELAY; 32 | self->dir ^= 1; 33 | } 34 | else 35 | self->x += 1; 36 | } 37 | } 38 | 39 | if (g_cur_room_id == self->roomId) 40 | { 41 | sp.x = self->x; 42 | sp.y = self->y - 1; 43 | 44 | sp.pattern = self->pat; 45 | sp.attr = 10; 46 | spman_alloc_fixed_sprite(&sp); 47 | } 48 | } -------------------------------------------------------------------------------- /demo/pyramid/src/foothold_logic.h: -------------------------------------------------------------------------------- 1 | #ifndef _FOOTHOLD_LOGIC_H 2 | #define _FOOTHOLD_LOGIC_H 3 | #include 4 | 5 | void update_foothold(); 6 | 7 | #endif -------------------------------------------------------------------------------- /demo/pyramid/src/game_util.h: -------------------------------------------------------------------------------- 1 | #ifndef _GAME_UTIL_H 2 | #define _GAME_UTIL_H 3 | #include 4 | 5 | uint8_t is_map_blocked(uint8_t x, uint8_t y); 6 | uint8_t is_map_jewel(uint8_t x, uint8_t y); 7 | uint8_t check_floor(uint8_t x, uint8_t y); 8 | struct entity *find_object(uint8_t id); 9 | struct entity* check_foothold(uint8_t x, uint8_t y); 10 | extern struct entity *find_collide_object(uint8_t x, uint8_t y, int type); 11 | 12 | #endif -------------------------------------------------------------------------------- /demo/pyramid/src/helpers.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "ubox.h" 4 | 5 | #include "helpers.h" 6 | 7 | /** 8 | * Put a zero terminated string on the screen using tiles. 9 | * 10 | * The font starts on the tileset on tile 128 and the fist char in our has 11 | * ASCII value 31, so it is adjusted so we can use ASCII *uppercase* directly 12 | * in our C code. 13 | */ 14 | void put_text(uint8_t x, uint8_t y, const uint8_t *text) 15 | { 16 | while (*text) 17 | ubox_put_tile(x++, y, *text++ + 128 - 31); 18 | } 19 | -------------------------------------------------------------------------------- /demo/pyramid/src/helpers.h: -------------------------------------------------------------------------------- 1 | #ifndef _HELPERS_H 2 | #define _HELPERS_H 3 | 4 | #include 5 | 6 | /** 7 | * Auxiliary functions. 8 | */ 9 | 10 | void put_text(uint8_t x, uint8_t y, const uint8_t *text); 11 | 12 | #endif // _HELPERS_H 13 | -------------------------------------------------------------------------------- /demo/pyramid/src/item_logic.c: -------------------------------------------------------------------------------- 1 | #include "item_logic.h" 2 | #include "game_util.h" 3 | 4 | void update_item() 5 | { 6 | } -------------------------------------------------------------------------------- /demo/pyramid/src/item_logic.h: -------------------------------------------------------------------------------- 1 | #ifndef _ITEM_LOGIC_H 2 | #define _ITEM_LOGIC_H 3 | #include 4 | 5 | void update_item(); 6 | 7 | #endif -------------------------------------------------------------------------------- /demo/pyramid/src/main.h: -------------------------------------------------------------------------------- 1 | #ifndef _MAIN_H 2 | #define _MAIN_H 3 | 4 | #include 5 | 6 | #ifndef LOCAL 7 | #define LOCAL extern 8 | #endif 9 | 10 | #define WHITESPACE_TILE 129 11 | 12 | // sub-songs matching our Arkos song 13 | // configure the song to use MSX AY 14 | enum songs 15 | { 16 | SONG_SILENCE = 0, 17 | SONG_IN_GAME, 18 | SONG_GAME_OVER, 19 | }; 20 | 21 | // we will use 0 and 1 for the music 22 | #define EFX_CHAN_NO 2 23 | 24 | // sound effects matching our Arkos efx song 25 | // configure the song to use MSX AY 26 | enum effects 27 | { 28 | EFX_NONE = 0, 29 | EFX_START, 30 | EFX_BATTERY, 31 | EFX_ELEVATOR, 32 | EFX_HIT, 33 | EFX_DEAD, 34 | }; 35 | 36 | void draw_end_game(); 37 | void draw_menu(); 38 | 39 | // store the selected control 40 | LOCAL uint8_t ctl; 41 | 42 | // Arkos data 43 | extern uint8_t SONG[]; 44 | extern uint8_t EFFECTS[]; 45 | 46 | #ifdef LOCAL 47 | #undef LOCAL 48 | #endif 49 | 50 | #endif // _MAIN_H 51 | -------------------------------------------------------------------------------- /demo/pyramid/src/player_logic.h: -------------------------------------------------------------------------------- 1 | #ifndef _PLAYER_LOGIC_H 2 | #define _PLAYER_LOGIC_H 3 | #include 4 | 5 | void update_player(); 6 | 7 | 8 | #endif -------------------------------------------------------------------------------- /demo/pyramid/src/song_playerconfig.asm: -------------------------------------------------------------------------------- 1 | ; Configuration that can be included to Arkos Tracker 2 players. 2 | ; It indicates what parts of code are useful to the song/sound effects, to save both memory and CPU. 3 | ; The players may or may not take advantage of these flags, it is up to them. 4 | 5 | ; You can either: 6 | ; - Include this to the source that also includes the player (BEFORE the player is included) (recommended solution). 7 | ; - Include this at the beginning of the player code. 8 | ; - Copy/paste this directly in the player. 9 | ; If you use one player but several songs, don't worry, these declarations will stack up. 10 | ; If no configuration is used, the player will use default values (full code used). 11 | 12 | PLY_CFG_ConfigurationIsPresent = 1 13 | PLY_CFG_NoSoftNoHard = 1 14 | PLY_CFG_SoftOnly = 1 15 | PLY_CFG_SoftOnly_Noise = 1 16 | PLY_CFG_SoftOnly_SoftwareArpeggio = 1 17 | PLY_CFG_SoftOnly_SoftwarePitch = 1 18 | -------------------------------------------------------------------------------- /demo/pyramid/src/warp_logic.c: -------------------------------------------------------------------------------- 1 | #include "warp_logic.h" 2 | #include "game_util.h" 3 | 4 | void update_warp() 5 | { 6 | } 7 | -------------------------------------------------------------------------------- /demo/pyramid/src/warp_logic.h: -------------------------------------------------------------------------------- 1 | #ifndef _WARP_LOGIC_H 2 | #define _WARP_LOGIC_H 3 | #include 4 | 5 | void update_warp(); 6 | 7 | #endif -------------------------------------------------------------------------------- /demo/pyramid/tools/map_generate.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from argparse import ArgumentParser 4 | from collections import defaultdict 5 | from os import path 6 | import json 7 | import os 8 | import subprocess 9 | import struct 10 | import sys 11 | import tempfile 12 | import traceback 13 | import subprocess 14 | import os.path 15 | 16 | __version__ = "1.0" 17 | 18 | MAX_LEVEL = 100 19 | 20 | 21 | def main(): 22 | for j in range(1, MAX_LEVEL): 23 | mapname = "map%d" % (j) 24 | mapjson = "map%d.json" % (j) 25 | if os.path.isfile(mapjson) == 0: 26 | break 27 | directive = "python3.9 ../tools/map.py --aplib --room-width 32 --room-height 21 %s %s" % (mapjson, mapname) 28 | subprocess.run(directive, shell=True) 29 | 30 | 31 | if __name__ == "__main__": 32 | remove_list = [] 33 | 34 | try: 35 | main() 36 | except Exception as ex: 37 | print("FATAL: %s\n***" % ex, file=sys.stderr) 38 | traceback.print_exc() 39 | 40 | for filename in remove_list: 41 | if os.path.exists(filename): 42 | os.unlink(filename) 43 | 44 | sys.exit(1) 45 | -------------------------------------------------------------------------------- /demo/scroll/Makefile: -------------------------------------------------------------------------------- 1 | export PATH := $(PWD)/../../bin:$(PATH) 2 | 3 | all: generated bin build 4 | make -C data 5 | cd src && python ../../../tools/mkdeps.py -b ../build -I ../generated:../../../include ./ Makefile.deps 6 | make -C src 7 | 8 | generated: 9 | mkdir -p ./generated 10 | 11 | bin: 12 | mkdir -p ./bin 13 | 14 | build: 15 | mkdir -p ./build 16 | 17 | .PHONY: all clean 18 | clean: 19 | rm -rf ./generated ./bin ./build 20 | make -C src clean 21 | make -C data clean 22 | 23 | -------------------------------------------------------------------------------- /demo/scroll/data/Makefile: -------------------------------------------------------------------------------- 1 | OUTPUT := ../generated 2 | GENERATED := $(OUTPUT)/tiles.h $(OUTPUT)/player.h $(OUTPUT)/enemy.h $(OUTPUT)/map.h 3 | 4 | all: $(GENERATED) 5 | 6 | $(OUTPUT)/tiles.h: tiles.png 7 | python3.9 ../../../tools/png2tiles.py -i tiles $< > $@ 8 | 9 | $(OUTPUT)/player.h: player.png 10 | python3.9 ../../../tools/png2sprites.py -i player_sprite $< > $@ 11 | 12 | $(OUTPUT)/enemy.h: enemy.png 13 | python3.9 ../../../tools/png2sprites.py -i enemy_sprite $< > $@ 14 | 15 | $(OUTPUT)/map.h: map.json map_conf.json 16 | python3.9 ../../../tools/map.py --aplib --max-ents 11 --room-height 21 map.json map > $@ 17 | 18 | .PHONY: all clean 19 | clean: 20 | rm -f $(OUTPUT)/* 21 | 22 | -------------------------------------------------------------------------------- /demo/scroll/data/effects.aks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/scroll/data/effects.aks -------------------------------------------------------------------------------- /demo/scroll/data/enemy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/scroll/data/enemy.png -------------------------------------------------------------------------------- /demo/scroll/data/enemy3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/scroll/data/enemy3.png -------------------------------------------------------------------------------- /demo/scroll/data/gameover.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/scroll/data/gameover.ogg -------------------------------------------------------------------------------- /demo/scroll/data/ingame.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/scroll/data/ingame.ogg -------------------------------------------------------------------------------- /demo/scroll/data/map_conf.json: -------------------------------------------------------------------------------- 1 | { 2 | "entities": [ 3 | { 4 | "bytes": 0, 5 | "name": "unused", 6 | "w": 1 7 | }, 8 | { 9 | "bytes": 0, 10 | "name": "player", 11 | "w": 1 12 | }, 13 | { 14 | "bytes": 0, 15 | "name": "enemy", 16 | "w": 1 17 | } 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /demo/scroll/data/player.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/scroll/data/player.png -------------------------------------------------------------------------------- /demo/scroll/data/song.aks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/scroll/data/song.aks -------------------------------------------------------------------------------- /demo/scroll/data/test.json: -------------------------------------------------------------------------------- 1 | { "columns":32, 2 | "image":"tiles.png", 3 | "imageheight":64, 4 | "imagewidth":256, 5 | "margin":0, 6 | "name":"tilesets", 7 | "spacing":0, 8 | "tilecount":256, 9 | "tiledversion":"1.7.1", 10 | "tileheight":8, 11 | "tilewidth":8, 12 | "type":"tileset", 13 | "version":"1.6" 14 | } -------------------------------------------------------------------------------- /demo/scroll/data/tiles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/scroll/data/tiles.png -------------------------------------------------------------------------------- /demo/scroll/data/tiles_ori.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/scroll/data/tiles_ori.png -------------------------------------------------------------------------------- /demo/scroll/src/Makefile.deps: -------------------------------------------------------------------------------- 1 | ../build/data.rel: data.c ../generated/tiles.h ../generated/player.h \ 2 | ../generated/enemy.h ../generated/map.h 3 | ../build/game.rel: game.c ../../../include/ubox.h ../../../include/spman.h \ 4 | ../../../include/ubox.h ../../../include/mplayer.h ../../../include/ap.h \ 5 | helpers.h main.h game.h ../generated/map.h ../generated/player.h \ 6 | ../generated/enemy.h 7 | ../build/helpers.rel: helpers.c ../../../include/ubox.h helpers.h 8 | ../build/main.rel: main.c ../../../include/ubox.h ../../../include/mplayer.h \ 9 | helpers.h game.h main.h ../generated/tiles.h -------------------------------------------------------------------------------- /demo/scroll/src/akm.z80: -------------------------------------------------------------------------------- 1 | ; 2 | ; to build the custom AKM player with song + effects 3 | ; 4 | 5 | include "song_playerconfig.asm" 6 | include "effects_playerconfig.asm" 7 | 8 | include "../../../src/mplayer/akm/akm_ubox.asm" 9 | 10 | songDisarkGenerateExternalLabel: 11 | include "song.asm" 12 | 13 | effectsDisarkGenerateExternalLabel: 14 | include "effects.asm" 15 | 16 | -------------------------------------------------------------------------------- /demo/scroll/src/crt0.z80: -------------------------------------------------------------------------------- 1 | .module crt0 2 | .globl _main 3 | 4 | .area _HOME 5 | .area _CODE 6 | .area _INITIALIZER 7 | .area _GSINIT 8 | .area _GSFINAL 9 | 10 | .area _DATA 11 | .area _INITIALIZED 12 | .area _BSEG 13 | .area _BSS 14 | .area _HEAP 15 | 16 | .area _CODE 17 | 18 | ENASLT = 0x0024 19 | RSLREG = 0x0138 20 | CLIKSW = 0xf3db 21 | 22 | ; ROM header 23 | .str "AB" 24 | .dw _main_init 25 | .db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 26 | 27 | _main_init:: 28 | 29 | ; init the stack 30 | di 31 | ld sp, #0xf380 32 | ei 33 | 34 | ; setup memory 35 | ; ref: https://www.msx.org/forum/msx-talk/development/memory-pages-again 36 | 37 | call RSLREG 38 | rrca 39 | rrca 40 | and #3 41 | ld c, a 42 | add a, #0xc1 43 | ld l, a 44 | ld h, #0xfc 45 | ld a, (hl) 46 | and #0x80 47 | or c 48 | ld c, a 49 | inc l 50 | inc l 51 | inc l 52 | inc l 53 | ld a, (hl) 54 | and #0x0c 55 | or c 56 | ld h, #0x80 57 | call ENASLT 58 | 59 | ; disable key click sound 60 | xor a 61 | ld (CLIKSW), a 62 | 63 | call gsinit 64 | call _main 65 | 66 | halt0: 67 | halt 68 | jr halt0 69 | 70 | .area _GSINIT 71 | gsinit:: 72 | ld bc, #l__INITIALIZER 73 | ld a, b 74 | or a, c 75 | jr Z, gsinit_next 76 | ld de, #s__INITIALIZED 77 | ld hl, #s__INITIALIZER 78 | ldir 79 | gsinit_next: 80 | 81 | .area _GSFINAL 82 | ret 83 | -------------------------------------------------------------------------------- /demo/scroll/src/data.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Module storing the generated data. 3 | */ 4 | 5 | #define LOCAL 6 | #include "tiles.h" 7 | #include "player.h" 8 | #include "enemy.h" 9 | #include "map.h" 10 | -------------------------------------------------------------------------------- /demo/scroll/src/effects_playerconfig.asm: -------------------------------------------------------------------------------- 1 | ; Configuration that can be included to Arkos Tracker 2 players. 2 | ; It indicates what parts of code are useful to the song/sound effects, to save both memory and CPU. 3 | ; The players may or may not take advantage of these flags, it is up to them. 4 | 5 | ; You can either: 6 | ; - Include this to the source that also includes the player (BEFORE the player is included) (recommended solution). 7 | ; - Include this at the beginning of the player code. 8 | ; - Copy/paste this directly in the player. 9 | ; If you use one player but several songs, don't worry, these declarations will stack up. 10 | ; If no configuration is used, the player will use default values (full code used). 11 | 12 | PLY_CFG_SFX_ConfigurationIsPresent = 1 13 | PLY_CFG_SFX_SoftOnly = 1 14 | PLY_CFG_SFX_SoftOnly_Noise = 1 15 | -------------------------------------------------------------------------------- /demo/scroll/src/game.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/demo/scroll/src/game.c -------------------------------------------------------------------------------- /demo/scroll/src/helpers.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "ubox.h" 4 | 5 | #include "helpers.h" 6 | 7 | /** 8 | * Put a zero terminated string on the screen using tiles. 9 | * 10 | * The font starts on the tileset on tile 128 and the fist char in our has 11 | * ASCII value 31, so it is adjusted so we can use ASCII *uppercase* directly 12 | * in our C code. 13 | */ 14 | void put_text(uint8_t x, uint8_t y, const uint8_t *text) 15 | { 16 | while (*text) 17 | ubox_put_tile(x++, y, *text++ + 192 - 31); 18 | } 19 | -------------------------------------------------------------------------------- /demo/scroll/src/helpers.h: -------------------------------------------------------------------------------- 1 | #ifndef _HELPERS_H 2 | #define _HELPERS_H 3 | 4 | #include 5 | 6 | /** 7 | * Auxiliary functions. 8 | */ 9 | 10 | void put_text(uint8_t x, uint8_t y, const uint8_t *text); 11 | 12 | #endif // _HELPERS_H 13 | -------------------------------------------------------------------------------- /demo/scroll/src/main.h: -------------------------------------------------------------------------------- 1 | #ifndef _MAIN_H 2 | #define _MAIN_H 3 | 4 | #include 5 | 6 | #ifndef LOCAL 7 | #define LOCAL extern 8 | #endif 9 | 10 | #define WHITESPACE_TILE 159 11 | 12 | // sub-songs matching our Arkos song 13 | // configure the song to use MSX AY 14 | enum songs 15 | { 16 | SONG_SILENCE = 0, 17 | SONG_IN_GAME, 18 | SONG_GAME_OVER, 19 | }; 20 | 21 | // we will use 0 and 1 for the music 22 | #define EFX_CHAN_NO 2 23 | 24 | // sound effects matching our Arkos efx song 25 | // configure the song to use MSX AY 26 | enum effects 27 | { 28 | EFX_NONE = 0, 29 | EFX_START, 30 | EFX_BATTERY, 31 | EFX_ELEVATOR, 32 | EFX_HIT, 33 | EFX_DEAD, 34 | }; 35 | 36 | void draw_end_game(); 37 | void draw_menu(); 38 | 39 | // store the selected control 40 | LOCAL uint8_t ctl; 41 | 42 | // Arkos data 43 | extern uint8_t SONG[]; 44 | extern uint8_t EFFECTS[]; 45 | 46 | #ifdef LOCAL 47 | #undef LOCAL 48 | #endif 49 | 50 | #endif // _MAIN_H 51 | -------------------------------------------------------------------------------- /demo/scroll/src/song_playerconfig.asm: -------------------------------------------------------------------------------- 1 | ; Configuration that can be included to Arkos Tracker 2 players. 2 | ; It indicates what parts of code are useful to the song/sound effects, to save both memory and CPU. 3 | ; The players may or may not take advantage of these flags, it is up to them. 4 | 5 | ; You can either: 6 | ; - Include this to the source that also includes the player (BEFORE the player is included) (recommended solution). 7 | ; - Include this at the beginning of the player code. 8 | ; - Copy/paste this directly in the player. 9 | ; If you use one player but several songs, don't worry, these declarations will stack up. 10 | ; If no configuration is used, the player will use default values (full code used). 11 | 12 | PLY_CFG_ConfigurationIsPresent = 1 13 | PLY_CFG_NoSoftNoHard = 1 14 | PLY_CFG_SoftOnly = 1 15 | PLY_CFG_SoftOnly_Noise = 1 16 | PLY_CFG_SoftOnly_SoftwareArpeggio = 1 17 | PLY_CFG_SoftOnly_SoftwarePitch = 1 18 | -------------------------------------------------------------------------------- /docs/extra.md: -------------------------------------------------------------------------------- 1 | ## Overview 2 | 3 | These are a collection of extra libraries that add functionality that can be 4 | useful when making games, but that are not essential. 5 | 6 | -------------------------------------------------------------------------------- /docs/footer.md: -------------------------------------------------------------------------------- 1 | ----- 2 | **Copyright © 2020-2021 Juan J. Martinez (jjm at usebox.net)** 3 | Licensed [CC BY NC SA 4.0](http://creativecommons.org/licenses/by-nc-sa/4.0/). 4 | -------------------------------------------------------------------------------- /docs/header.html: -------------------------------------------------------------------------------- 1 | 9 | -------------------------------------------------------------------------------- /docs/images/player.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/docs/images/player.png -------------------------------------------------------------------------------- /docs/spman.md: -------------------------------------------------------------------------------- 1 | ## Overview 2 | 3 | **spman** is a simple sprite manager that provides: 4 | 5 | - support for 16x16 sprites. 6 | - an easy way to manage sprite patterns. 7 | - a simple yet effective sprite flicker that allows displaying more than 4 sprites 8 | on the same line, with support for "fixed" sprites that are excluded from 9 | flickering. 10 | 11 | It should be easy to modify and customize (`spman.c` is around 100 lines of code). 12 | 13 | The manager is used as follows: 14 | 15 | 1. Initialize the manager with [spman_init](#spman_init). 16 | 2. Allocate patterns with [spman_alloc](#spman_alloc). This can be done at any 17 | time, is not needed to allocate all the patterns in one go. 18 | 3. In the game loop: 19 | - Allocate sprites to be drawn on screen, using 20 | [spman_alloc_fixed_sprite](#spman_alloc_fixed_sprite) for sprites excluded 21 | from the flicker and [spman_alloc_sprite](#spman_alloc_sprite) for any 22 | other sprite. 23 | - Update the sprites on screen with [spman_update](#spman_update). 24 | 25 | The allocate/update cycle needs to happen per frame, so the flicker function is 26 | effective. The longer between updates, the slower the flickering will be. If 27 | the game updates at least 25/30 FPS, that's good enough for most games. 28 | 29 | There are other functions to flush allocated sprites without updating the 30 | screen, or to hide all the sprites on screen. 31 | 32 | The manager supports all 64 patterns and up to 31 visible sprites (one sprite 33 | is used by the flicker). 34 | 35 | **spman** comes from "Sprite Pattern MANager". 36 | 37 | -------------------------------------------------------------------------------- /emul_start_config.txt: -------------------------------------------------------------------------------- 1 | machine Philips_NMS_8255 2 | ext msxdos2 3 | ext gfx9000 4 | bind F12 cycle videosource 5 | plug joyporta mouse 6 | plug printerport simpl 7 | cart bin/game.rom 8 | -------------------------------------------------------------------------------- /examples/01_hello/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "type": "shell", 6 | "label": "Compile", 7 | "command": "make", 8 | "group": { 9 | "kind": "build", 10 | "isDefault": true 11 | } 12 | }, 13 | { 14 | "type": "shell", 15 | "label": "Run", 16 | "command": "openmsx.exe", 17 | "args": [ 18 | "-script", 19 | "emul_start_config.txt" 20 | ], 21 | "group": { 22 | "kind": "test", 23 | "isDefault": true 24 | } 25 | 26 | } 27 | ], 28 | } -------------------------------------------------------------------------------- /examples/01_hello/Makefile: -------------------------------------------------------------------------------- 1 | all: bin build 2 | make -C src 3 | 4 | export PATH := $(PWD)/../../bin:$(PATH) 5 | 6 | bin: 7 | mkdir -p ./bin 8 | 9 | build: 10 | mkdir -p ./build 11 | 12 | .PHONY: all clean 13 | clean: 14 | rm -rf ./bin ./build 15 | make -C src clean 16 | 17 | 18 | -------------------------------------------------------------------------------- /examples/01_hello/emul_start_config.txt: -------------------------------------------------------------------------------- 1 | machine Philips_NMS_8255 2 | ext msxdos2 3 | ext gfx9000 4 | bind F12 cycle videosource 5 | plug joyporta mouse 6 | plug printerport simpl 7 | cart bin/01_hello.rom 8 | -------------------------------------------------------------------------------- /examples/01_hello/src/Makefile: -------------------------------------------------------------------------------- 1 | TARGET := 01_hello 2 | 3 | CODE := 0x4000 4 | # leaves 222 bytes for AKM player buffer 5 | DATA := 0xc0de 6 | 7 | # HEX, will fill with 0 8 | ROM_MAX := 8000 9 | 10 | OUTPUT := ../build 11 | OBJS := $(patsubst %.c,$(OUTPUT)/%.rel,$(wildcard *.c)) 12 | UBOX_LIBS := $(wildcard ../../../lib/*.lib) 13 | LIBS := -lubox -lspman -lmplayer -lap 14 | 15 | CC := sdcc 16 | AS := sdasz80 17 | AR := sdcclib 18 | CFLAGS := --debug -mz80 --Werror -I../../../include -I../generated --fsigned-char --std-sdcc99 --opt-code-speed 19 | LDFLAGS := -L../../../lib -L. --no-std-crt0 --fomit-frame-pointer 20 | 21 | all: $(OUTPUT)/$(TARGET).rom 22 | python ../../../tools/chksize 8000 4000 $(OUTPUT)/$(TARGET).map 23 | @cp ../bin/$(TARGET).rom ../../bin 24 | 25 | openmsx: all 26 | openmsx -carta $(OUTPUT)/$(TARGET).rom -machine msx1 27 | 28 | $(OUTPUT)/%.rel: %.c 29 | $(CC) $(CFLAGS) $(LDFLAGS) -c $< -o $@ 30 | 31 | $(OUTPUT)/%.rel: %.z80 32 | $(AS) -g -o $@ $< 33 | 34 | $(OUTPUT)/$(TARGET).rom: $(OBJS) $(OUTPUT)/crt0.rel $(UBOX_LIBS) 35 | $(CC) $(CFLAGS) $(LDFLAGS) $(LIBS) --code-loc $(CODE) --data-loc $(DATA) $(OUTPUT)/crt0.rel $(OBJS) -o $(OUTPUT)/$(TARGET).ihx 36 | hex2bin -e bin -p 00 -l $(ROM_MAX) $(OUTPUT)/$(TARGET).ihx 37 | @cp $(OUTPUT)/$(TARGET).bin ../bin/$(TARGET).rom 38 | 39 | clean: 40 | rm -f $(OUTPUT)/* 41 | rm -f ../bin/$(TARGET).rom ../../bin/$(TARGET).rom 42 | 43 | .PHONY: all clean 44 | -------------------------------------------------------------------------------- /examples/01_hello/src/crt0.z80: -------------------------------------------------------------------------------- 1 | .module crt0 2 | .globl _main 3 | 4 | .area _HOME 5 | .area _CODE 6 | .area _INITIALIZER 7 | .area _GSINIT 8 | .area _GSFINAL 9 | 10 | .area _DATA 11 | .area _INITIALIZED 12 | .area _BSEG 13 | .area _BSS 14 | .area _HEAP 15 | 16 | .area _CODE 17 | 18 | ENASLT = 0x0024 19 | RSLREG = 0x0138 20 | CLIKSW = 0xf3db 21 | 22 | ; ROM header 23 | .str "AB" 24 | .dw _main_init 25 | .db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 26 | 27 | _main_init:: 28 | 29 | ; init the stack 30 | di 31 | ld sp, #0xf380 32 | ei 33 | 34 | ; setup memory 35 | ; ref: https://www.msx.org/forum/msx-talk/development/memory-pages-again 36 | 37 | call RSLREG 38 | rrca 39 | rrca 40 | and #3 41 | ld c, a 42 | add a, #0xc1 43 | ld l, a 44 | ld h, #0xfc 45 | ld a, (hl) 46 | and #0x80 47 | or c 48 | ld c, a 49 | inc l 50 | inc l 51 | inc l 52 | inc l 53 | ld a, (hl) 54 | and #0x0c 55 | or c 56 | ld h, #0x80 57 | call ENASLT 58 | 59 | ; disable key click sound 60 | xor a 61 | ld (CLIKSW), a 62 | 63 | call gsinit 64 | call _main 65 | 66 | halt0: 67 | halt 68 | jr halt0 69 | 70 | .area _GSINIT 71 | gsinit:: 72 | ld bc, #l__INITIALIZER 73 | ld a, b 74 | or a, c 75 | jr Z, gsinit_next 76 | ld de, #s__INITIALIZED 77 | ld hl, #s__INITIALIZER 78 | ldir 79 | gsinit_next: 80 | 81 | .area _GSFINAL 82 | ret 83 | -------------------------------------------------------------------------------- /examples/01_hello/src/main.c: -------------------------------------------------------------------------------- 1 | #include "ubox.h" 2 | 3 | #define LOCAL 4 | #include "tiles.h" 5 | 6 | #define WHITESPACE_TILE 129 7 | 8 | void put_text(uint8_t x, uint8_t y, const uint8_t *text) 9 | { 10 | while (*text) 11 | ubox_put_tile(x++, y, *text++ + 128 - 31); 12 | } 13 | 14 | void main() 15 | { 16 | 17 | ubox_init_isr(2); 18 | 19 | ubox_set_mode(2); 20 | 21 | ubox_set_colors(1, 1, 1); 22 | 23 | ubox_disable_screen(); 24 | 25 | ubox_set_tiles(tiles); 26 | ubox_set_tiles_colors(tiles_colors); 27 | 28 | ubox_fill_screen(WHITESPACE_TILE); 29 | put_text(11, 11, "HELLO WORLD!!"); 30 | 31 | ubox_enable_screen(); 32 | 33 | 34 | while (1) 35 | { 36 | ubox_wait(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /examples/02_consolehello/Makefile: -------------------------------------------------------------------------------- 1 | export PATH := $(PWD)/../../bin:$(PATH) 2 | 3 | all: bin build 4 | make -C src 5 | 6 | bin: 7 | mkdir -p ./bin 8 | 9 | build: 10 | mkdir -p ./build 11 | 12 | .PHONY: all clean 13 | clean: 14 | rm -rf ./bin ./build 15 | make -C src clean 16 | 17 | 18 | -------------------------------------------------------------------------------- /examples/02_consolehello/src/Makefile: -------------------------------------------------------------------------------- 1 | TARGET := 02_consolehello 2 | 3 | CODE := 0x4000 4 | # leaves 222 bytes for AKM player buffer 5 | DATA := 0xc0de 6 | 7 | # HEX, will fill with 0 8 | ROM_MAX := 8000 9 | 10 | OUTPUT := ../build 11 | OBJS := $(patsubst %.c,$(OUTPUT)/%.rel,$(wildcard *.c)) 12 | UBOX_LIBS := $(wildcard ../../../lib/*.lib) 13 | LIBS := -lubox -lspman -lmplayer -lap 14 | 15 | CC := sdcc 16 | AS := sdasz80 17 | AR := sdcclib 18 | CFLAGS := --debug -mz80 --Werror -I../../../include -I../generated --fsigned-char --std-sdcc99 --opt-code-speed 19 | LDFLAGS := -L../../../lib -L. --no-std-crt0 --fomit-frame-pointer 20 | 21 | all: $(OUTPUT)/$(TARGET).rom 22 | python ../../../tools/chksize 8000 4000 $(OUTPUT)/$(TARGET).map 23 | @cp ../bin/$(TARGET).rom ../../bin 24 | 25 | openmsx: all 26 | openmsx -carta $(OUTPUT)/$(TARGET).rom -machine msx1 27 | 28 | $(OUTPUT)/%.rel: %.c 29 | $(CC) $(CFLAGS) $(LDFLAGS) -c $< -o $@ 30 | 31 | $(OUTPUT)/%.rel: %.z80 32 | $(AS) -g -o $@ $< 33 | 34 | $(OUTPUT)/$(TARGET).rom: $(OBJS) $(OUTPUT)/crt0.rel $(OUTPUT)/printf.rel $(UBOX_LIBS) 35 | $(CC) $(CFLAGS) $(LDFLAGS) $(LIBS) --code-loc $(CODE) --data-loc $(DATA) $(OUTPUT)/crt0.rel $(OUTPUT)/printf.rel $(OBJS) -o $(OUTPUT)/$(TARGET).ihx 36 | hex2bin -e bin -p 00 -l $(ROM_MAX) $(OUTPUT)/$(TARGET).ihx 37 | @cp $(OUTPUT)/$(TARGET).bin ../bin/$(TARGET).rom 38 | 39 | clean: 40 | rm -f $(OUTPUT)/* 41 | rm -f ../bin/$(TARGET).rom ../../bin/$(TARGET).rom 42 | 43 | .PHONY: all clean 44 | -------------------------------------------------------------------------------- /examples/02_consolehello/src/crt0.z80: -------------------------------------------------------------------------------- 1 | .module crt0 2 | .globl _main 3 | 4 | .area _HOME 5 | .area _CODE 6 | .area _INITIALIZER 7 | .area _GSINIT 8 | .area _GSFINAL 9 | 10 | .area _DATA 11 | .area _INITIALIZED 12 | .area _BSEG 13 | .area _BSS 14 | .area _HEAP 15 | 16 | .area _CODE 17 | 18 | ENASLT = 0x0024 19 | RSLREG = 0x0138 20 | CLIKSW = 0xf3db 21 | 22 | ; ROM header 23 | .str "AB" 24 | .dw _main_init 25 | .db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 26 | 27 | _main_init:: 28 | 29 | ; init the stack 30 | di 31 | ld sp, #0xf380 32 | ei 33 | 34 | ; setup memory 35 | ; ref: https://www.msx.org/forum/msx-talk/development/memory-pages-again 36 | 37 | call RSLREG 38 | rrca 39 | rrca 40 | and #3 41 | ld c, a 42 | add a, #0xc1 43 | ld l, a 44 | ld h, #0xfc 45 | ld a, (hl) 46 | and #0x80 47 | or c 48 | ld c, a 49 | inc l 50 | inc l 51 | inc l 52 | inc l 53 | ld a, (hl) 54 | and #0x0c 55 | or c 56 | ld h, #0x80 57 | call ENASLT 58 | 59 | ; disable key click sound 60 | xor a 61 | ld (CLIKSW), a 62 | 63 | call gsinit 64 | call _main 65 | 66 | halt0: 67 | halt 68 | jr halt0 69 | 70 | .area _GSINIT 71 | gsinit:: 72 | ld bc, #l__INITIALIZER 73 | ld a, b 74 | or a, c 75 | jr Z, gsinit_next 76 | ld de, #s__INITIALIZED 77 | ld hl, #s__INITIALIZER 78 | ldir 79 | gsinit_next: 80 | 81 | .area _GSFINAL 82 | ret 83 | -------------------------------------------------------------------------------- /examples/02_consolehello/src/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern void printf(char* message); 4 | 5 | void main() 6 | { 7 | printf("HELLO WORLD!!"); 8 | } 9 | -------------------------------------------------------------------------------- /examples/02_consolehello/src/printf.z80: -------------------------------------------------------------------------------- 1 | .globl _printf 2 | 3 | CHPUT = 0x00a2 4 | 5 | _printf:: 6 | di 7 | Loop: 8 | ld a,(hl) 9 | and a 10 | jr z,Done 11 | call CHPUT 12 | inc hl 13 | jr Loop 14 | Done: 15 | ei 16 | ret 17 | 18 | 19 | -------------------------------------------------------------------------------- /examples/03_timer/Makefile: -------------------------------------------------------------------------------- 1 | all: bin build 2 | make -C src 3 | 4 | export PATH := $(PWD)/../../bin:$(PATH) 5 | 6 | bin: 7 | mkdir -p ./bin 8 | 9 | build: 10 | mkdir -p ./build 11 | 12 | .PHONY: all clean 13 | clean: 14 | rm -rf ./bin ./build 15 | make -C src clean 16 | 17 | 18 | -------------------------------------------------------------------------------- /examples/03_timer/src/Makefile: -------------------------------------------------------------------------------- 1 | TARGET := 03_timer 2 | 3 | CODE := 0x4000 4 | # leaves 222 bytes for AKM player buffer 5 | DATA := 0xc0de 6 | 7 | # HEX, will fill with 0 8 | ROM_MAX := 8000 9 | 10 | OUTPUT := ../build 11 | OBJS := $(patsubst %.c,$(OUTPUT)/%.rel,$(wildcard *.c)) 12 | UBOX_LIBS := $(wildcard ../../../lib/*.lib) 13 | LIBS := -lubox -lspman -lmplayer -lap 14 | 15 | CC := sdcc 16 | AS := sdasz80 17 | AR := sdcclib 18 | CFLAGS := --debug -mz80 --Werror -I../../../include -I../generated --fsigned-char --std-sdcc99 --opt-code-speed 19 | LDFLAGS := -L../../../lib -L. --no-std-crt0 --fomit-frame-pointer 20 | 21 | all: $(OUTPUT)/$(TARGET).rom 22 | python ../../../tools/chksize 8000 4000 $(OUTPUT)/$(TARGET).map 23 | @cp ../bin/$(TARGET).rom ../../bin 24 | 25 | openmsx: all 26 | openmsx -carta $(OUTPUT)/$(TARGET).rom -machine msx1 27 | 28 | $(OUTPUT)/%.rel: %.c 29 | $(CC) $(CFLAGS) $(LDFLAGS) -c $< -o $@ 30 | 31 | $(OUTPUT)/%.rel: %.z80 32 | $(AS) -g -o $@ $< 33 | 34 | $(OUTPUT)/$(TARGET).rom: $(OBJS) $(OUTPUT)/crt0.rel $(UBOX_LIBS) 35 | $(CC) $(CFLAGS) $(LDFLAGS) $(LIBS) --code-loc $(CODE) --data-loc $(DATA) $(OUTPUT)/crt0.rel $(OBJS) -o $(OUTPUT)/$(TARGET).ihx 36 | hex2bin -e bin -p 00 -l $(ROM_MAX) $(OUTPUT)/$(TARGET).ihx 37 | @cp $(OUTPUT)/$(TARGET).bin ../bin/$(TARGET).rom 38 | 39 | clean: 40 | rm -f $(OUTPUT)/* 41 | rm -f ../bin/$(TARGET).rom ../../bin/$(TARGET).rom 42 | 43 | .PHONY: all clean 44 | -------------------------------------------------------------------------------- /examples/03_timer/src/crt0.z80: -------------------------------------------------------------------------------- 1 | .module crt0 2 | .globl _main 3 | 4 | .area _HOME 5 | .area _CODE 6 | .area _INITIALIZER 7 | .area _GSINIT 8 | .area _GSFINAL 9 | 10 | .area _DATA 11 | .area _INITIALIZED 12 | .area _BSEG 13 | .area _BSS 14 | .area _HEAP 15 | 16 | .area _CODE 17 | 18 | ENASLT = 0x0024 19 | RSLREG = 0x0138 20 | CLIKSW = 0xf3db 21 | 22 | ; ROM header 23 | .str "AB" 24 | .dw _main_init 25 | .db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 26 | 27 | _main_init:: 28 | 29 | ; init the stack 30 | di 31 | ld sp, #0xf380 32 | ei 33 | 34 | ; setup memory 35 | ; ref: https://www.msx.org/forum/msx-talk/development/memory-pages-again 36 | 37 | call RSLREG 38 | rrca 39 | rrca 40 | and #3 41 | ld c, a 42 | add a, #0xc1 43 | ld l, a 44 | ld h, #0xfc 45 | ld a, (hl) 46 | and #0x80 47 | or c 48 | ld c, a 49 | inc l 50 | inc l 51 | inc l 52 | inc l 53 | ld a, (hl) 54 | and #0x0c 55 | or c 56 | ld h, #0x80 57 | call ENASLT 58 | 59 | ; disable key click sound 60 | xor a 61 | ld (CLIKSW), a 62 | 63 | call gsinit 64 | call _main 65 | 66 | halt0: 67 | halt 68 | jr halt0 69 | 70 | .area _GSINIT 71 | gsinit:: 72 | ld bc, #l__INITIALIZER 73 | ld a, b 74 | or a, c 75 | jr Z, gsinit_next 76 | ld de, #s__INITIALIZED 77 | ld hl, #s__INITIALIZER 78 | ldir 79 | gsinit_next: 80 | 81 | .area _GSFINAL 82 | ret 83 | -------------------------------------------------------------------------------- /examples/03_timer/src/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "ubox.h" 3 | #include 4 | 5 | #define LOCAL 6 | #include "tiles.h" 7 | 8 | #define WHITESPACE_TILE 129 9 | 10 | void put_text(uint8_t x, uint8_t y, const uint8_t *text) 11 | { 12 | while (*text) 13 | ubox_put_tile(x++, y, *text++ + 128 - 31); 14 | } 15 | 16 | 17 | char buffer[10]; 18 | 19 | int g_count = 0; 20 | int g_counter = 0; 21 | 22 | void my_isr() 23 | { 24 | g_counter++; 25 | } 26 | 27 | void main() 28 | { 29 | uint8_t wait_tick = 2; 30 | ubox_init_isr(wait_tick); 31 | 32 | ubox_set_mode(2); 33 | 34 | ubox_set_colors(1, 1, 1); 35 | 36 | ubox_disable_screen(); 37 | 38 | ubox_set_tiles(tiles); 39 | ubox_set_tiles_colors(tiles_colors); 40 | 41 | ubox_fill_screen(WHITESPACE_TILE); 42 | put_text(11, 11, "COUNT : "); 43 | sprintf(buffer, "%d", g_count); 44 | put_text(11 + 9, 11, buffer); 45 | 46 | ubox_enable_screen(); 47 | ubox_wvdp(1, 0xe2); 48 | 49 | ubox_set_user_isr(my_isr); 50 | 51 | while (1) 52 | { 53 | 54 | if((g_counter / wait_tick) == 50) 55 | { 56 | g_count++; 57 | sprintf(buffer, "%d", g_count); 58 | put_text(11 + 9, 11, buffer); 59 | g_counter = 0; 60 | } 61 | 62 | ubox_wait(); 63 | 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /examples/03_timer/src/main.h: -------------------------------------------------------------------------------- 1 | #ifndef _MAIN_H 2 | #define _MAIN_H 3 | 4 | #include 5 | 6 | #define WHITESPACE_TILE 129 7 | 8 | 9 | #endif // _MAIN_H 10 | -------------------------------------------------------------------------------- /examples/04_clibrary/Makefile: -------------------------------------------------------------------------------- 1 | all: bin build 2 | make -C src 3 | 4 | export PATH := $(PWD)/../../bin:$(PATH) 5 | 6 | bin: 7 | mkdir -p ./bin 8 | 9 | build: 10 | mkdir -p ./build 11 | 12 | .PHONY: all clean 13 | clean: 14 | rm -rf ./bin ./build 15 | make -C src clean 16 | 17 | 18 | -------------------------------------------------------------------------------- /examples/04_clibrary/src/Makefile: -------------------------------------------------------------------------------- 1 | TARGET := 04_clibrary 2 | 3 | CODE := 0x4000 4 | # leaves 222 bytes for AKM player buffer 5 | DATA := 0xc0de 6 | 7 | # HEX, will fill with 0 8 | ROM_MAX := 8000 9 | 10 | OUTPUT := ../build 11 | OBJS := $(patsubst %.c,$(OUTPUT)/%.rel,$(wildcard *.c)) 12 | UBOX_LIBS := $(wildcard ../../../lib/*.lib) 13 | LIBS := -lubox -lspman -lmplayer -lap 14 | 15 | CC := sdcc 16 | AS := sdasz80 17 | AR := sdcclib 18 | CFLAGS := --debug -mz80 --Werror -I../../../include -I../generated --fsigned-char --std-sdcc99 --opt-code-speed 19 | LDFLAGS := -L../../../lib -L. --no-std-crt0 --fomit-frame-pointer 20 | 21 | all: $(OUTPUT)/$(TARGET).rom 22 | python ../../../tools/chksize 8000 4000 $(OUTPUT)/$(TARGET).map 23 | @cp ../bin/$(TARGET).rom ../../bin 24 | 25 | openmsx: all 26 | openmsx -carta $(OUTPUT)/$(TARGET).rom -machine msx1 27 | 28 | $(OUTPUT)/%.rel: %.c 29 | $(CC) $(CFLAGS) $(LDFLAGS) -c $< -o $@ 30 | 31 | $(OUTPUT)/%.rel: %.z80 32 | $(AS) -g -o $@ $< 33 | 34 | $(OUTPUT)/$(TARGET).rom: $(OBJS) $(OUTPUT)/crt0.rel $(UBOX_LIBS) 35 | $(CC) $(CFLAGS) $(LDFLAGS) $(LIBS) --code-loc $(CODE) --data-loc $(DATA) $(OUTPUT)/crt0.rel $(OBJS) -o $(OUTPUT)/$(TARGET).ihx 36 | hex2bin -e bin -p 00 -l $(ROM_MAX) $(OUTPUT)/$(TARGET).ihx 37 | @cp $(OUTPUT)/$(TARGET).bin ../bin/$(TARGET).rom 38 | 39 | clean: 40 | rm -f $(OUTPUT)/* 41 | rm -f ../bin/$(TARGET).rom ../../bin/$(TARGET).rom 42 | 43 | .PHONY: all clean 44 | -------------------------------------------------------------------------------- /examples/04_clibrary/src/crt0.z80: -------------------------------------------------------------------------------- 1 | .module crt0 2 | .globl _main 3 | 4 | .area _HOME 5 | .area _CODE 6 | .area _INITIALIZER 7 | .area _GSINIT 8 | .area _GSFINAL 9 | 10 | .area _DATA 11 | .area _INITIALIZED 12 | .area _BSEG 13 | .area _BSS 14 | .area _HEAP 15 | 16 | .area _CODE 17 | 18 | ENASLT = 0x0024 19 | RSLREG = 0x0138 20 | CLIKSW = 0xf3db 21 | 22 | ; ROM header 23 | .str "AB" 24 | .dw _main_init 25 | .db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 26 | 27 | _main_init:: 28 | 29 | ; init the stack 30 | di 31 | ld sp, #0xf380 32 | ei 33 | 34 | ; setup memory 35 | ; ref: https://www.msx.org/forum/msx-talk/development/memory-pages-again 36 | 37 | call RSLREG 38 | rrca 39 | rrca 40 | and #3 41 | ld c, a 42 | add a, #0xc1 43 | ld l, a 44 | ld h, #0xfc 45 | ld a, (hl) 46 | and #0x80 47 | or c 48 | ld c, a 49 | inc l 50 | inc l 51 | inc l 52 | inc l 53 | ld a, (hl) 54 | and #0x0c 55 | or c 56 | ld h, #0x80 57 | call ENASLT 58 | 59 | ; disable key click sound 60 | xor a 61 | ld (CLIKSW), a 62 | 63 | call gsinit 64 | call _main 65 | 66 | halt0: 67 | halt 68 | jr halt0 69 | 70 | .area _GSINIT 71 | gsinit:: 72 | ld bc, #l__INITIALIZER 73 | ld a, b 74 | or a, c 75 | jr Z, gsinit_next 76 | ld de, #s__INITIALIZED 77 | ld hl, #s__INITIALIZER 78 | ldir 79 | gsinit_next: 80 | 81 | .area _GSFINAL 82 | ret 83 | -------------------------------------------------------------------------------- /examples/04_clibrary/src/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "ubox.h" 3 | #include "printf.h" 4 | 5 | #define LOCAL 6 | #include "tiles.h" 7 | 8 | #define WHITESPACE_TILE 129 9 | 10 | void put_text(uint8_t x, uint8_t y, const uint8_t *text) 11 | { 12 | while (*text) 13 | ubox_put_tile(x++, y, *text++ + 128 - 31); 14 | } 15 | 16 | uint8_t g_x = 0; 17 | void _putchar(char character) 18 | { 19 | ubox_put_tile(g_x++, 0, character + 128 - 31); 20 | } 21 | 22 | char buffer[10]; 23 | 24 | int counter = 0; 25 | 26 | int g_count = 0; 27 | 28 | 29 | void my_isr() 30 | { 31 | 32 | ++counter; 33 | 34 | if(counter >= 30) 35 | { 36 | g_count++; 37 | counter = 0; 38 | } 39 | } 40 | 41 | void main() 42 | { 43 | 44 | ubox_init_isr(2); 45 | 46 | ubox_set_mode(2); 47 | 48 | ubox_set_colors(1, 1, 1); 49 | 50 | ubox_disable_screen(); 51 | 52 | ubox_set_tiles(tiles); 53 | ubox_set_tiles_colors(tiles_colors); 54 | 55 | ubox_fill_screen(WHITESPACE_TILE); 56 | put_text(11, 11, "COUNT : "); 57 | sprintf(buffer, "%d", g_count); 58 | put_text(11 + 9, 11, buffer); 59 | 60 | ubox_enable_screen(); 61 | 62 | ubox_set_user_isr(my_isr); 63 | 64 | int temp_counter = 0; 65 | 66 | printf("04 CLIBRARY\n"); 67 | 68 | while (1) 69 | { 70 | if(temp_counter != g_count) 71 | { 72 | sprintf(buffer, "%d", g_count); 73 | put_text(11 + 9, 11, buffer); 74 | temp_counter = g_count; 75 | } 76 | 77 | ubox_wait(); 78 | 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /examples/04_clibrary/src/main.h: -------------------------------------------------------------------------------- 1 | #ifndef _MAIN_H 2 | #define _MAIN_H 3 | 4 | #include 5 | 6 | #define WHITESPACE_TILE 129 7 | 8 | 9 | #endif // _MAIN_H 10 | -------------------------------------------------------------------------------- /examples/05_music/Makefile: -------------------------------------------------------------------------------- 1 | all: bin build 2 | make -C src 3 | 4 | export PATH := $(PWD)/../../bin:$(PATH) 5 | 6 | bin: 7 | mkdir -p ./bin 8 | 9 | build: 10 | mkdir -p ./build 11 | 12 | .PHONY: all clean 13 | clean: 14 | rm -rf ./bin ./build 15 | make -C src clean 16 | 17 | 18 | -------------------------------------------------------------------------------- /examples/05_music/src/Makefile: -------------------------------------------------------------------------------- 1 | TARGET := 05_music 2 | 3 | CODE := 0x4000 4 | # leaves 222 bytes for AKM player buffer 5 | DATA := 0xc0de 6 | 7 | # HEX, will fill with 0 8 | ROM_MAX := 8000 9 | 10 | OUTPUT := ../build 11 | OBJS := $(patsubst %.c,$(OUTPUT)/%.rel,$(wildcard *.c)) $(OUTPUT)/akm.rel 12 | UBOX_LIBS := $(wildcard ../../../lib/*.lib) 13 | LIBS := -lubox -lspman -lmplayer -lap 14 | 15 | CC := sdcc 16 | AS := sdasz80 17 | AR := sdcclib 18 | CFLAGS := --debug -mz80 --Werror -I../../../include -I../generated --fsigned-char --std-sdcc99 --opt-code-speed 19 | LDFLAGS := -L../../../lib -L. --no-std-crt0 --fomit-frame-pointer 20 | 21 | all: $(OUTPUT)/$(TARGET).rom 22 | python ../../../tools/chksize 8000 4000 $(OUTPUT)/$(TARGET).map 23 | @cp ../bin/$(TARGET).rom ../../bin 24 | 25 | openmsx: all 26 | openmsx -carta $(OUTPUT)/$(TARGET).rom -machine msx1 27 | 28 | $(OUTPUT)/%.rel: %.c 29 | $(CC) $(CFLAGS) $(LDFLAGS) -c $< -o $@ 30 | 31 | $(OUTPUT)/%.rel: %.z80 32 | $(AS) -g -o $@ $< 33 | 34 | $(OUTPUT)/akm.rel: akm.z80 alienall.asm 35 | rasm akm.z80 -o $(OUTPUT)/akm -s -sl -sq 36 | Disark --sourceProfile sdcc --symbolFile $(OUTPUT)/akm.sym --src16bitsValuesInHex --src8bitsValuesInHex --undocumentedOpcodesToBytes $(OUTPUT)/akm.bin $(OUTPUT)/akm_sdcc.asm 37 | $(AS) -g -o $@ $(OUTPUT)/akm_sdcc.asm 38 | 39 | $(OUTPUT)/$(TARGET).rom: $(OBJS) $(OUTPUT)/crt0.rel $(UBOX_LIBS) 40 | $(CC) $(CFLAGS) $(LDFLAGS) $(LIBS) --code-loc $(CODE) --data-loc $(DATA) $(OUTPUT)/crt0.rel $(OBJS) -o $(OUTPUT)/$(TARGET).ihx 41 | hex2bin -e bin -p 00 -l $(ROM_MAX) $(OUTPUT)/$(TARGET).ihx 42 | @cp $(OUTPUT)/$(TARGET).bin ../bin/$(TARGET).rom 43 | 44 | clean: 45 | rm -f $(OUTPUT)/* 46 | rm -f ../bin/$(TARGET).rom ../../bin/$(TARGET).rom 47 | 48 | .PHONY: all clean 49 | -------------------------------------------------------------------------------- /examples/05_music/src/akm.z80: -------------------------------------------------------------------------------- 1 | include "alienall_playerconfig.asm" 2 | 3 | include "../../../src/mplayer/akm/akm_ubox.asm" 4 | 5 | songDisarkGenerateExternalLabel: 6 | include "alienall.asm" 7 | 8 | -------------------------------------------------------------------------------- /examples/05_music/src/alienall_playerconfig.asm: -------------------------------------------------------------------------------- 1 | ; Configuration that can be included to Arkos Tracker 2 players. 2 | ; It indicates what parts of code are useful to the song/sound effects, to save both memory and CPU. 3 | ; The players may or may not take advantage of these flags, it is up to them. 4 | 5 | ; You can either: 6 | ; - Include this to the source that also includes the player (BEFORE the player is included) (recommended solution). 7 | ; - Include this at the beginning of the player code. 8 | ; - Copy/paste this directly in the player. 9 | ; If you use one player but several songs, don't worry, these declarations will stack up. 10 | ; If no configuration is used, the player will use default values (full code used). 11 | 12 | PLY_CFG_ConfigurationIsPresent = 1 13 | PLY_CFG_UseHardwareSounds = 1 14 | PLY_CFG_UseEffects = 1 15 | PLY_CFG_UseInstrumentLoopTo = 1 16 | PLY_CFG_NoSoftNoHard = 1 17 | PLY_CFG_SoftOnly = 1 18 | PLY_CFG_SoftOnly_Noise = 1 19 | PLY_CFG_SoftOnly_SoftwarePitch = 1 20 | PLY_CFG_SoftToHard = 1 21 | PLY_CFG_UseEffect_Reset = 1 22 | PLY_CFG_UseEffect_ArpeggioTable = 1 23 | PLY_CFG_UseEffect_SetVolume = 1 24 | -------------------------------------------------------------------------------- /examples/05_music/src/crt0.z80: -------------------------------------------------------------------------------- 1 | .module crt0 2 | .globl _main 3 | 4 | .area _HOME 5 | .area _CODE 6 | .area _INITIALIZER 7 | .area _GSINIT 8 | .area _GSFINAL 9 | 10 | .area _DATA 11 | .area _INITIALIZED 12 | .area _BSEG 13 | .area _BSS 14 | .area _HEAP 15 | 16 | .area _CODE 17 | 18 | ENASLT = 0x0024 19 | RSLREG = 0x0138 20 | CLIKSW = 0xf3db 21 | 22 | ; ROM header 23 | .str "AB" 24 | .dw _main_init 25 | .db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 26 | 27 | _main_init:: 28 | 29 | ; init the stack 30 | di 31 | ld sp, #0xf380 32 | ei 33 | 34 | ; setup memory 35 | ; ref: https://www.msx.org/forum/msx-talk/development/memory-pages-again 36 | 37 | call RSLREG 38 | rrca 39 | rrca 40 | and #3 41 | ld c, a 42 | add a, #0xc1 43 | ld l, a 44 | ld h, #0xfc 45 | ld a, (hl) 46 | and #0x80 47 | or c 48 | ld c, a 49 | inc l 50 | inc l 51 | inc l 52 | inc l 53 | ld a, (hl) 54 | and #0x0c 55 | or c 56 | ld h, #0x80 57 | call ENASLT 58 | 59 | ; disable key click sound 60 | xor a 61 | ld (CLIKSW), a 62 | 63 | call gsinit 64 | call _main 65 | 66 | halt0: 67 | halt 68 | jr halt0 69 | 70 | .area _GSINIT 71 | gsinit:: 72 | ld bc, #l__INITIALIZER 73 | ld a, b 74 | or a, c 75 | jr Z, gsinit_next 76 | ld de, #s__INITIALIZED 77 | ld hl, #s__INITIALIZER 78 | ldir 79 | gsinit_next: 80 | 81 | .area _GSFINAL 82 | ret 83 | -------------------------------------------------------------------------------- /examples/05_music/src/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "ubox.h" 3 | #include "mplayer.h" 4 | 5 | #define LOCAL 6 | #include "tiles.h" 7 | 8 | extern uint8_t SONG[]; 9 | 10 | #define WHITESPACE_TILE 129 11 | 12 | void put_text(uint8_t x, uint8_t y, const uint8_t *text) 13 | { 14 | while (*text) 15 | ubox_put_tile(x++, y, *text++ + 128 - 31); 16 | } 17 | 18 | void main() 19 | { 20 | 21 | ubox_init_isr(2); 22 | 23 | ubox_set_mode(2); 24 | 25 | ubox_set_colors(1, 1, 1); 26 | 27 | ubox_disable_screen(); 28 | 29 | ubox_set_tiles(tiles); 30 | ubox_set_tiles_colors(tiles_colors); 31 | 32 | ubox_fill_screen(WHITESPACE_TILE); 33 | put_text(11, 11, "MUSIC : ALIENALL"); 34 | 35 | ubox_enable_screen(); 36 | 37 | mplayer_init(SONG, 0); 38 | 39 | ubox_set_user_isr(mplayer_play); 40 | 41 | mplayer_play(); 42 | 43 | while (1) 44 | { 45 | ubox_wait(); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /examples/06_sound/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "tiles.h": "c" 4 | } 5 | } -------------------------------------------------------------------------------- /examples/06_sound/Makefile: -------------------------------------------------------------------------------- 1 | all: bin build 2 | make -C src 3 | 4 | export PATH := $(PWD)/../../bin:$(PATH) 5 | 6 | bin: 7 | mkdir -p ./bin 8 | 9 | build: 10 | mkdir -p ./build 11 | 12 | .PHONY: all clean 13 | clean: 14 | rm -rf ./bin ./build 15 | make -C src clean 16 | 17 | 18 | -------------------------------------------------------------------------------- /examples/06_sound/src/Makefile: -------------------------------------------------------------------------------- 1 | TARGET := 06_sound 2 | 3 | CODE := 0x4000 4 | # leaves 222 bytes for AKM player buffer 5 | DATA := 0xc0de 6 | 7 | # HEX, will fill with 0 8 | ROM_MAX := 8000 9 | 10 | OUTPUT := ../build 11 | OBJS := $(patsubst %.c,$(OUTPUT)/%.rel,$(wildcard *.c)) $(OUTPUT)/akm.rel 12 | UBOX_LIBS := $(wildcard ../../../lib/*.lib) 13 | LIBS := -lubox -lspman -lmplayer -lap 14 | 15 | CC := sdcc 16 | AS := sdasz80 17 | AR := sdcclib 18 | CFLAGS := --debug -mz80 --Werror -I../../../include -I../generated --fsigned-char --std-sdcc99 --opt-code-speed 19 | LDFLAGS := -L../../../lib -L. --no-std-crt0 --fomit-frame-pointer 20 | 21 | all: $(OUTPUT)/$(TARGET).rom 22 | python ../../../tools/chksize 8000 4000 $(OUTPUT)/$(TARGET).map 23 | @cp ../bin/$(TARGET).rom ../../bin 24 | 25 | openmsx: all 26 | openmsx -carta $(OUTPUT)/$(TARGET).rom -machine msx1 27 | 28 | $(OUTPUT)/%.rel: %.c 29 | $(CC) $(CFLAGS) $(LDFLAGS) -c $< -o $@ 30 | 31 | $(OUTPUT)/%.rel: %.z80 32 | $(AS) -g -o $@ $< 33 | 34 | $(OUTPUT)/akm.rel: akm.z80 song.asm effects.asm 35 | rasm akm.z80 -o $(OUTPUT)/akm -s -sl -sq 36 | Disark --sourceProfile sdcc --symbolFile $(OUTPUT)/akm.sym --src16bitsValuesInHex --src8bitsValuesInHex --undocumentedOpcodesToBytes $(OUTPUT)/akm.bin $(OUTPUT)/akm_sdcc.asm 37 | $(AS) -g -o $@ $(OUTPUT)/akm_sdcc.asm 38 | 39 | $(OUTPUT)/$(TARGET).rom: $(OBJS) $(OUTPUT)/crt0.rel $(UBOX_LIBS) 40 | $(CC) $(CFLAGS) $(LDFLAGS) $(LIBS) --code-loc $(CODE) --data-loc $(DATA) $(OUTPUT)/crt0.rel $(OBJS) -o $(OUTPUT)/$(TARGET).ihx 41 | hex2bin -e bin -p 00 -l $(ROM_MAX) $(OUTPUT)/$(TARGET).ihx 42 | @cp $(OUTPUT)/$(TARGET).bin ../bin/$(TARGET).rom 43 | 44 | clean: 45 | rm -f $(OUTPUT)/* 46 | rm -f ../bin/$(TARGET).rom ../../bin/$(TARGET).rom 47 | 48 | .PHONY: all clean 49 | -------------------------------------------------------------------------------- /examples/06_sound/src/akm.z80: -------------------------------------------------------------------------------- 1 | ; 2 | ; to build the custom AKM player with song + effects 3 | ; 4 | 5 | include "song_playerconfig.asm" 6 | include "effects_playerconfig.asm" 7 | 8 | include "../../../src/mplayer/akm/akm_ubox.asm" 9 | 10 | songDisarkGenerateExternalLabel: 11 | include "song.asm" 12 | 13 | effectsDisarkGenerateExternalLabel: 14 | include "effects.asm" 15 | 16 | -------------------------------------------------------------------------------- /examples/06_sound/src/crt0.z80: -------------------------------------------------------------------------------- 1 | .module crt0 2 | .globl _main 3 | 4 | .area _HOME 5 | .area _CODE 6 | .area _INITIALIZER 7 | .area _GSINIT 8 | .area _GSFINAL 9 | 10 | .area _DATA 11 | .area _INITIALIZED 12 | .area _BSEG 13 | .area _BSS 14 | .area _HEAP 15 | 16 | .area _CODE 17 | 18 | ENASLT = 0x0024 19 | RSLREG = 0x0138 20 | CLIKSW = 0xf3db 21 | 22 | ; ROM header 23 | .str "AB" 24 | .dw _main_init 25 | .db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 26 | 27 | _main_init:: 28 | 29 | ; init the stack 30 | di 31 | ld sp, #0xf380 32 | ei 33 | 34 | ; setup memory 35 | ; ref: https://www.msx.org/forum/msx-talk/development/memory-pages-again 36 | 37 | call RSLREG 38 | rrca 39 | rrca 40 | and #3 41 | ld c, a 42 | add a, #0xc1 43 | ld l, a 44 | ld h, #0xfc 45 | ld a, (hl) 46 | and #0x80 47 | or c 48 | ld c, a 49 | inc l 50 | inc l 51 | inc l 52 | inc l 53 | ld a, (hl) 54 | and #0x0c 55 | or c 56 | ld h, #0x80 57 | call ENASLT 58 | 59 | ; disable key click sound 60 | xor a 61 | ld (CLIKSW), a 62 | 63 | call gsinit 64 | call _main 65 | 66 | halt0: 67 | halt 68 | jr halt0 69 | 70 | .area _GSINIT 71 | gsinit:: 72 | ld bc, #l__INITIALIZER 73 | ld a, b 74 | or a, c 75 | jr Z, gsinit_next 76 | ld de, #s__INITIALIZED 77 | ld hl, #s__INITIALIZER 78 | ldir 79 | gsinit_next: 80 | 81 | .area _GSFINAL 82 | ret 83 | -------------------------------------------------------------------------------- /examples/06_sound/src/effects_playerconfig.asm: -------------------------------------------------------------------------------- 1 | ; Configuration that can be included to Arkos Tracker 2 players. 2 | ; It indicates what parts of code are useful to the song/sound effects, to save both memory and CPU. 3 | ; The players may or may not take advantage of these flags, it is up to them. 4 | 5 | ; You can either: 6 | ; - Include this to the source that also includes the player (BEFORE the player is included) (recommended solution). 7 | ; - Include this at the beginning of the player code. 8 | ; - Copy/paste this directly in the player. 9 | ; If you use one player but several songs, don't worry, these declarations will stack up. 10 | ; If no configuration is used, the player will use default values (full code used). 11 | 12 | PLY_CFG_SFX_ConfigurationIsPresent = 1 13 | PLY_CFG_SFX_SoftOnly = 1 14 | PLY_CFG_SFX_SoftOnly_Noise = 1 15 | -------------------------------------------------------------------------------- /examples/06_sound/src/song_playerconfig.asm: -------------------------------------------------------------------------------- 1 | ; Configuration that can be included to Arkos Tracker 2 players. 2 | ; It indicates what parts of code are useful to the song/sound effects, to save both memory and CPU. 3 | ; The players may or may not take advantage of these flags, it is up to them. 4 | 5 | ; You can either: 6 | ; - Include this to the source that also includes the player (BEFORE the player is included) (recommended solution). 7 | ; - Include this at the beginning of the player code. 8 | ; - Copy/paste this directly in the player. 9 | ; If you use one player but several songs, don't worry, these declarations will stack up. 10 | ; If no configuration is used, the player will use default values (full code used). 11 | 12 | PLY_CFG_ConfigurationIsPresent = 1 13 | PLY_CFG_NoSoftNoHard = 1 14 | PLY_CFG_SoftOnly = 1 15 | PLY_CFG_SoftOnly_Noise = 1 16 | PLY_CFG_SoftOnly_SoftwareArpeggio = 1 17 | PLY_CFG_SoftOnly_SoftwarePitch = 1 18 | -------------------------------------------------------------------------------- /examples/07_snakebyte/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "util.h": "c" 4 | } 5 | } -------------------------------------------------------------------------------- /examples/07_snakebyte/Makefile: -------------------------------------------------------------------------------- 1 | all: bin build 2 | make -C src 3 | 4 | export PATH := $(PWD)/../../bin:$(PATH) 5 | 6 | bin: 7 | mkdir -p ./bin 8 | 9 | build: 10 | mkdir -p ./build 11 | 12 | .PHONY: all clean 13 | clean: 14 | rm -rf ./bin ./build 15 | make -C src clean 16 | 17 | 18 | -------------------------------------------------------------------------------- /examples/07_snakebyte/src/Makefile: -------------------------------------------------------------------------------- 1 | TARGET := 07_snakebyte 2 | 3 | CODE := 0x4000 4 | # leaves 222 bytes for AKM player buffer 5 | DATA := 0xc0de 6 | 7 | # HEX, will fill with 0 8 | ROM_MAX := 8000 9 | 10 | OUTPUT := ../build 11 | OBJS := $(patsubst %.c,$(OUTPUT)/%.rel,$(wildcard *.c)) #$(OUTPUT)/akm.rel 12 | UBOX_LIBS := $(wildcard ../../../lib/*.lib) 13 | LIBS := -lubox -lspman -lmplayer -lap 14 | 15 | CC := sdcc 16 | AS := sdasz80 17 | AR := sdcclib 18 | CFLAGS := --debug -mz80 -I../../../include -I../generated --fsigned-char --std-sdcc99 --opt-code-speed 19 | LDFLAGS := -L../../../lib -L. --no-std-crt0 --fomit-frame-pointer 20 | 21 | all: $(OUTPUT)/$(TARGET).rom 22 | python ../../../tools/chksize 8000 4000 $(OUTPUT)/$(TARGET).map 23 | @cp ../bin/$(TARGET).rom ../../bin 24 | 25 | openmsx: all 26 | openmsx -carta $(OUTPUT)/$(TARGET).rom -machine msx1 27 | 28 | $(OUTPUT)/%.rel: %.c 29 | $(CC) $(CFLAGS) $(LDFLAGS) -c $< -o $@ 30 | 31 | $(OUTPUT)/%.rel: %.z80 32 | $(AS) -g -o $@ $< 33 | 34 | #$(OUTPUT)/akm.rel: akm.z80 song.asm effects.asm 35 | # rasm akm.z80 -o $(OUTPUT)/akm -s -sl -sq 36 | # Disark --sourceProfile sdcc --symbolFile $(OUTPUT)/akm.sym --src16bitsValuesInHex --src8bitsValuesInHex --undocumentedOpcodesToBytes $(OUTPUT)/akm.bin $(OUTPUT)/akm_sdcc.asm 37 | # $(AS) -g -o $@ $(OUTPUT)/akm_sdcc.asm 38 | 39 | $(OUTPUT)/$(TARGET).rom: $(OBJS) $(OUTPUT)/crt0.rel $(UBOX_LIBS) 40 | $(CC) $(CFLAGS) $(LDFLAGS) $(LIBS) --code-loc $(CODE) --data-loc $(DATA) $(OUTPUT)/crt0.rel $(OBJS) -o $(OUTPUT)/$(TARGET).ihx 41 | hex2bin -e bin -p 00 -l $(ROM_MAX) $(OUTPUT)/$(TARGET).ihx 42 | @cp $(OUTPUT)/$(TARGET).bin ../bin/$(TARGET).rom 43 | 44 | clean: 45 | rm -f $(OUTPUT)/* 46 | rm -f ../bin/$(TARGET).rom ../../bin/$(TARGET).rom 47 | 48 | .PHONY: all clean 49 | -------------------------------------------------------------------------------- /examples/07_snakebyte/src/crt0.z80: -------------------------------------------------------------------------------- 1 | .module crt0 2 | .globl _main 3 | 4 | .area _HOME 5 | .area _CODE 6 | .area _INITIALIZER 7 | .area _GSINIT 8 | .area _GSFINAL 9 | 10 | .area _DATA 11 | .area _INITIALIZED 12 | .area _BSEG 13 | .area _BSS 14 | .area _HEAP 15 | 16 | .area _CODE 17 | 18 | ENASLT = 0x0024 19 | RSLREG = 0x0138 20 | CLIKSW = 0xf3db 21 | 22 | ; ROM header 23 | .str "AB" 24 | .dw _main_init 25 | .db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 26 | 27 | _main_init:: 28 | 29 | ; init the stack 30 | di 31 | ld sp, #0xf380 32 | ei 33 | 34 | ; setup memory 35 | ; ref: https://www.msx.org/forum/msx-talk/development/memory-pages-again 36 | 37 | call RSLREG 38 | rrca 39 | rrca 40 | and #3 41 | ld c, a 42 | add a, #0xc1 43 | ld l, a 44 | ld h, #0xfc 45 | ld a, (hl) 46 | and #0x80 47 | or c 48 | ld c, a 49 | inc l 50 | inc l 51 | inc l 52 | inc l 53 | ld a, (hl) 54 | and #0x0c 55 | or c 56 | ld h, #0x80 57 | call ENASLT 58 | 59 | ; disable key click sound 60 | xor a 61 | ld (CLIKSW), a 62 | 63 | call gsinit 64 | call _main 65 | 66 | halt0: 67 | halt 68 | jr halt0 69 | 70 | .area _GSINIT 71 | gsinit:: 72 | ld bc, #l__INITIALIZER 73 | ld a, b 74 | or a, c 75 | jr Z, gsinit_next 76 | ld de, #s__INITIALIZED 77 | ld hl, #s__INITIALIZER 78 | ldir 79 | gsinit_next: 80 | 81 | .area _GSFINAL 82 | ret 83 | -------------------------------------------------------------------------------- /examples/07_snakebyte/src/game.h: -------------------------------------------------------------------------------- 1 | #ifndef _GAME_H 2 | #define _GAME_H 3 | 4 | #define WHITESPACE_TILE 129 5 | #define BLACK_TILE 85 6 | #define GREEN_TILE 74 7 | #define YELLOW_TILE 77 8 | #define WHITE_TILE 81 9 | 10 | enum GAME_STATE 11 | { 12 | STATE_TITLE = 0, 13 | STATE_IN_GAME, 14 | STATE_GAME_OVER, 15 | }; 16 | 17 | void run_game(); 18 | 19 | #endif -------------------------------------------------------------------------------- /examples/07_snakebyte/src/util.c: -------------------------------------------------------------------------------- 1 | #include "util.h" 2 | #include 3 | 4 | volatile long g_tick_count = 0; //틱 카운트 5 | 6 | void put_text(uint8_t x, uint8_t y, const uint8_t *text) 7 | { 8 | while (*text) 9 | ubox_put_tile(x++, y, *text++ + 128 - 31); 10 | } 11 | 12 | void RenderTile(int x, int y, int tileNum) 13 | { 14 | ubox_put_tile(x, y, tileNum); 15 | } 16 | 17 | 18 | int now() 19 | { 20 | return g_tick_count; 21 | } 22 | 23 | void my_isr() 24 | { 25 | g_tick_count++; 26 | } 27 | 28 | -------------------------------------------------------------------------------- /examples/07_snakebyte/src/util.h: -------------------------------------------------------------------------------- 1 | #ifndef _UTIL_H 2 | #define _UTIL_H 3 | #include 4 | #include 5 | #include 6 | 7 | void put_text(uint8_t x, uint8_t y, const uint8_t *text); 8 | void RenderTile(int x, int y, int tileNum); 9 | int now(); 10 | void my_isr(); 11 | 12 | #endif -------------------------------------------------------------------------------- /examples/08_socoban/Makefile: -------------------------------------------------------------------------------- 1 | all: bin build 2 | make -C src 3 | 4 | export PATH := $(PWD)/../../bin:$(PATH) 5 | 6 | bin: 7 | mkdir -p ./bin 8 | 9 | build: 10 | mkdir -p ./build 11 | 12 | .PHONY: all clean 13 | clean: 14 | rm -rf ./bin ./build 15 | make -C src clean 16 | 17 | 18 | -------------------------------------------------------------------------------- /examples/08_socoban/src/crt0.z80: -------------------------------------------------------------------------------- 1 | .module crt0 2 | .globl _main 3 | 4 | .area _HOME 5 | .area _CODE 6 | .area _INITIALIZER 7 | .area _GSINIT 8 | .area _GSFINAL 9 | 10 | .area _DATA 11 | .area _INITIALIZED 12 | .area _BSEG 13 | .area _BSS 14 | .area _HEAP 15 | 16 | .area _CODE 17 | 18 | ENASLT = 0x0024 19 | RSLREG = 0x0138 20 | CLIKSW = 0xf3db 21 | 22 | ; ROM header 23 | .str "AB" 24 | .dw _main_init 25 | .db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 26 | 27 | _main_init:: 28 | 29 | ; init the stack 30 | di 31 | ld sp, #0xf380 32 | ei 33 | 34 | ; setup memory 35 | ; ref: https://www.msx.org/forum/msx-talk/development/memory-pages-again 36 | 37 | call RSLREG 38 | rrca 39 | rrca 40 | and #3 41 | ld c, a 42 | add a, #0xc1 43 | ld l, a 44 | ld h, #0xfc 45 | ld a, (hl) 46 | and #0x80 47 | or c 48 | ld c, a 49 | inc l 50 | inc l 51 | inc l 52 | inc l 53 | ld a, (hl) 54 | and #0x0c 55 | or c 56 | ld h, #0x80 57 | call ENASLT 58 | 59 | ; disable key click sound 60 | xor a 61 | ld (CLIKSW), a 62 | 63 | call gsinit 64 | call _main 65 | 66 | halt0: 67 | halt 68 | jr halt0 69 | 70 | .area _GSINIT 71 | gsinit:: 72 | ld bc, #l__INITIALIZER 73 | ld a, b 74 | or a, c 75 | jr Z, gsinit_next 76 | ld de, #s__INITIALIZED 77 | ld hl, #s__INITIALIZER 78 | ldir 79 | gsinit_next: 80 | 81 | .area _GSFINAL 82 | ret 83 | -------------------------------------------------------------------------------- /examples/08_socoban/src/game.h: -------------------------------------------------------------------------------- 1 | #ifndef _GAME_H 2 | #define _GAME_H 3 | 4 | #define WHITESPACE_TILE 129 5 | #define BLACK_TILE 85 6 | #define GREEN_TILE 74 7 | #define YELLOW_TILE 77 8 | #define WHITE_TILE 81 9 | #define RED_TILE 80 10 | 11 | #define MAX_STAGE_NUM 5 12 | 13 | enum GAME_STATE 14 | { 15 | STATE_TITLE = 0, 16 | STATE_IN_GAME, 17 | STATE_GAME_RESET, 18 | STATE_NO_MAP, 19 | STATE_GAME_CLEAR, 20 | }; 21 | 22 | void run_game(); 23 | 24 | #endif -------------------------------------------------------------------------------- /examples/08_socoban/src/util.c: -------------------------------------------------------------------------------- 1 | #include "util.h" 2 | #include "ubox.h" 3 | 4 | void put_text(uint8_t x, uint8_t y, const uint8_t *text) 5 | { 6 | while (*text) 7 | ubox_put_tile(x++, y, *text++ + 128 - 31); 8 | } 9 | 10 | void RenderTile(int x, int y, int tileNum) 11 | { 12 | 13 | ubox_put_tile(x, y, tileNum); 14 | } 15 | 16 | -------------------------------------------------------------------------------- /examples/08_socoban/src/util.h: -------------------------------------------------------------------------------- 1 | #ifndef _UTIL_H 2 | #define _UTIL_H 3 | #include 4 | 5 | void RenderTile(int x, int y, int tileNum); 6 | void put_text(uint8_t x, uint8_t y, const uint8_t *text); 7 | 8 | #endif -------------------------------------------------------------------------------- /examples/09_tetris/.vscode/c_cpp_properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "Win32", 5 | "includePath": [ 6 | "${workspaceFolder}/**" 7 | ], 8 | "defines": [ 9 | "_DEBUG", 10 | "UNICODE", 11 | "_UNICODE" 12 | ], 13 | "windowsSdkVersion": "10.0.19041.0", 14 | "compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.27.29110/bin/Hostx64/x64/cl.exe", 15 | "cStandard": "c17", 16 | "cppStandard": "c++17", 17 | "intelliSenseMode": "windows-msvc-x64" 18 | } 19 | ], 20 | "version": 4 21 | } -------------------------------------------------------------------------------- /examples/09_tetris/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "ubox.h": "c", 4 | "string.h": "c" 5 | } 6 | } -------------------------------------------------------------------------------- /examples/09_tetris/Makefile: -------------------------------------------------------------------------------- 1 | all: bin build 2 | make -C src 3 | 4 | export PATH := $(PWD)/../../bin:$(PATH) 5 | 6 | bin: 7 | mkdir -p ./bin 8 | 9 | build: 10 | mkdir -p ./build 11 | 12 | .PHONY: all clean 13 | clean: 14 | rm -rf ./bin ./build 15 | make -C src clean 16 | 17 | 18 | -------------------------------------------------------------------------------- /examples/09_tetris/src/Makefile: -------------------------------------------------------------------------------- 1 | TARGET := 09_tetris 2 | 3 | CODE := 0x4000 4 | # leaves 222 bytes for AKM player buffer 5 | DATA := 0xc0de 6 | 7 | # HEX, will fill with 0 8 | ROM_MAX := 8000 9 | 10 | OUTPUT := ../build 11 | OBJS := $(patsubst %.c,$(OUTPUT)/%.rel,$(wildcard *.c)) #$(OUTPUT)/akm.rel 12 | UBOX_LIBS := $(wildcard ../../../lib/*.lib) 13 | LIBS := -lubox -lspman -lmplayer -lap 14 | 15 | CC := sdcc 16 | AS := sdasz80 17 | AR := sdcclib 18 | CFLAGS := --debug -mz80 -I../../../include -I../generated --fsigned-char --std-sdcc99 --opt-code-speed 19 | LDFLAGS := -L../../../lib -L. --no-std-crt0 --fomit-frame-pointer 20 | 21 | all: $(OUTPUT)/$(TARGET).rom 22 | python ../../../tools/chksize 8000 4000 $(OUTPUT)/$(TARGET).map 23 | @cp ../bin/$(TARGET).rom ../../bin 24 | 25 | openmsx: all 26 | openmsx -carta $(OUTPUT)/$(TARGET).rom -machine msx1 27 | 28 | $(OUTPUT)/%.rel: %.c 29 | $(CC) $(CFLAGS) $(LDFLAGS) -c $< -o $@ 30 | 31 | $(OUTPUT)/%.rel: %.z80 32 | $(AS) -g -o $@ $< 33 | 34 | #$(OUTPUT)/akm.rel: akm.z80 song.asm effects.asm 35 | # rasm akm.z80 -o $(OUTPUT)/akm -s -sl -sq 36 | # Disark --sourceProfile sdcc --symbolFile $(OUTPUT)/akm.sym --src16bitsValuesInHex --src8bitsValuesInHex --undocumentedOpcodesToBytes $(OUTPUT)/akm.bin $(OUTPUT)/akm_sdcc.asm 37 | # $(AS) -g -o $@ $(OUTPUT)/akm_sdcc.asm 38 | 39 | $(OUTPUT)/$(TARGET).rom: $(OBJS) $(OUTPUT)/crt0.rel $(UBOX_LIBS) 40 | $(CC) $(CFLAGS) $(LDFLAGS) $(LIBS) --code-loc $(CODE) --data-loc $(DATA) $(OUTPUT)/crt0.rel $(OBJS) -o $(OUTPUT)/$(TARGET).ihx 41 | hex2bin -e bin -p 00 -l $(ROM_MAX) $(OUTPUT)/$(TARGET).ihx 42 | @cp $(OUTPUT)/$(TARGET).bin ../bin/$(TARGET).rom 43 | 44 | clean: 45 | rm -f $(OUTPUT)/* 46 | rm -f ../bin/$(TARGET).rom ../../bin/$(TARGET).rom 47 | 48 | .PHONY: all clean 49 | -------------------------------------------------------------------------------- /examples/09_tetris/src/crt0.z80: -------------------------------------------------------------------------------- 1 | .module crt0 2 | .globl _main 3 | 4 | .area _HOME 5 | .area _CODE 6 | .area _INITIALIZER 7 | .area _GSINIT 8 | .area _GSFINAL 9 | 10 | .area _DATA 11 | .area _INITIALIZED 12 | .area _BSEG 13 | .area _BSS 14 | .area _HEAP 15 | 16 | .area _CODE 17 | 18 | ENASLT = 0x0024 19 | RSLREG = 0x0138 20 | CLIKSW = 0xf3db 21 | 22 | ; ROM header 23 | .str "AB" 24 | .dw _main_init 25 | .db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 26 | 27 | _main_init:: 28 | 29 | ; init the stack 30 | di 31 | ld sp, #0xf380 32 | ei 33 | 34 | ; setup memory 35 | ; ref: https://www.msx.org/forum/msx-talk/development/memory-pages-again 36 | 37 | call RSLREG 38 | rrca 39 | rrca 40 | and #3 41 | ld c, a 42 | add a, #0xc1 43 | ld l, a 44 | ld h, #0xfc 45 | ld a, (hl) 46 | and #0x80 47 | or c 48 | ld c, a 49 | inc l 50 | inc l 51 | inc l 52 | inc l 53 | ld a, (hl) 54 | and #0x0c 55 | or c 56 | ld h, #0x80 57 | call ENASLT 58 | 59 | ; disable key click sound 60 | xor a 61 | ld (CLIKSW), a 62 | 63 | call gsinit 64 | call _main 65 | 66 | halt0: 67 | halt 68 | jr halt0 69 | 70 | .area _GSINIT 71 | gsinit:: 72 | ld bc, #l__INITIALIZER 73 | ld a, b 74 | or a, c 75 | jr Z, gsinit_next 76 | ld de, #s__INITIALIZED 77 | ld hl, #s__INITIALIZER 78 | ldir 79 | gsinit_next: 80 | 81 | .area _GSFINAL 82 | ret 83 | -------------------------------------------------------------------------------- /examples/09_tetris/src/game.h: -------------------------------------------------------------------------------- 1 | #ifndef _GAME_H 2 | #define _GAME_H 3 | 4 | enum GAME_STATE 5 | { 6 | STATE_TITLE = 0, 7 | STATE_IN_GAME, 8 | STATE_GAME_OVER, 9 | }; 10 | 11 | void run_game(); 12 | 13 | #endif -------------------------------------------------------------------------------- /examples/09_tetris/src/main.c: -------------------------------------------------------------------------------- 1 | #include "ubox.h" 2 | #include "game.h" 3 | #include "util.h" 4 | 5 | uint8_t g_gamestate = STATE_TITLE; 6 | uint8_t ctl; 7 | 8 | void draw_title() 9 | { 10 | uint8_t i; 11 | 12 | ubox_disable_screen(); 13 | 14 | ubox_fill_screen(WHITESPACE_TILE); 15 | 16 | put_text(13, 9, "TETRIS"); 17 | put_text(8, 11, "PRESS SPACE BAR"); 18 | 19 | put_text(8, 18, "\0372021 YUZA SOFT"); 20 | 21 | ubox_enable_screen(); 22 | 23 | while (1) 24 | { 25 | ctl = ubox_select_ctl(); 26 | 27 | if (ctl != UBOX_MSX_CTL_NONE) 28 | break; 29 | 30 | ubox_wait(); 31 | } 32 | 33 | g_gamestate = STATE_IN_GAME; 34 | } 35 | 36 | void draw_game_over() 37 | { 38 | ubox_disable_screen(); 39 | 40 | put_text(11, 10, "GAME OVER"); 41 | 42 | ubox_enable_screen(); 43 | 44 | ubox_wait_for(128); 45 | 46 | ubox_disable_screen(); 47 | ubox_fill_screen(WHITESPACE_TILE); 48 | ubox_enable_screen(); 49 | 50 | g_gamestate = STATE_TITLE; 51 | 52 | } 53 | 54 | void main() 55 | { 56 | InitEnvironment(); 57 | 58 | draw_title(); 59 | 60 | while (1) 61 | { 62 | switch (g_gamestate) 63 | { 64 | case STATE_GAME_OVER: 65 | draw_game_over(); 66 | break; 67 | case STATE_IN_GAME: 68 | run_game(); 69 | break; 70 | case STATE_TITLE: 71 | draw_title(); 72 | break; 73 | } 74 | 75 | ubox_wait(); 76 | } 77 | } -------------------------------------------------------------------------------- /examples/09_tetris/src/util.c: -------------------------------------------------------------------------------- 1 | #include "util.h" 2 | #include "ubox.h" 3 | 4 | #define LOCAL 5 | #include "tiles.h" 6 | 7 | volatile long g_tick_count = 0; //틱 카운트 8 | 9 | void put_text(uint8_t x, uint8_t y, const uint8_t *text) 10 | { 11 | while (*text) 12 | ubox_put_tile(x++, y, *text++ + 128 - 31); 13 | } 14 | 15 | void RenderTile(uint8_t x, uint8_t y, uint8_t tileNum) 16 | { 17 | 18 | ubox_put_tile(x, y, tileNum); 19 | } 20 | 21 | void RenderTiles(int x, int y, int x_count, int y_count, int tileNum) 22 | { 23 | 24 | for(int i = 0; i < y_count; i++) 25 | for(int j = 0; j < x_count; j++) 26 | ubox_put_tile(x + j, y + i, tileNum); 27 | 28 | } 29 | 30 | void InitEnvironment() 31 | { 32 | ubox_init_isr(2); 33 | 34 | ubox_set_mode(2); 35 | ubox_set_colors(1, 1, 1); 36 | 37 | ubox_disable_screen(); 38 | 39 | ubox_set_tiles(tiles); 40 | ubox_set_tiles_colors(tiles_colors); 41 | 42 | ubox_fill_screen(WHITESPACE_TILE); 43 | 44 | ubox_enable_screen(); 45 | 46 | ubox_set_user_isr(my_isr); 47 | ubox_wvdp(1, 0xe2); 48 | } 49 | 50 | int now() 51 | { 52 | return g_tick_count; 53 | } 54 | 55 | void my_isr() 56 | { 57 | g_tick_count++; 58 | } 59 | 60 | int InRect(int posx, int posy, struct Rect *rect) 61 | { 62 | if (posx >= rect->x1 && posx < rect->x2 && posy >= rect->y1 && posy < rect->y2) 63 | return 1; 64 | 65 | return 0; 66 | } 67 | -------------------------------------------------------------------------------- /examples/09_tetris/src/util.h: -------------------------------------------------------------------------------- 1 | #ifndef _UTIL_H 2 | #define _UTIL_H 3 | #include 4 | 5 | #define WHITESPACE_TILE 129 6 | #define BLACK_TILE 85 7 | #define GREEN_TILE 74 8 | #define YELLOW_TILE 77 9 | #define WHITE_TILE 81 10 | #define RED_TILE 80 11 | 12 | #define WHITESPACE_TILE 129 13 | 14 | struct Rect 15 | { 16 | uint8_t x1; 17 | uint8_t y1; 18 | uint8_t x2; 19 | uint8_t y2; 20 | }; 21 | 22 | void InitEnvironment(); 23 | void RenderTile(uint8_t x, uint8_t y, uint8_t tileNum); 24 | void RenderTiles(int x, int y, int x_count, int y_count, int tileNum); 25 | void put_text(uint8_t x, uint8_t y, const uint8_t *text); 26 | int now(); 27 | void my_isr(); 28 | int InRect(int posx, int posy, struct Rect *rect); 29 | 30 | #endif -------------------------------------------------------------------------------- /examples/10_breakout/.vscode/c_cpp_properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "Win32", 5 | "includePath": [ 6 | "${workspaceFolder}/**", 7 | "${workspaceFolder}/../../include" 8 | ], 9 | "defines": [ 10 | "_DEBUG", 11 | "UNICODE", 12 | "_UNICODE" 13 | ], 14 | "windowsSdkVersion": "10.0.19041.0", 15 | "compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.27.29110/bin/Hostx64/x64/cl.exe", 16 | "cStandard": "c17", 17 | "cppStandard": "c++17", 18 | "intelliSenseMode": "windows-msvc-x64" 19 | } 20 | ], 21 | "version": 4 22 | } -------------------------------------------------------------------------------- /examples/10_breakout/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "ubox.h": "c" 4 | } 5 | } -------------------------------------------------------------------------------- /examples/10_breakout/Makefile: -------------------------------------------------------------------------------- 1 | all: bin build 2 | make -C src 3 | 4 | export PATH := $(PWD)/../../bin:$(PATH) 5 | 6 | bin: 7 | mkdir -p ./bin 8 | 9 | build: 10 | mkdir -p ./build 11 | 12 | .PHONY: all clean 13 | clean: 14 | rm -rf ./bin ./build 15 | make -C src clean 16 | 17 | 18 | -------------------------------------------------------------------------------- /examples/10_breakout/src/crt0.z80: -------------------------------------------------------------------------------- 1 | .module crt0 2 | .globl _main 3 | 4 | .area _HOME 5 | .area _CODE 6 | .area _INITIALIZER 7 | .area _GSINIT 8 | .area _GSFINAL 9 | 10 | .area _DATA 11 | .area _INITIALIZED 12 | .area _BSEG 13 | .area _BSS 14 | .area _HEAP 15 | 16 | .area _CODE 17 | 18 | ENASLT = 0x0024 19 | RSLREG = 0x0138 20 | CLIKSW = 0xf3db 21 | 22 | ; ROM header 23 | .str "AB" 24 | .dw _main_init 25 | .db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 26 | 27 | _main_init:: 28 | 29 | ; init the stack 30 | di 31 | ld sp, #0xf380 32 | ei 33 | 34 | ; setup memory 35 | ; ref: https://www.msx.org/forum/msx-talk/development/memory-pages-again 36 | 37 | call RSLREG 38 | rrca 39 | rrca 40 | and #3 41 | ld c, a 42 | add a, #0xc1 43 | ld l, a 44 | ld h, #0xfc 45 | ld a, (hl) 46 | and #0x80 47 | or c 48 | ld c, a 49 | inc l 50 | inc l 51 | inc l 52 | inc l 53 | ld a, (hl) 54 | and #0x0c 55 | or c 56 | ld h, #0x80 57 | call ENASLT 58 | 59 | ; disable key click sound 60 | xor a 61 | ld (CLIKSW), a 62 | 63 | call gsinit 64 | call _main 65 | 66 | halt0: 67 | halt 68 | jr halt0 69 | 70 | .area _GSINIT 71 | gsinit:: 72 | ld bc, #l__INITIALIZER 73 | ld a, b 74 | or a, c 75 | jr Z, gsinit_next 76 | ld de, #s__INITIALIZED 77 | ld hl, #s__INITIALIZER 78 | ldir 79 | gsinit_next: 80 | 81 | .area _GSFINAL 82 | ret 83 | -------------------------------------------------------------------------------- /examples/10_breakout/src/game.h: -------------------------------------------------------------------------------- 1 | #ifndef _GAME_H 2 | #define _GAME_H 3 | 4 | enum GAME_STATE 5 | { 6 | STATE_TITLE = 0, 7 | STATE_IN_GAME, 8 | STATE_GAME_OVER, 9 | STATE_GAME_CLEAR, 10 | }; 11 | 12 | 13 | void run_game(); 14 | 15 | #endif -------------------------------------------------------------------------------- /examples/10_breakout/src/util.h: -------------------------------------------------------------------------------- 1 | #ifndef _UTIL_H 2 | #define _UTIL_H 3 | #include 4 | 5 | #define WHITESPACE_TILE 129 6 | #define BLACK_TILE 85 7 | #define GREEN_TILE 74 8 | #define YELLOW_TILE 77 9 | #define WHITE_TILE 81 10 | #define RED_TILE 80 11 | 12 | struct Rect 13 | { 14 | uint8_t x1; 15 | uint8_t y1; 16 | uint8_t x2; 17 | uint8_t y2; 18 | }; 19 | 20 | void InitEnvironment(); 21 | void RenderTile(int x, int y, int tileNum); 22 | void RenderBlock(int x, int y); 23 | void put_text(uint8_t x, uint8_t y, const uint8_t *text); 24 | int now(); 25 | void my_isr(); 26 | int InRect(int posx, int posy, struct Rect *rect); 27 | void EraseTiles(int x, int y, int x_count, int y_count, int tileNum); 28 | 29 | #endif -------------------------------------------------------------------------------- /examples/11_log/Makefile: -------------------------------------------------------------------------------- 1 | all: bin build 2 | make -C src 3 | 4 | export PATH := $(PWD)/../../bin:$(PATH) 5 | 6 | bin: 7 | mkdir -p ./bin 8 | 9 | build: 10 | mkdir -p ./build 11 | 12 | .PHONY: all clean 13 | clean: 14 | rm -rf ./bin ./build 15 | make -C src clean 16 | 17 | 18 | -------------------------------------------------------------------------------- /examples/11_log/src/Makefile: -------------------------------------------------------------------------------- 1 | TARGET := 11_log 2 | 3 | CODE := 0x4000 4 | # leaves 222 bytes for AKM player buffer 5 | DATA := 0xc0de 6 | 7 | # HEX, will fill with 0 8 | ROM_MAX := 8000 9 | 10 | OUTPUT := ../build 11 | OBJS := $(patsubst %.c,$(OUTPUT)/%.rel,$(wildcard *.c)) 12 | UBOX_LIBS := $(wildcard ../../../lib/*.lib) 13 | LIBS := -lubox -lspman -lmplayer -lap 14 | 15 | CC := sdcc 16 | AS := sdasz80 17 | AR := sdcclib 18 | CFLAGS := --debug -mz80 --Werror -I../../../include -I../generated --fsigned-char --std-sdcc99 --opt-code-speed 19 | LDFLAGS := -L../../../lib -L. --no-std-crt0 --fomit-frame-pointer 20 | 21 | all: $(OUTPUT)/$(TARGET).rom 22 | python ../../../tools/chksize 8000 4000 $(OUTPUT)/$(TARGET).map 23 | @cp ../bin/$(TARGET).rom ../../bin 24 | 25 | openmsx: all 26 | openmsx -carta $(OUTPUT)/$(TARGET).rom -machine msx1 27 | 28 | $(OUTPUT)/%.rel: %.c 29 | $(CC) $(CFLAGS) $(LDFLAGS) -c $< -o $@ 30 | 31 | $(OUTPUT)/%.rel: %.z80 32 | $(AS) -g -o $@ $< 33 | 34 | $(OUTPUT)/$(TARGET).rom: $(OBJS) $(OUTPUT)/crt0.rel $(UBOX_LIBS) 35 | $(CC) $(CFLAGS) $(LDFLAGS) $(LIBS) --code-loc $(CODE) --data-loc $(DATA) $(OUTPUT)/crt0.rel $(OBJS) -o $(OUTPUT)/$(TARGET).ihx 36 | hex2bin -e bin -p 00 -l $(ROM_MAX) $(OUTPUT)/$(TARGET).ihx 37 | @cp $(OUTPUT)/$(TARGET).bin ../bin/$(TARGET).rom 38 | 39 | clean: 40 | rm -f $(OUTPUT)/* 41 | rm -f ../bin/$(TARGET).rom ../../bin/$(TARGET).rom 42 | 43 | .PHONY: all clean 44 | -------------------------------------------------------------------------------- /examples/11_log/src/crt0.z80: -------------------------------------------------------------------------------- 1 | .module crt0 2 | .globl _main 3 | 4 | .area _HOME 5 | .area _CODE 6 | .area _INITIALIZER 7 | .area _GSINIT 8 | .area _GSFINAL 9 | 10 | .area _DATA 11 | .area _INITIALIZED 12 | .area _BSEG 13 | .area _BSS 14 | .area _HEAP 15 | 16 | .area _CODE 17 | 18 | ENASLT = 0x0024 19 | RSLREG = 0x0138 20 | CLIKSW = 0xf3db 21 | 22 | ; ROM header 23 | .str "AB" 24 | .dw _main_init 25 | .db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 26 | 27 | _main_init:: 28 | 29 | ; init the stack 30 | di 31 | ld sp, #0xf380 32 | ei 33 | 34 | ; setup memory 35 | ; ref: https://www.msx.org/forum/msx-talk/development/memory-pages-again 36 | 37 | call RSLREG 38 | rrca 39 | rrca 40 | and #3 41 | ld c, a 42 | add a, #0xc1 43 | ld l, a 44 | ld h, #0xfc 45 | ld a, (hl) 46 | and #0x80 47 | or c 48 | ld c, a 49 | inc l 50 | inc l 51 | inc l 52 | inc l 53 | ld a, (hl) 54 | and #0x0c 55 | or c 56 | ld h, #0x80 57 | call ENASLT 58 | 59 | ; disable key click sound 60 | xor a 61 | ld (CLIKSW), a 62 | 63 | call gsinit 64 | call _main 65 | 66 | halt0: 67 | halt 68 | jr halt0 69 | 70 | .area _GSINIT 71 | gsinit:: 72 | ld bc, #l__INITIALIZER 73 | ld a, b 74 | or a, c 75 | jr Z, gsinit_next 76 | ld de, #s__INITIALIZED 77 | ld hl, #s__INITIALIZER 78 | ldir 79 | gsinit_next: 80 | 81 | .area _GSFINAL 82 | ret 83 | -------------------------------------------------------------------------------- /examples/11_log/src/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "ubox.h" 7 | #include 8 | 9 | #define LOCAL 10 | #include "tiles.h" 11 | 12 | #define WHITESPACE_TILE 129 13 | 14 | 15 | void put_text(uint8_t x, uint8_t y, const uint8_t *text) 16 | { 17 | while (*text) 18 | ubox_put_tile(x++, y, *text++ + 128 - 31); 19 | } 20 | 21 | void HALT() 22 | { 23 | while(1) { 24 | __asm__ ("halt"); 25 | }; 26 | } 27 | 28 | void UBOX_FATAL(const char* message, int line_number) 29 | { 30 | char fileName[256]; 31 | char error_message[256]; 32 | 33 | strcpy(fileName, __FILE__); 34 | for(int i = 0; i < strlen(fileName); i++) 35 | { 36 | fileName[i] = (char)toupper((fileName[i])); 37 | } 38 | 39 | sprintf(error_message, "%s %d %s", fileName, line_number, message); 40 | put_text(0, 0, error_message); 41 | //HALT(); 42 | } 43 | 44 | void main() 45 | { 46 | 47 | ubox_init_isr(2); 48 | 49 | ubox_set_mode(2); 50 | 51 | ubox_set_colors(1, 1, 1); 52 | 53 | ubox_disable_screen(); 54 | 55 | ubox_set_tiles(tiles); 56 | ubox_set_tiles_colors(tiles_colors); 57 | 58 | ubox_enable_screen(); 59 | 60 | ubox_fill_screen(WHITESPACE_TILE); 61 | 62 | char* data = malloc(1000000); 63 | 64 | if(data == 0) 65 | { 66 | UBOX_FATAL("DATA IS NULL", __LINE__); 67 | UBOX_FATAL("NOT PRINTED!!", __LINE__); 68 | } 69 | 70 | while (1) 71 | { 72 | ubox_wait(); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /examples/12_debugger/Makefile: -------------------------------------------------------------------------------- 1 | all: bin build 2 | make -C src 3 | 4 | export PATH := $(PWD)/../../bin:$(PATH) 5 | 6 | bin: 7 | mkdir -p ./bin 8 | 9 | build: 10 | mkdir -p ./build 11 | 12 | .PHONY: all clean 13 | clean: 14 | rm -rf ./bin ./build 15 | make -C src clean 16 | 17 | 18 | -------------------------------------------------------------------------------- /examples/12_debugger/src/Makefile: -------------------------------------------------------------------------------- 1 | TARGET := 12_debugger 2 | 3 | CODE := 0x4000 4 | # leaves 222 bytes for AKM player buffer 5 | DATA := 0xc0de 6 | 7 | # HEX, will fill with 0 8 | ROM_MAX := 8000 9 | 10 | OUTPUT := ../build 11 | OBJS := $(patsubst %.c,$(OUTPUT)/%.rel,$(wildcard *.c)) 12 | UBOX_LIBS := $(wildcard ../../../lib/*.lib) 13 | LIBS := -lubox -lspman -lmplayer -lap 14 | 15 | CC := sdcc 16 | AS := sdasz80 17 | AR := sdcclib 18 | CFLAGS := -mz80 --Werror -I../../../include -I../generated --fsigned-char --std-sdcc99 --opt-code-speed 19 | LDFLAGS := -L../../../lib -L. --no-std-crt0 --fomit-frame-pointer 20 | 21 | all: $(OUTPUT)/$(TARGET).rom 22 | python ../../../tools/chksize 8000 4000 $(OUTPUT)/$(TARGET).map 23 | @cp ../bin/$(TARGET).rom ../../bin 24 | 25 | openmsx: all 26 | openmsx -carta $(OUTPUT)/$(TARGET).rom -machine msx1 27 | 28 | $(OUTPUT)/%.rel: %.c 29 | $(CC) $(CFLAGS) $(LDFLAGS) -c $< -o $@ 30 | 31 | $(OUTPUT)/%.rel: %.z80 32 | $(AS) -g -o $@ $< 33 | 34 | $(OUTPUT)/$(TARGET).rom: $(OBJS) $(OUTPUT)/crt0.rel $(UBOX_LIBS) 35 | $(CC) $(CFLAGS) $(LDFLAGS) $(LIBS) --code-loc $(CODE) --data-loc $(DATA) $(OUTPUT)/crt0.rel $(OBJS) -o $(OUTPUT)/$(TARGET).ihx 36 | hex2bin -e bin -p 00 -l $(ROM_MAX) $(OUTPUT)/$(TARGET).ihx 37 | @cp $(OUTPUT)/$(TARGET).bin ../bin/$(TARGET).rom 38 | 39 | clean: 40 | rm -f $(OUTPUT)/* 41 | rm -f ../bin/$(TARGET).rom ../../bin/$(TARGET).rom 42 | 43 | .PHONY: all clean 44 | -------------------------------------------------------------------------------- /examples/12_debugger/src/crt0.z80: -------------------------------------------------------------------------------- 1 | .module crt0 2 | .globl _main 3 | 4 | .area _HOME 5 | .area _CODE 6 | .area _INITIALIZER 7 | .area _GSINIT 8 | .area _GSFINAL 9 | 10 | .area _DATA 11 | .area _INITIALIZED 12 | .area _BSEG 13 | .area _BSS 14 | .area _HEAP 15 | 16 | .area _CODE 17 | 18 | ENASLT = 0x0024 19 | RSLREG = 0x0138 20 | CLIKSW = 0xf3db 21 | 22 | ; ROM header 23 | .str "AB" 24 | .dw _main_init 25 | .db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 26 | 27 | _main_init:: 28 | 29 | ; init the stack 30 | di 31 | ld sp, #0xf380 32 | ei 33 | 34 | ; setup memory 35 | ; ref: https://www.msx.org/forum/msx-talk/development/memory-pages-again 36 | 37 | call RSLREG 38 | rrca 39 | rrca 40 | and #3 41 | ld c, a 42 | add a, #0xc1 43 | ld l, a 44 | ld h, #0xfc 45 | ld a, (hl) 46 | and #0x80 47 | or c 48 | ld c, a 49 | inc l 50 | inc l 51 | inc l 52 | inc l 53 | ld a, (hl) 54 | and #0x0c 55 | or c 56 | ld h, #0x80 57 | call ENASLT 58 | 59 | ; disable key click sound 60 | xor a 61 | ld (CLIKSW), a 62 | 63 | call gsinit 64 | call _main 65 | 66 | halt0: 67 | halt 68 | jr halt0 69 | 70 | .area _GSINIT 71 | gsinit:: 72 | ld bc, #l__INITIALIZER 73 | ld a, b 74 | or a, c 75 | jr Z, gsinit_next 76 | ld de, #s__INITIALIZED 77 | ld hl, #s__INITIALIZER 78 | ldir 79 | gsinit_next: 80 | 81 | .area _GSFINAL 82 | ret 83 | -------------------------------------------------------------------------------- /examples/12_debugger/src/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "ubox.h" 3 | 4 | #define LOCAL 5 | #include "tiles.h" 6 | 7 | #define WHITESPACE_TILE 129 8 | 9 | 10 | void put_text(uint8_t x, uint8_t y, const uint8_t *text) 11 | { 12 | while (*text) 13 | ubox_put_tile(x++, y, *text++ + 128 - 31); 14 | } 15 | 16 | uint32_t sum(uint32_t a, uint32_t b) 17 | { 18 | return a + b; 19 | } 20 | 21 | void echo_function(uint8_t a) 22 | { 23 | uint8_t b = a; 24 | } 25 | 26 | 27 | void main() 28 | { 29 | 30 | ubox_init_isr(2); 31 | 32 | ubox_set_mode(2); 33 | 34 | ubox_set_colors(1, 1, 1); 35 | 36 | ubox_disable_screen(); 37 | 38 | ubox_set_tiles(tiles); 39 | ubox_set_tiles_colors(tiles_colors); 40 | 41 | ubox_fill_screen(WHITESPACE_TILE); 42 | 43 | ubox_enable_screen(); 44 | 45 | uint8_t result = sum(5, 4); 46 | 47 | echo_function(result); 48 | 49 | while (1) 50 | { 51 | ubox_wait(); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /examples/12_debugger/symbol_conversion.py: -------------------------------------------------------------------------------- 1 | import string 2 | import sys 3 | 4 | def is_hex(s): 5 | try: 6 | int(s, 16) 7 | return True 8 | except ValueError: 9 | return False 10 | 11 | f1 = open('12_debugger.sym','w') # 저장할 파일 이름 12 | with open('12_debugger.map','r') as f2: # 원본 심볼 파일 13 | for line in f2: # 원본 파일에서 한줄씩 읽는다 14 | line1 = line.strip() 15 | words = line1.split() # 라인을 단어로 구분해서 words 리스트 변수에 저장한다 16 | if len(words) > 1: 17 | if is_hex(words[0]): # 숫자로 시작하는 경우에만 기록한다 18 | f1.write(words[1] + ': equ ' + words[0] + "H\n") 19 | f2.close() # 생성 파일의 핸들을 닫는다 20 | f1.close() # 원본 파일의 핸들을 닫는다 21 | exit() 22 | -------------------------------------------------------------------------------- /examples/Makefile: -------------------------------------------------------------------------------- 1 | all: 01_hello 02_consolehello 03_timer 04_clibrary 05_music 06_sound 07_snakebyte 08_socoban 09_tetris 10_breakout 11_log 12_debugger 2 | 3 | export PATH := $(PWD)/../bin:$(PATH) 4 | 5 | 01_hello: bin 6 | make -C 01_hello 7 | 8 | 02_consolehello: bin 9 | make -C 02_consolehello 10 | 11 | 03_timer: bin 12 | make -C 03_timer 13 | 14 | 04_clibrary: bin 15 | make -C 04_clibrary 16 | 17 | 05_music: bin 18 | make -C 05_music 19 | 20 | 06_sound: bin 21 | make -C 06_sound 22 | 23 | 07_snakebyte: bin 24 | make -C 07_snakebyte 25 | 26 | 27 | 08_socoban: bin 28 | make -C 08_socoban 29 | 30 | 09_tetris: bin 31 | make -C 09_tetris 32 | 33 | 10_breakout: bin 34 | make -C 10_breakout 35 | 36 | 11_log: bin 37 | make -C 11_log 38 | 39 | 12_debugger: bin 40 | make -C 12_debugger 41 | 42 | .PHONY: clean cleanall 01_hello 02_consolehello 03_timer 04_clibrary 05_music 06_sound 07_snakebyte 08_socoban 09_tetris 10_breakout 11_log 12_debugger 43 | clean: 44 | make -C 01_hello clean 45 | make -C 02_consolehello clean 46 | make -C 03_timer clean 47 | make -C 04_clibrary clean 48 | make -C 05_music clean 49 | make -C 06_sound clean 50 | make -C 07_snakebyte clean 51 | make -C 08_socoban clean 52 | make -C 09_tetris clean 53 | make -C 10_breakout clean 54 | 55 | bin: 56 | mkdir -p ./bin 57 | 58 | cleanall: clean 59 | rm -rf ./bin -------------------------------------------------------------------------------- /game/Makefile: -------------------------------------------------------------------------------- 1 | all: generated bin build 2 | make -C data 3 | cd src && python ../../tools/mkdeps.py -b ../build -I ../generated:../../include ./ Makefile.deps 4 | make -C src 5 | 6 | generated: 7 | mkdir -p ./generated 8 | 9 | bin: 10 | mkdir -p ./bin 11 | 12 | build: 13 | mkdir -p ./build 14 | 15 | .PHONY: all clean 16 | clean: 17 | rm -rf ./generated ./bin ./build 18 | make -C src clean 19 | make -C data clean 20 | 21 | -------------------------------------------------------------------------------- /game/data/Makefile: -------------------------------------------------------------------------------- 1 | OUTPUT := ../generated 2 | GENERATED := $(OUTPUT)/tiles.h $(OUTPUT)/player.h $(OUTPUT)/enemy.h $(OUTPUT)/map.h 3 | 4 | all: $(GENERATED) 5 | 6 | $(OUTPUT)/tiles.h: tiles.png 7 | python ../../tools/png2tiles.py -i tiles $< > $@ 8 | 9 | $(OUTPUT)/player.h: player.png 10 | python ../../tools/png2sprites.py -i player_sprite $< > $@ 11 | 12 | $(OUTPUT)/enemy.h: enemy.png 13 | python ../../tools/png2sprites.py -i enemy_sprite $< > $@ 14 | 15 | $(OUTPUT)/map.h: map.json map_conf.json 16 | python ../../tools/map.py --aplib --max-ents 11 --room-height 21 map.json map > $@ 17 | 18 | .PHONY: all clean 19 | clean: 20 | rm -f $(OUTPUT)/* 21 | 22 | -------------------------------------------------------------------------------- /game/data/effects.aks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/game/data/effects.aks -------------------------------------------------------------------------------- /game/data/enemy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/game/data/enemy.png -------------------------------------------------------------------------------- /game/data/map_conf.json: -------------------------------------------------------------------------------- 1 | { 2 | "entities": [ 3 | { 4 | "bytes": 0, 5 | "name": "unused", 6 | "w": 1 7 | }, 8 | { 9 | "bytes": 0, 10 | "name": "player", 11 | "w": 1 12 | }, 13 | { 14 | "bytes": 0, 15 | "name": "enemy", 16 | "w": 1 17 | } 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /game/data/player.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/game/data/player.png -------------------------------------------------------------------------------- /game/data/song.aks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/game/data/song.aks -------------------------------------------------------------------------------- /game/data/symbol_conversion.py: -------------------------------------------------------------------------------- 1 | import string 2 | import sys 3 | 4 | def is_hex(s): 5 | try: 6 | int(s, 16) 7 | return True 8 | except ValueError: 9 | return False 10 | 11 | f1 = open('game_conv.map','w') # 저장할 파일 이름 12 | with open('game.map','r') as f2: # 원본 심볼 파일 13 | for line in f2: # 원본 파일에서 한줄씩 읽는다 14 | line1 = line.strip() 15 | words = line1.split() # 라인을 단어로 구분해서 words 리스트 변수에 저장한다 16 | if len(words) > 1: 17 | if is_hex(words[0]): # 숫자로 시작하는 경우에만 기록한다 18 | f1.write(words[1] + ': equ ' + words[0] + "H\n") 19 | f2.close() # 생성 파일의 핸들을 닫는다 20 | f1.close() # 원본 파일의 핸들을 닫는다 21 | exit() 22 | -------------------------------------------------------------------------------- /game/data/tiles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/game/data/tiles.png -------------------------------------------------------------------------------- /game/src/Makefile: -------------------------------------------------------------------------------- 1 | TARGET := game 2 | 3 | CODE := 0x4000 4 | # leaves 222 bytes for AKM player buffer 5 | DATA := 0xc0de 6 | 7 | # HEX, will fill with 0 8 | ROM_MAX := 8000 9 | 10 | OUTPUT := ../build 11 | OBJS := $(patsubst %.c,$(OUTPUT)/%.rel,$(wildcard *.c)) $(OUTPUT)/akm.rel 12 | UBOX_LIBS := $(wildcard ../../lib/*.lib) 13 | LIBS := -lubox -lspman -lmplayer -lap 14 | 15 | CC := sdcc 16 | AS := sdasz80 17 | AR := sdcclib 18 | CFLAGS := -mz80 --Werror -I../../include -I../generated --fsigned-char --std-sdcc99 --opt-code-speed 19 | LDFLAGS := -L../../lib -L. --no-std-crt0 --fomit-frame-pointer 20 | 21 | all: $(OUTPUT)/$(TARGET).rom 22 | python ../../tools/chksize 8000 4000 $(OUTPUT)/$(TARGET).map 23 | @cp ../bin/$(TARGET).rom ../../bin 24 | 25 | openmsx: all 26 | openmsx -carta $(OUTPUT)/$(TARGET).rom -machine msx1 27 | 28 | $(OUTPUT)/%.rel: %.c 29 | $(CC) $(CFLAGS) $(LDFLAGS) -c $< -o $@ 30 | 31 | $(OUTPUT)/%.rel: %.z80 32 | $(AS) -g -o $@ $< 33 | 34 | $(OUTPUT)/akm.rel: akm.z80 song.asm effects.asm 35 | rasm akm.z80 -o $(OUTPUT)/akm -s -sl -sq 36 | Disark --sourceProfile sdcc --symbolFile $(OUTPUT)/akm.sym --src16bitsValuesInHex --src8bitsValuesInHex --undocumentedOpcodesToBytes $(OUTPUT)/akm.bin $(OUTPUT)/akm_sdcc.asm 37 | $(AS) -g -o $@ $(OUTPUT)/akm_sdcc.asm 38 | 39 | $(OUTPUT)/$(TARGET).rom: $(OBJS) $(OUTPUT)/crt0.rel $(UBOX_LIBS) 40 | $(CC) $(CFLAGS) $(LDFLAGS) $(LIBS) --code-loc $(CODE) --data-loc $(DATA) $(OUTPUT)/crt0.rel $(OBJS) -o $(OUTPUT)/$(TARGET).ihx 41 | hex2bin -e bin -p 00 -l $(ROM_MAX) $(OUTPUT)/$(TARGET).ihx 42 | @cp $(OUTPUT)/$(TARGET).bin ../bin/$(TARGET).rom 43 | 44 | clean: 45 | rm -f $(OUTPUT)/* 46 | rm -f ../bin/$(TARGET).rom ../../bin/$(TARGET).rom 47 | 48 | .PHONY: all clean 49 | 50 | include Makefile.deps 51 | -------------------------------------------------------------------------------- /game/src/Makefile.deps: -------------------------------------------------------------------------------- 1 | ../build/data.rel: data.c ../generated/tiles.h ../generated/player.h \ 2 | ../generated/enemy.h ../generated/map.h 3 | ../build/game.rel: game.c ../../include/ubox.h ../../include/spman.h \ 4 | ../../include/ubox.h ../../include/mplayer.h ../../include/ap.h \ 5 | helpers.h main.h game.h ../generated/map.h ../generated/player.h \ 6 | ../generated/enemy.h 7 | ../build/helpers.rel: helpers.c ../../include/ubox.h helpers.h 8 | ../build/main.rel: main.c ../../include/ubox.h ../../include/mplayer.h helpers.h \ 9 | game.h main.h ../generated/tiles.h -------------------------------------------------------------------------------- /game/src/akm.z80: -------------------------------------------------------------------------------- 1 | ; 2 | ; to build the custom AKM player with song + effects 3 | ; 4 | 5 | include "song_playerconfig.asm" 6 | include "effects_playerconfig.asm" 7 | 8 | include "../../src/mplayer/akm/akm_ubox.asm" 9 | 10 | songDisarkGenerateExternalLabel: 11 | include "song.asm" 12 | 13 | effectsDisarkGenerateExternalLabel: 14 | include "effects.asm" 15 | 16 | -------------------------------------------------------------------------------- /game/src/crt0.z80: -------------------------------------------------------------------------------- 1 | .module crt0 2 | .globl _main 3 | 4 | .area _HOME 5 | .area _CODE 6 | .area _INITIALIZER 7 | .area _GSINIT 8 | .area _GSFINAL 9 | 10 | .area _DATA 11 | .area _INITIALIZED 12 | .area _BSEG 13 | .area _BSS 14 | .area _HEAP 15 | 16 | .area _CODE 17 | 18 | ENASLT = 0x0024 19 | RSLREG = 0x0138 20 | CLIKSW = 0xf3db 21 | 22 | ; ROM header 23 | .str "AB" 24 | .dw _main_init 25 | .db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 26 | 27 | _main_init:: 28 | 29 | ; init the stack 30 | di 31 | ld sp, #0xf380 32 | ei 33 | 34 | ; setup memory 35 | ; ref: https://www.msx.org/forum/msx-talk/development/memory-pages-again 36 | 37 | call RSLREG 38 | rrca 39 | rrca 40 | and #3 41 | ld c, a 42 | add a, #0xc1 43 | ld l, a 44 | ld h, #0xfc 45 | ld a, (hl) 46 | and #0x80 47 | or c 48 | ld c, a 49 | inc l 50 | inc l 51 | inc l 52 | inc l 53 | ld a, (hl) 54 | and #0x0c 55 | or c 56 | ld h, #0x80 57 | call ENASLT 58 | 59 | ; disable key click sound 60 | xor a 61 | ld (CLIKSW), a 62 | 63 | call gsinit 64 | call _main 65 | 66 | halt0: 67 | halt 68 | jr halt0 69 | 70 | .area _GSINIT 71 | gsinit:: 72 | ld bc, #l__INITIALIZER 73 | ld a, b 74 | or a, c 75 | jr Z, gsinit_next 76 | ld de, #s__INITIALIZED 77 | ld hl, #s__INITIALIZER 78 | ldir 79 | gsinit_next: 80 | 81 | .area _GSFINAL 82 | ret 83 | -------------------------------------------------------------------------------- /game/src/data.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Module storing the generated data. 3 | */ 4 | 5 | #define LOCAL 6 | #include "tiles.h" 7 | #include "player.h" 8 | #include "enemy.h" 9 | #include "map.h" 10 | -------------------------------------------------------------------------------- /game/src/effects_playerconfig.asm: -------------------------------------------------------------------------------- 1 | ; Configuration that can be included to Arkos Tracker 2 players. 2 | ; It indicates what parts of code are useful to the song/sound effects, to save both memory and CPU. 3 | ; The players may or may not take advantage of these flags, it is up to them. 4 | 5 | ; You can either: 6 | ; - Include this to the source that also includes the player (BEFORE the player is included) (recommended solution). 7 | ; - Include this at the beginning of the player code. 8 | ; - Copy/paste this directly in the player. 9 | ; If you use one player but several songs, don't worry, these declarations will stack up. 10 | ; If no configuration is used, the player will use default values (full code used). 11 | 12 | PLY_CFG_SFX_ConfigurationIsPresent = 1 13 | PLY_CFG_SFX_SoftOnly = 1 14 | PLY_CFG_SFX_SoftOnly_Noise = 1 15 | -------------------------------------------------------------------------------- /game/src/helpers.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "ubox.h" 4 | 5 | #include "helpers.h" 6 | 7 | /** 8 | * Put a zero terminated string on the screen using tiles. 9 | * 10 | * The font starts on the tileset on tile 128 and the fist char in our has 11 | * ASCII value 31, so it is adjusted so we can use ASCII *uppercase* directly 12 | * in our C code. 13 | */ 14 | void put_text(uint8_t x, uint8_t y, const uint8_t *text) 15 | { 16 | while (*text) 17 | ubox_put_tile(x++, y, *text++ + 128 - 31); 18 | } 19 | -------------------------------------------------------------------------------- /game/src/helpers.h: -------------------------------------------------------------------------------- 1 | #ifndef _HELPERS_H 2 | #define _HELPERS_H 3 | 4 | #include 5 | 6 | /** 7 | * Auxiliary functions. 8 | */ 9 | 10 | void put_text(uint8_t x, uint8_t y, const uint8_t *text); 11 | 12 | #endif // _HELPERS_H 13 | -------------------------------------------------------------------------------- /game/src/main.h: -------------------------------------------------------------------------------- 1 | #ifndef _MAIN_H 2 | #define _MAIN_H 3 | 4 | #include 5 | 6 | #ifndef LOCAL 7 | #define LOCAL extern 8 | #endif 9 | 10 | #define WHITESPACE_TILE 129 11 | 12 | // sub-songs matching our Arkos song 13 | // configure the song to use MSX AY 14 | enum songs 15 | { 16 | SONG_SILENCE = 0, 17 | SONG_IN_GAME, 18 | SONG_GAME_OVER, 19 | }; 20 | 21 | // we will use 0 and 1 for the music 22 | #define EFX_CHAN_NO 2 23 | 24 | // sound effects matching our Arkos efx song 25 | // configure the song to use MSX AY 26 | enum effects 27 | { 28 | EFX_NONE = 0, 29 | EFX_START, 30 | EFX_BATTERY, 31 | EFX_ELEVATOR, 32 | EFX_HIT, 33 | EFX_DEAD, 34 | }; 35 | 36 | void draw_end_game(); 37 | void draw_menu(); 38 | 39 | // store the selected control 40 | LOCAL uint8_t ctl; 41 | 42 | // Arkos data 43 | extern uint8_t SONG[]; 44 | extern uint8_t EFFECTS[]; 45 | 46 | #ifdef LOCAL 47 | #undef LOCAL 48 | #endif 49 | 50 | #endif // _MAIN_H 51 | -------------------------------------------------------------------------------- /game/src/song_playerconfig.asm: -------------------------------------------------------------------------------- 1 | ; Configuration that can be included to Arkos Tracker 2 players. 2 | ; It indicates what parts of code are useful to the song/sound effects, to save both memory and CPU. 3 | ; The players may or may not take advantage of these flags, it is up to them. 4 | 5 | ; You can either: 6 | ; - Include this to the source that also includes the player (BEFORE the player is included) (recommended solution). 7 | ; - Include this at the beginning of the player code. 8 | ; - Copy/paste this directly in the player. 9 | ; If you use one player but several songs, don't worry, these declarations will stack up. 10 | ; If no configuration is used, the player will use default values (full code used). 11 | 12 | PLY_CFG_ConfigurationIsPresent = 1 13 | PLY_CFG_NoSoftNoHard = 1 14 | PLY_CFG_SoftOnly = 1 15 | PLY_CFG_SoftOnly_Noise = 1 16 | PLY_CFG_SoftOnly_SoftwareArpeggio = 1 17 | PLY_CFG_SoftOnly_SoftwarePitch = 1 18 | -------------------------------------------------------------------------------- /game/symbol_conversion.py: -------------------------------------------------------------------------------- 1 | import string 2 | import sys 3 | 4 | def is_hex(s): 5 | try: 6 | int(s, 16) 7 | return True 8 | except ValueError: 9 | return False 10 | 11 | f1 = open('game_conv.sym','w') # 저장할 파일 이름 12 | with open('game.map','r') as f2: # 원본 심볼 파일 13 | for line in f2: # 원본 파일에서 한줄씩 읽는다 14 | line1 = line.strip() 15 | words = line1.split() # 라인을 단어로 구분해서 words 리스트 변수에 저장한다 16 | if len(words) > 1: 17 | if is_hex(words[0]): # 숫자로 시작하는 경우에만 기록한다 18 | f1.write(words[1] + ': equ ' + words[0] + "H\n") 19 | f2.close() # 생성 파일의 핸들을 닫는다 20 | f1.close() # 원본 파일의 핸들을 닫는다 21 | exit() 22 | -------------------------------------------------------------------------------- /img/breakout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/img/breakout.png -------------------------------------------------------------------------------- /img/example11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/img/example11.png -------------------------------------------------------------------------------- /img/socoban.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/img/socoban.png -------------------------------------------------------------------------------- /img/tetris2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/img/tetris2.png -------------------------------------------------------------------------------- /include/ap.h: -------------------------------------------------------------------------------- 1 | #ifndef _AP_H 2 | #define _AP_H 3 | 4 | #include 5 | 6 | // @aPLib compression 7 | // 8 | // The `ap.lib` library allows decompressing data compressed by 9 | // [aPLib](https://ibsensoftware.com/products_aPLib.html). 10 | // 11 | // [apultra](https://github.com/emmanuel-marty/apultra) is an optimal 12 | // compressor for the aPLib format and it is included in tools for convenience. 13 | // 14 | // It will be compiled as part of the tools, but you can compile it 15 | // independently with: 16 | // 17 | // ``` 18 | // make bin/apultra 19 | // ``` 20 | // 21 | // The resulting binary will be placed in the `bin` directory. 22 | 23 | /** 24 | * Uncompress the data pointed by `src` into the memory pointed by `dst`. 25 | * 26 | * The compressed data is expected to be in aPLib raw format. 27 | */ 28 | void ap_uncompress(const uint8_t *dst, const uint8_t *src); 29 | 30 | #endif // _AP_H 31 | -------------------------------------------------------------------------------- /src/ap/Makefile: -------------------------------------------------------------------------------- 1 | LIB := ../../lib/ap.lib 2 | all: $(LIB) 3 | 4 | AS := sdasz80 5 | AR := sdar 6 | 7 | SOURCES := ap.z80 8 | OBJS := $(patsubst %.z80,%.rel,$(SOURCES)) 9 | 10 | $(LIB): $(OBJS) 11 | $(AR) -rcD $(LIB) $(OBJS) 12 | 13 | %.rel: %.z80 14 | $(AS) -o $< 15 | 16 | .PHONY: clean 17 | clean: 18 | rm -f $(OBJS) $(LIB) 19 | 20 | -------------------------------------------------------------------------------- /src/mplayer/Makefile: -------------------------------------------------------------------------------- 1 | LIB := ../../lib/mplayer.lib 2 | all: $(LIB) 3 | 4 | AS := sdasz80 5 | AR := sdar 6 | 7 | SOURCES := $(wildcard *.z80) 8 | OBJS := $(patsubst %.z80,%.rel,$(SOURCES)) 9 | 10 | $(LIB): $(OBJS) 11 | $(AR) -rcD $(LIB) $(OBJS) 12 | 13 | %.rel: %.z80 14 | $(AS) -o $< 15 | 16 | .PHONY: clean 17 | clean: 18 | rm -f $(OBJS) $(LIB) 19 | 20 | -------------------------------------------------------------------------------- /src/mplayer/akm/LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016-2020 Julien Névo (contact@julien-nevo.com) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /src/mplayer/akm/Makefile: -------------------------------------------------------------------------------- 1 | akm_sdcc.z80: main.asm 2 | rasm main.asm -o akm -s -sl -sq 3 | Disark --sourceProfile sdcc --symbolFile akm.sym --src16bitsValuesInHex --src8bitsValuesInHex --undocumentedOpcodesToBytes akm.bin akm_sdcc.z80 4 | 5 | -------------------------------------------------------------------------------- /src/mplayer/akm/README.md: -------------------------------------------------------------------------------- 1 | # Arkos 2 AKM Player 2 | 3 | Configured to use ROM and default options expecting a 222 bytes buffer starting 4 | at 0xc000. 5 | 6 | ## Local changes 7 | 8 | - A new function `PLY_AKM_IsDoundEffectOn` was added; this is used by the 9 | priority based sound effects. 10 | 11 | -------------------------------------------------------------------------------- /src/mplayer/akm/akm_ubox.asm: -------------------------------------------------------------------------------- 1 | 2 | ; these are common 3 | PLY_AKM_HARDWARE_MSX = 1 4 | PLY_AKM_MANAGE_SOUND_EFFECTS = 1 5 | PLY_AKM_Rom = 1 6 | PLY_AKM_ROM_Buffer = #c000 7 | 8 | include "PlayerAkm.asm" 9 | 10 | ; IN: L = channel 11 | ; OUT: L = 0 if is not on 12 | PLY_AKM_IsSoundEffectOnDisarkGenerateExternalLabel: 13 | PLY_AKM_IsSoundEffectOn: 14 | ld a,l 15 | add a,a 16 | add a,a 17 | add a,a 18 | ld c,a 19 | ld b,0 20 | ld hl,PLY_AKM_Channel1_SoundEffectData 21 | add hl,bc 22 | ld a,(hl) 23 | inc hl 24 | or (hl) 25 | ld l,a 26 | ret 27 | 28 | -------------------------------------------------------------------------------- /src/mplayer/mplayer_init.z80: -------------------------------------------------------------------------------- 1 | .globl _mplayer_init 2 | 3 | .globl _PLY_AKM_INIT 4 | 5 | _mplayer_init:: 6 | ld ix, #2 7 | add ix, sp 8 | 9 | ld l, 0 (ix) 10 | ld h, 1 (ix) 11 | ld a, 2 (ix) 12 | 13 | di 14 | call _PLY_AKM_INIT 15 | ei 16 | 17 | ret 18 | -------------------------------------------------------------------------------- /src/mplayer/mplayer_init_effects.z80: -------------------------------------------------------------------------------- 1 | .module mplayer 2 | 3 | .globl _mplayer_init_effects 4 | .globl mplayer_current_efx 5 | 6 | .globl _PLY_AKM_INITSOUNDEFFECTS 7 | 8 | _mplayer_init_effects:: 9 | xor a 10 | ld (mplayer_current_efx), a 11 | jp _PLY_AKM_INITSOUNDEFFECTS 12 | 13 | .area _DATA 14 | 15 | mplayer_current_efx: .ds 1 16 | 17 | -------------------------------------------------------------------------------- /src/mplayer/mplayer_is_sound_effect_on.z80: -------------------------------------------------------------------------------- 1 | .module mplayer 2 | 3 | .globl _mplayer_is_sound_effect_on 4 | 5 | .globl _PLY_AKM_ISSOUNDEFFECTON 6 | 7 | _mplayer_is_sound_effect_on:: 8 | jp _PLY_AKM_ISSOUNDEFFECTON 9 | 10 | -------------------------------------------------------------------------------- /src/mplayer/mplayer_play.z80: -------------------------------------------------------------------------------- 1 | .module mplayer 2 | 3 | .globl _mplayer_play 4 | 5 | .globl _PLY_AKM_PLAY 6 | 7 | _mplayer_play:: 8 | jp _PLY_AKM_PLAY 9 | 10 | -------------------------------------------------------------------------------- /src/mplayer/mplayer_play_effect.z80: -------------------------------------------------------------------------------- 1 | .module mplayer 2 | 3 | .globl _mplayer_play_effect 4 | 5 | .globl _PLY_AKM_PLAYSOUNDEFFECT 6 | 7 | _mplayer_play_effect:: 8 | ld hl, #2 9 | add hl, sp 10 | 11 | ld a, (hl) 12 | inc hl 13 | ld c, (hl) 14 | inc hl 15 | ld b, (hl) 16 | 17 | jp _PLY_AKM_PLAYSOUNDEFFECT 18 | 19 | -------------------------------------------------------------------------------- /src/mplayer/mplayer_play_effect_p.z80: -------------------------------------------------------------------------------- 1 | .module mplayer 2 | 3 | .globl _mplayer_play_effect_p 4 | .globl _mplayer_is_sound_effect_on 5 | .globl mplayer_current_efx 6 | 7 | .globl _PLY_AKM_PLAYSOUNDEFFECT 8 | 9 | _mplayer_play_effect_p:: 10 | ld hl, #2 11 | add hl, sp 12 | 13 | ld e, (hl) 14 | inc hl 15 | ld c, (hl) 16 | inc hl 17 | ld b, (hl) 18 | 19 | ; e effect no 20 | ; bc: channel and volume 21 | push bc 22 | push de 23 | ld l, c 24 | call _mplayer_is_sound_effect_on 25 | 26 | ld a, l 27 | or a 28 | pop de 29 | pop bc 30 | jr z, play_efx 31 | 32 | ld a, (mplayer_current_efx) 33 | ; comment out following line if you don't want to 34 | ; replace current sound if is the same effect type 35 | dec a 36 | cp e 37 | ret nc 38 | 39 | play_efx: 40 | ; all good, play the effect 41 | ld a, e 42 | ld (mplayer_current_efx), a 43 | 44 | jp _PLY_AKM_PLAYSOUNDEFFECT 45 | 46 | -------------------------------------------------------------------------------- /src/mplayer/mplayer_stop.z80: -------------------------------------------------------------------------------- 1 | .module mplayer 2 | 3 | .globl _mplayer_stop 4 | 5 | .globl _PLY_AKM_STOP 6 | 7 | _mplayer_stop:: 8 | jp _PLY_AKM_STOP 9 | 10 | -------------------------------------------------------------------------------- /src/mplayer/mplayer_stop_effect_channel.z80: -------------------------------------------------------------------------------- 1 | .module mplayer 2 | 3 | .globl _mplayer_stop_effect_channel 4 | 5 | .globl _PLY_AKM_STOPSOUNDEFFECTFROMCHANNEL 6 | 7 | _mplayer_stop_effect_channel:: 8 | ld a, l 9 | jp _PLY_AKM_STOPSOUNDEFFECTFROMCHANNEL 10 | 11 | -------------------------------------------------------------------------------- /src/spman/.gitignore: -------------------------------------------------------------------------------- 1 | spman.asm -------------------------------------------------------------------------------- /src/spman/Makefile: -------------------------------------------------------------------------------- 1 | LIB := ../../lib/spman.lib 2 | all: $(LIB) 3 | 4 | CC := sdcc 5 | AR := sdar 6 | CFLAGS := -mz80 --Werror -I../../include --fsigned-char --std-sdcc99 --opt-code-speed 7 | 8 | SOURCES := $(wildcard *.c) 9 | OBJS := $(patsubst %.c,%.rel,$(SOURCES)) 10 | 11 | $(LIB): $(OBJS) 12 | $(AR) -rcD $(LIB) $(OBJS) 13 | 14 | %.rel: %.c 15 | $(CC) $(CFLAGS) $(LDFLAGS) -c $< 16 | 17 | .PHONY: clean 18 | clean: 19 | rm -f $(OBJS) $(LIB) 20 | 21 | -------------------------------------------------------------------------------- /src/ubox/Makefile: -------------------------------------------------------------------------------- 1 | LIB := ../../lib/ubox.lib 2 | all: $(LIB) 3 | 4 | AS := sdasz80 5 | AR := sdar 6 | 7 | SOURCES := $(wildcard ubox_*.z80) 8 | OBJS := $(patsubst %.z80,%.rel,$(SOURCES)) 9 | 10 | $(LIB): $(OBJS) 11 | $(AR) -rcD $(LIB) $(OBJS) 12 | 13 | %.rel: %.z80 14 | $(AS) -o $< 15 | 16 | .PHONY: clean 17 | clean: 18 | rm -f $(OBJS) $(LIB) 19 | 20 | -------------------------------------------------------------------------------- /src/ubox/ubox_disable_screen.z80: -------------------------------------------------------------------------------- 1 | .globl _ubox_disable_screen 2 | 3 | DISSCR = 0x0041 4 | 5 | _ubox_disable_screen:: 6 | jp DISSCR 7 | 8 | -------------------------------------------------------------------------------- /src/ubox/ubox_enable_screen.z80: -------------------------------------------------------------------------------- 1 | .globl _ubox_enable_screen 2 | 3 | ENASCR = 0x0044 4 | 5 | _ubox_enable_screen:: 6 | jp ENASCR 7 | 8 | -------------------------------------------------------------------------------- /src/ubox/ubox_fill_screen.z80: -------------------------------------------------------------------------------- 1 | .globl _ubox_fill_screen 2 | 3 | FILVRM = 0x0056 4 | 5 | _ubox_fill_screen:: 6 | ld a, l 7 | ld hl, #0x1800 8 | ld bc, #768 9 | jp FILVRM 10 | 11 | -------------------------------------------------------------------------------- /src/ubox/ubox_get_tile.z80: -------------------------------------------------------------------------------- 1 | .globl _ubox_get_tile 2 | 3 | RDVRM = 0x004a 4 | 5 | _ubox_get_tile:: 6 | ld hl, #2 7 | add hl, sp 8 | 9 | ld b, #0 10 | ld c, (hl) 11 | inc hl 12 | ld l, (hl) 13 | 14 | ld h, #0 15 | add hl, hl 16 | add hl, hl 17 | add hl, hl 18 | add hl, hl 19 | add hl, hl 20 | add hl, bc 21 | 22 | ld bc, #0x1800 23 | add hl, bc 24 | 25 | call RDVRM 26 | ld l, a 27 | ret 28 | 29 | -------------------------------------------------------------------------------- /src/ubox/ubox_get_vsync_freq.z80: -------------------------------------------------------------------------------- 1 | .globl _ubox_get_vsync_freq 2 | 3 | _ubox_get_vsync_freq:: 4 | ld a, (#0x002b) 5 | and #128 6 | ld l, a 7 | ret z 8 | ld l, #1 9 | ret 10 | -------------------------------------------------------------------------------- /src/ubox/ubox_isr.z80: -------------------------------------------------------------------------------- 1 | .globl _ubox_init_isr 2 | .globl _ubox_tick 3 | .globl ubox_isr_wait_ticks 4 | .globl ubox_isr_wait_tick 5 | .globl ubox_usr_isr 6 | .globl ___sdcc_call_hl 7 | 8 | HTIMI_HOOK = 0xfd9f 9 | 10 | SCNCNT = 0xf3f6 11 | REPCNT = 0xf3f7 12 | 13 | _ubox_init_isr:: 14 | di 15 | ld a, l 16 | ld (ubox_isr_wait_ticks), a 17 | xor a 18 | ld (ubox_isr_wait_tick), a 19 | ld (_ubox_tick), a 20 | ld (ubox_usr_isr), a 21 | ld (ubox_usr_isr+1), a 22 | ld hl, #ubox_isr 23 | ex de, hl 24 | ld hl, #HTIMI_HOOK 25 | ld a, #0xc3 26 | ld (hl), a 27 | inc hl 28 | ld (hl), e 29 | inc hl 30 | ld (hl), d 31 | ei 32 | ret 33 | 34 | ubox_isr: 35 | push af 36 | push ix 37 | push iy 38 | push bc 39 | push hl 40 | push de 41 | 42 | ; stop BIOS reading keyboard buffer 43 | xor a 44 | ld (SCNCNT), a 45 | ld (REPCNT), a 46 | 47 | ld hl, #ubox_isr_wait_tick 48 | inc (hl) 49 | inc hl 50 | inc (hl) 51 | inc hl 52 | inc hl 53 | 54 | ; check user isr, only MSB 55 | ld a, (hl) 56 | or a 57 | jr z, no_user_isr 58 | 59 | dec hl 60 | ld l, (hl) 61 | ld h, a 62 | call ___sdcc_call_hl 63 | 64 | no_user_isr: 65 | pop de 66 | pop hl 67 | pop bc 68 | pop iy 69 | pop ix 70 | pop af 71 | ret 72 | 73 | .area _DATA 74 | 75 | ubox_isr_wait_ticks: .ds 1 76 | ubox_isr_wait_tick: .ds 1 77 | _ubox_tick: .ds 1 78 | 79 | ubox_usr_isr: .ds 2 80 | -------------------------------------------------------------------------------- /src/ubox/ubox_put_tile.z80: -------------------------------------------------------------------------------- 1 | .globl _ubox_put_tile 2 | 3 | WRTVRM = 0x004d 4 | 5 | _ubox_put_tile:: 6 | ld hl, #2 7 | add hl, sp 8 | 9 | ld c, (hl) 10 | inc hl 11 | ld b, (hl) 12 | inc hl 13 | 14 | ld a, (hl) 15 | 16 | ld h, #0 17 | ld l, b 18 | add hl, hl 19 | add hl, hl 20 | add hl, hl 21 | add hl, hl 22 | add hl, hl 23 | ld b, #0 24 | add hl, bc 25 | 26 | ld bc, #0x1800 27 | add hl, bc 28 | 29 | jp WRTVRM 30 | 31 | -------------------------------------------------------------------------------- /src/ubox/ubox_read_ctl.z80: -------------------------------------------------------------------------------- 1 | .globl _ubox_read_ctl 2 | 3 | RDPSG = 0x0096 4 | WRTPSG = 0x0093 5 | SNSMAT = 0x0141 6 | 7 | _ubox_read_ctl:: 8 | ld a, l 9 | or a 10 | jr z, is_keyb 11 | dec a 12 | jr z, is_joy1 13 | dec a 14 | jr z, is_joy2 15 | 16 | ld l, #0 17 | ret 18 | 19 | is_joy2: 20 | ; select 21 | ld e, #0xcf 22 | jr call_psg 23 | 24 | is_joy1: 25 | ; select 26 | ld e, #0x8f 27 | 28 | call_psg: 29 | ld a, #0x0f 30 | call WRTPSG 31 | 32 | ld a, #0x0e 33 | 34 | di 35 | call RDPSG 36 | ei 37 | cpl 38 | and #0x3f 39 | ld e, a 40 | 41 | ; button 2 (M) 42 | ld a, #4 43 | call SNSMAT 44 | rra 45 | rra 46 | rra 47 | ld a, #0x20 48 | jr nc, joy_extra_m 49 | xor a 50 | joy_extra_m: 51 | or e 52 | ld l, a 53 | ret 54 | 55 | is_keyb: 56 | ; button 2 (M) 57 | ld a, #4 58 | call SNSMAT 59 | rra 60 | rra 61 | rra 62 | ld e, #0x20 63 | jr nc, is_keyb_dir 64 | 65 | ld e, #0 66 | 67 | is_keyb_dir: 68 | ; direction 69 | ld a, #8 70 | call SNSMAT 71 | cpl 72 | rrca 73 | rrca 74 | ld c, a 75 | 76 | and #4 77 | ld b, a 78 | ; b has left 79 | 80 | ld a, c 81 | rrca 82 | rrca 83 | ld c, a 84 | 85 | and #0x18 86 | or b 87 | ld b, a 88 | ; added space and right 89 | 90 | ld a, c 91 | rrca 92 | and #3 93 | or b 94 | ; added down and up 95 | 96 | or e 97 | ; added 2nd fire (M) 98 | 99 | ld l, a 100 | ret 101 | -------------------------------------------------------------------------------- /src/ubox/ubox_read_keys.z80: -------------------------------------------------------------------------------- 1 | .globl _ubox_read_keys 2 | 3 | SNSMAT = 0x0141 4 | 5 | _ubox_read_keys:: 6 | ld a, l 7 | call SNSMAT 8 | cpl 9 | ld l, a 10 | ret 11 | -------------------------------------------------------------------------------- /src/ubox/ubox_read_vm.z80: -------------------------------------------------------------------------------- 1 | .globl _ubox_read_vm 2 | 3 | LDIRMV = 0x0059 4 | 5 | _ubox_read_vm:: 6 | ld hl, #2 7 | add hl, sp 8 | 9 | ld e, (hl) 10 | inc hl 11 | ld d, (hl) 12 | inc hl 13 | ld c, (hl) 14 | inc hl 15 | ld b, (hl) 16 | inc hl 17 | ld a, (hl) 18 | inc hl 19 | ld h, (hl) 20 | ld l, a 21 | 22 | jp LDIRMV 23 | 24 | -------------------------------------------------------------------------------- /src/ubox/ubox_reset_tick.z80: -------------------------------------------------------------------------------- 1 | .globl _ubox_reset_tick 2 | .globl _ubox_tick 3 | 4 | _ubox_reset_tick:: 5 | xor a 6 | di 7 | ld (_ubox_tick), a 8 | ei 9 | ret 10 | 11 | -------------------------------------------------------------------------------- /src/ubox/ubox_select_ctl.z80: -------------------------------------------------------------------------------- 1 | .globl _ubox_select_ctl 2 | 3 | GTTRIG = 0x00d8 4 | 5 | _ubox_select_ctl:: 6 | ld b, #3 7 | loop: 8 | ld a, b 9 | dec a 10 | push bc 11 | call GTTRIG 12 | pop bc 13 | or a 14 | jr nz, trigger 15 | djnz loop 16 | 17 | ; 2nd button 18 | 19 | ld b, #4 20 | ld a, b 21 | push bc 22 | call GTTRIG 23 | pop bc 24 | or a 25 | jr nz, trigger_b 26 | 27 | dec b 28 | ld a, b 29 | push bc 30 | call GTTRIG 31 | pop bc 32 | or a 33 | jr nz, trigger_b 34 | 35 | ld l, #0xff 36 | ret 37 | trigger_b: 38 | dec b 39 | trigger: 40 | dec b 41 | ld l, b 42 | ret 43 | -------------------------------------------------------------------------------- /src/ubox/ubox_set_colors.z80: -------------------------------------------------------------------------------- 1 | .globl _ubox_set_colors 2 | 3 | CHGCLR = 0x0062 4 | FORCLR = 0xf3e9 5 | BAKCLR = 0xf3ea 6 | BDRCLR = 0xf3eb 7 | 8 | _ubox_set_colors:: 9 | ld hl, #2 10 | add hl, sp 11 | 12 | ld a, (hl) 13 | inc hl 14 | ld (FORCLR), a 15 | ld a, (hl) 16 | inc hl 17 | ld (BAKCLR), a 18 | ld a, (hl) 19 | inc hl 20 | ld (BDRCLR), a 21 | call CHGCLR 22 | ret 23 | 24 | -------------------------------------------------------------------------------- /src/ubox/ubox_set_mode.z80: -------------------------------------------------------------------------------- 1 | .globl _ubox_set_mode 2 | 3 | CHGMOD = 0x005f 4 | 5 | _ubox_set_mode:: 6 | ld a, l 7 | jp CHGMOD 8 | 9 | -------------------------------------------------------------------------------- /src/ubox/ubox_set_sprite_attr.z80: -------------------------------------------------------------------------------- 1 | .globl _ubox_set_sprite_attr 2 | .globl _ubox_write_vm 3 | 4 | _ubox_set_sprite_attr:: 5 | ld hl, #2 6 | add hl, sp 7 | 8 | ld e, (hl) 9 | inc hl 10 | ld d, (hl) 11 | inc hl 12 | 13 | ld l, (hl) 14 | sla l 15 | sla l 16 | ld h, #0 17 | ld bc, #0x1b00 18 | add hl, bc 19 | 20 | push de 21 | ld bc, #4 22 | push bc 23 | push hl 24 | call _ubox_write_vm 25 | pop af 26 | pop af 27 | pop af 28 | ret 29 | 30 | -------------------------------------------------------------------------------- /src/ubox/ubox_set_sprite_pat16.z80: -------------------------------------------------------------------------------- 1 | .globl _ubox_set_sprite_pat16 2 | .globl _ubox_write_vm 3 | 4 | _ubox_set_sprite_pat16:: 5 | ld hl, #2 6 | add hl, sp 7 | 8 | ld e, (hl) 9 | inc hl 10 | ld d, (hl) 11 | inc hl 12 | 13 | ld l, (hl) 14 | ld h, #0 15 | add hl, hl 16 | add hl, hl 17 | add hl, hl 18 | add hl, hl 19 | add hl, hl 20 | ld bc, #0x3800 21 | add hl, bc 22 | 23 | push de 24 | ld bc, #32 25 | push bc 26 | push hl 27 | call _ubox_write_vm 28 | pop af 29 | pop af 30 | pop af 31 | ret 32 | 33 | -------------------------------------------------------------------------------- /src/ubox/ubox_set_sprite_pat16_flip.z80: -------------------------------------------------------------------------------- 1 | .globl _ubox_set_sprite_pat16_flip 2 | 3 | WRTVRM = 0x004d 4 | 5 | _ubox_set_sprite_pat16_flip:: 6 | ld hl, #2 7 | add hl, sp 8 | 9 | ld e, (hl) 10 | inc hl 11 | ld d, (hl) 12 | inc hl 13 | 14 | ld l, (hl) 15 | ld h, #0 16 | add hl, hl 17 | add hl, hl 18 | add hl, hl 19 | add hl, hl 20 | add hl, hl 21 | ld bc, #0x3800 22 | add hl, bc 23 | 24 | push de 25 | ld bc, #16 26 | ex de, hl 27 | add hl, bc 28 | ex de, hl 29 | call flip 30 | 31 | pop de 32 | call flip 33 | 34 | ret 35 | 36 | flip: 37 | ld b, #16 38 | flip0: 39 | call flip_and_copy 40 | inc hl 41 | inc de 42 | djnz flip0 43 | ret 44 | 45 | flip_and_copy: 46 | ld a, (de) 47 | ld c, a 48 | rlca 49 | rlca 50 | xor c 51 | and #0xaa 52 | xor c 53 | ld c, a 54 | rlca 55 | rlca 56 | rlca 57 | rrc c 58 | xor c 59 | and #0x66 60 | xor c 61 | 62 | jp WRTVRM 63 | 64 | -------------------------------------------------------------------------------- /src/ubox/ubox_set_sprite_pat8.z80: -------------------------------------------------------------------------------- 1 | .globl _ubox_set_sprite_pat8 2 | .globl _ubox_write_vm 3 | 4 | _ubox_set_sprite_pat8:: 5 | ld hl, #2 6 | add hl, sp 7 | 8 | ld e, (hl) 9 | inc hl 10 | ld d, (hl) 11 | inc hl 12 | 13 | ld l, (hl) 14 | ld h, #0 15 | add hl, hl 16 | add hl, hl 17 | add hl, hl 18 | ld bc, #0x3800 19 | add hl, bc 20 | 21 | push de 22 | ld bc, #8 23 | push bc 24 | push hl 25 | call _ubox_write_vm 26 | pop af 27 | pop af 28 | pop af 29 | ret 30 | 31 | -------------------------------------------------------------------------------- /src/ubox/ubox_set_sprite_pat8_flip.z80: -------------------------------------------------------------------------------- 1 | .globl _ubox_set_sprite_pat8_flip 2 | 3 | WRTVRM = 0x004d 4 | 5 | _ubox_set_sprite_pat8_flip:: 6 | ld hl, #2 7 | add hl, sp 8 | 9 | ld e, (hl) 10 | inc hl 11 | ld d, (hl) 12 | inc hl 13 | 14 | ld l, (hl) 15 | ld h, #0 16 | add hl, hl 17 | add hl, hl 18 | add hl, hl 19 | ld bc, #0x3800 20 | add hl, bc 21 | 22 | ld b, #8 23 | flip0: 24 | call flip_and_copy 25 | inc hl 26 | inc de 27 | djnz flip0 28 | ret 29 | 30 | flip_and_copy: 31 | ld a, (de) 32 | ld c, a 33 | rlca 34 | rlca 35 | xor c 36 | and #0xaa 37 | xor c 38 | ld c, a 39 | rlca 40 | rlca 41 | rlca 42 | rrc c 43 | xor c 44 | and #0x66 45 | xor c 46 | 47 | jp WRTVRM 48 | 49 | -------------------------------------------------------------------------------- /src/ubox/ubox_set_tiles.z80: -------------------------------------------------------------------------------- 1 | .globl _ubox_set_tiles 2 | 3 | LDIRVM = 0x005c 4 | 5 | _ubox_set_tiles:: 6 | ld de, #0 7 | ld bc, #256 * 8 8 | push hl 9 | call LDIRVM 10 | pop hl 11 | 12 | ld de, #256 * 8 13 | ld bc, #256 * 8 14 | push hl 15 | call LDIRVM 16 | pop hl 17 | 18 | ld de, #256 * 8 * 2 19 | ld bc, #256 * 8 20 | jp LDIRVM 21 | 22 | -------------------------------------------------------------------------------- /src/ubox/ubox_set_tiles_colors.z80: -------------------------------------------------------------------------------- 1 | .globl _ubox_set_tiles_colors 2 | 3 | LDIRVM = 0x005c 4 | 5 | _ubox_set_tiles_colors:: 6 | ld de, #0x2000 7 | ld bc, #256 * 8 8 | push hl 9 | call LDIRVM 10 | pop hl 11 | 12 | ld de, #0x2000 + 256 * 8 13 | ld bc, #256 * 8 14 | push hl 15 | call LDIRVM 16 | pop hl 17 | 18 | ld de, #0x2000 + 256 * 8 * 2 19 | ld bc, #256 * 8 20 | jp LDIRVM 21 | 22 | -------------------------------------------------------------------------------- /src/ubox/ubox_set_user_isr.z80: -------------------------------------------------------------------------------- 1 | .globl _ubox_set_user_isr 2 | .globl ubox_usr_isr 3 | 4 | _ubox_set_user_isr:: 5 | di 6 | ld (ubox_usr_isr), hl 7 | ei 8 | ret 9 | -------------------------------------------------------------------------------- /src/ubox/ubox_wait.z80: -------------------------------------------------------------------------------- 1 | .globl _ubox_wait 2 | .globl ubox_isr_wait_ticks 3 | .globl ubox_isr_wait_tick 4 | 5 | _ubox_wait:: 6 | ld hl, #ubox_isr_wait_tick 7 | ld a, (ubox_isr_wait_ticks) 8 | ld c, a 9 | 10 | wait_loop: 11 | ld a, (hl) 12 | cp c 13 | jr nc, wait_done 14 | halt 15 | jr wait_loop 16 | 17 | wait_done: 18 | xor a 19 | di 20 | ld (hl), a 21 | ei 22 | ret 23 | 24 | -------------------------------------------------------------------------------- /src/ubox/ubox_wait_for.z80: -------------------------------------------------------------------------------- 1 | .globl _ubox_wait_for 2 | .globl _ubox_wait 3 | .globl ubox_isr_wait_ticks 4 | .globl ubox_isr_wait_tick 5 | 6 | _ubox_wait_for:: 7 | ld b, l 8 | wait_for_loop: 9 | push bc 10 | call _ubox_wait 11 | pop bc 12 | djnz wait_for_loop 13 | ret 14 | 15 | -------------------------------------------------------------------------------- /src/ubox/ubox_write_vm.z80: -------------------------------------------------------------------------------- 1 | .globl _ubox_write_vm 2 | 3 | LDIRVM = 0x005c 4 | 5 | _ubox_write_vm:: 6 | ld hl, #2 7 | add hl, sp 8 | 9 | ld e, (hl) 10 | inc hl 11 | ld d, (hl) 12 | inc hl 13 | ld c, (hl) 14 | inc hl 15 | ld b, (hl) 16 | inc hl 17 | ld a, (hl) 18 | inc hl 19 | ld h, (hl) 20 | ld l, a 21 | 22 | jp LDIRVM 23 | 24 | -------------------------------------------------------------------------------- /src/ubox/ubox_wvdp.z80: -------------------------------------------------------------------------------- 1 | .globl _ubox_wvdp 2 | 3 | WRITEVDP = 0x0047 4 | 5 | _ubox_wvdp:: 6 | ld hl, #2 7 | add hl, sp 8 | 9 | ld c, (hl) 10 | inc hl 11 | ld b, (hl) 12 | call WRITEVDP 13 | ret 14 | 15 | -------------------------------------------------------------------------------- /tools/Makefile: -------------------------------------------------------------------------------- 1 | BIN := ../bin/hex2bin ../bin/rasm ../bin/apultra 2 | 3 | all: $(BIN) 4 | 5 | ../bin/hex2bin: 6 | mkdir -p hex2bin-2.0/bin 7 | make -C hex2bin-2.0 8 | make -C hex2bin-2.0 cleanall 9 | 10 | ../bin/rasm: 11 | make -C rasm 12 | 13 | ../bin/apultra: 14 | make -C apultra 15 | 16 | .PHONY: all clean 17 | clean: 18 | make -C hex2bin-2.0 cleanall 19 | make -C rasm clean 20 | -------------------------------------------------------------------------------- /tools/apultra/.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Object files 5 | *.o 6 | *.ko 7 | *.obj 8 | *.elf 9 | 10 | # Linker output 11 | *.ilk 12 | *.map 13 | *.exp 14 | 15 | # Precompiled Headers 16 | *.gch 17 | *.pch 18 | 19 | # Libraries 20 | *.lib 21 | *.a 22 | *.la 23 | *.lo 24 | 25 | # Shared objects (inc. Windows DLLs) 26 | *.dll 27 | *.so 28 | *.so.* 29 | *.dylib 30 | 31 | # Executables 32 | *.exe 33 | *.out 34 | *.app 35 | *.i*86 36 | *.x86_64 37 | *.hex 38 | 39 | # Debug files 40 | *.dSYM/ 41 | *.su 42 | *.idb 43 | *.pdb 44 | 45 | # Kernel Module Compile Results 46 | *.mod* 47 | *.cmd 48 | .tmp_versions/ 49 | modules.order 50 | Module.symvers 51 | Mkfile.old 52 | dkms.conf 53 | 54 | bin 55 | build 56 | generated 57 | *.lst 58 | *.sym 59 | *.rel 60 | *.bak 61 | VS2017/.vs 62 | VS2017/Debug -------------------------------------------------------------------------------- /tools/apultra/LICENSE: -------------------------------------------------------------------------------- 1 | The apultra code is available under the Zlib license, except for src/matchfinder.c which is placed under the Creative Commons CC0 license. 2 | 3 | Please consult LICENSE.zlib.md and LICENSE.CC0.md for more information. 4 | -------------------------------------------------------------------------------- /tools/apultra/LICENSE.zlib.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2019 Emmanuel Marty 2 | 3 | This software is provided 'as-is', without any express or implied warranty. In 4 | no event will the authors be held liable for any damages arising from the use of 5 | this software. 6 | 7 | Permission is granted to anyone to use this software for any purpose, including 8 | commercial applications, and to alter it and redistribute it freely, subject to 9 | the following restrictions: 10 | 11 | 1. The origin of this software must not be misrepresented; you must not claim 12 | that you wrote the original software. If you use this software in a product, 13 | an acknowledgment in the product documentation would be appreciated but is 14 | not required. 15 | 16 | 2. Altered source versions must be plainly marked as such, and must not be 17 | misrepresented as being the original software. 18 | 19 | 3. This notice may not be removed or altered from any source distribution. 20 | -------------------------------------------------------------------------------- /tools/apultra/Makefile: -------------------------------------------------------------------------------- 1 | #CC=clang 2 | CC=gcc 3 | CFLAGS=-O3 -g -fomit-frame-pointer -Isrc/libdivsufsort/include -Isrc 4 | OBJDIR=obj 5 | LDFLAGS= 6 | 7 | $(OBJDIR)/%.o: src/../%.c 8 | @mkdir -p '$(@D)' 9 | $(CC) $(CFLAGS) -c $< -o $@ 10 | 11 | APP := apultra 12 | 13 | OBJS += $(OBJDIR)/src/apultra.o 14 | OBJS += $(OBJDIR)/src/expand.o 15 | OBJS += $(OBJDIR)/src/matchfinder.o 16 | OBJS += $(OBJDIR)/src/shrink.o 17 | OBJS += $(OBJDIR)/src/libdivsufsort/lib/divsufsort.o 18 | OBJS += $(OBJDIR)/src/libdivsufsort/lib/divsufsort_utils.o 19 | OBJS += $(OBJDIR)/src/libdivsufsort/lib/sssort.o 20 | OBJS += $(OBJDIR)/src/libdivsufsort/lib/trsort.o 21 | 22 | all: $(APP) 23 | 24 | ifeq ($(OS),Windows_NT) 25 | TARGET = apultra.exe 26 | else 27 | TARGET = apultra 28 | endif 29 | 30 | $(APP): $(OBJS) 31 | $(CC) $^ $(LDFLAGS) -o $(APP) 32 | cp $(TARGET) ../../bin 33 | @rm -rf $(TARGET) $(OBJDIR) 34 | 35 | clean: 36 | @rm -rf $(TARGET) $(OBJDIR) 37 | 38 | -------------------------------------------------------------------------------- /tools/apultra/VS2017/apultra.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.489 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "apultra", "apultra.vcxproj", "{3F30FEE8-63C5-4D39-A175-EDD7EA93E9B8}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {3F30FEE8-63C5-4D39-A175-EDD7EA93E9B8}.Debug|x64.ActiveCfg = Debug|x64 17 | {3F30FEE8-63C5-4D39-A175-EDD7EA93E9B8}.Debug|x64.Build.0 = Debug|x64 18 | {3F30FEE8-63C5-4D39-A175-EDD7EA93E9B8}.Debug|x86.ActiveCfg = Debug|Win32 19 | {3F30FEE8-63C5-4D39-A175-EDD7EA93E9B8}.Debug|x86.Build.0 = Debug|Win32 20 | {3F30FEE8-63C5-4D39-A175-EDD7EA93E9B8}.Release|x64.ActiveCfg = Release|x64 21 | {3F30FEE8-63C5-4D39-A175-EDD7EA93E9B8}.Release|x64.Build.0 = Release|x64 22 | {3F30FEE8-63C5-4D39-A175-EDD7EA93E9B8}.Release|x86.ActiveCfg = Release|Win32 23 | {3F30FEE8-63C5-4D39-A175-EDD7EA93E9B8}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {A1E1655C-AA9F-41F0-80C9-18DD0B859D7C} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /tools/apultra/src/apultra.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/tools/apultra/src/apultra.c -------------------------------------------------------------------------------- /tools/apultra/src/expand.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/tools/apultra/src/expand.c -------------------------------------------------------------------------------- /tools/apultra/src/expand.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/tools/apultra/src/expand.h -------------------------------------------------------------------------------- /tools/apultra/src/format.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/tools/apultra/src/format.h -------------------------------------------------------------------------------- /tools/apultra/src/libapultra.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/tools/apultra/src/libapultra.h -------------------------------------------------------------------------------- /tools/apultra/src/libdivsufsort/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # libdivsufsort Change Log 2 | 3 | See full changelog at: https://github.com/y-256/libdivsufsort/commits 4 | 5 | ## [2.0.1] - 2010-11-11 6 | ### Fixed 7 | * Wrong variable used in `divbwt` function 8 | * Enclose some string variables with double quotation marks in include/CMakeLists.txt 9 | * Fix typo in include/CMakeLists.txt 10 | 11 | ## 2.0.0 - 2008-08-23 12 | ### Changed 13 | * Switch the build system to [CMake](http://www.cmake.org/) 14 | * Improve the performance of the suffix-sorting algorithm 15 | 16 | ### Added 17 | * OpenMP support 18 | * 64-bit version of divsufsort 19 | 20 | [Unreleased]: https://github.com/y-256/libdivsufsort/compare/2.0.1...HEAD 21 | [2.0.1]: https://github.com/y-256/libdivsufsort/compare/2.0.0...2.0.1 22 | -------------------------------------------------------------------------------- /tools/apultra/src/libdivsufsort/CMakeModules/CheckFunctionKeywords.cmake: -------------------------------------------------------------------------------- 1 | include(CheckCSourceCompiles) 2 | 3 | macro(check_function_keywords _wordlist) 4 | set(${_result} "") 5 | foreach(flag ${_wordlist}) 6 | string(REGEX REPLACE "[-+/ ()]" "_" flagname "${flag}") 7 | string(TOUPPER "${flagname}" flagname) 8 | set(have_flag "HAVE_${flagname}") 9 | check_c_source_compiles("${flag} void func(); void func() { } int main() { func(); return 0; }" ${have_flag}) 10 | if(${have_flag} AND NOT ${_result}) 11 | set(${_result} "${flag}") 12 | # break() 13 | endif(${have_flag} AND NOT ${_result}) 14 | endforeach(flag) 15 | endmacro(check_function_keywords) 16 | -------------------------------------------------------------------------------- /tools/apultra/src/libdivsufsort/CMakeModules/cmake_uninstall.cmake.in: -------------------------------------------------------------------------------- 1 | IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 2 | MESSAGE(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"") 3 | ENDIF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 4 | 5 | FILE(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) 6 | STRING(REGEX REPLACE "\n" ";" files "${files}") 7 | 8 | SET(NUM 0) 9 | FOREACH(file ${files}) 10 | IF(EXISTS "$ENV{DESTDIR}${file}") 11 | MESSAGE(STATUS "Looking for \"$ENV{DESTDIR}${file}\" - found") 12 | SET(UNINSTALL_CHECK_${NUM} 1) 13 | ELSE(EXISTS "$ENV{DESTDIR}${file}") 14 | MESSAGE(STATUS "Looking for \"$ENV{DESTDIR}${file}\" - not found") 15 | SET(UNINSTALL_CHECK_${NUM} 0) 16 | ENDIF(EXISTS "$ENV{DESTDIR}${file}") 17 | MATH(EXPR NUM "1 + ${NUM}") 18 | ENDFOREACH(file) 19 | 20 | SET(NUM 0) 21 | FOREACH(file ${files}) 22 | IF(${UNINSTALL_CHECK_${NUM}}) 23 | MESSAGE(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") 24 | EXEC_PROGRAM( 25 | "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" 26 | OUTPUT_VARIABLE rm_out 27 | RETURN_VALUE rm_retval 28 | ) 29 | IF(NOT "${rm_retval}" STREQUAL 0) 30 | MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") 31 | ENDIF(NOT "${rm_retval}" STREQUAL 0) 32 | ENDIF(${UNINSTALL_CHECK_${NUM}}) 33 | MATH(EXPR NUM "1 + ${NUM}") 34 | ENDFOREACH(file) 35 | 36 | FILE(REMOVE "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 37 | -------------------------------------------------------------------------------- /tools/apultra/src/libdivsufsort/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2003 Yuta Mori All rights reserved. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /tools/apultra/src/libdivsufsort/VERSION.cmake: -------------------------------------------------------------------------------- 1 | set(PROJECT_VERSION_MAJOR "2") 2 | set(PROJECT_VERSION_MINOR "0") 3 | set(PROJECT_VERSION_PATCH "2") 4 | set(PROJECT_VERSION_EXTRA "-1") 5 | set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}") 6 | set(PROJECT_VERSION_FULL "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}${PROJECT_VERSION_EXTRA}") 7 | 8 | set(LIBRARY_VERSION "3.0.1") 9 | set(LIBRARY_SOVERSION "3") 10 | 11 | ## Git revision number ## 12 | if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git") 13 | execute_process(COMMAND git describe --tags HEAD 14 | WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" 15 | OUTPUT_VARIABLE GIT_DESCRIBE_TAGS ERROR_QUIET) 16 | if(GIT_DESCRIBE_TAGS) 17 | string(REGEX REPLACE "^v(.*)" "\\1" GIT_REVISION "${GIT_DESCRIBE_TAGS}") 18 | string(STRIP "${GIT_REVISION}" GIT_REVISION) 19 | if(GIT_REVISION) 20 | set(PROJECT_VERSION_FULL "${GIT_REVISION}") 21 | endif(GIT_REVISION) 22 | endif(GIT_DESCRIBE_TAGS) 23 | endif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git") 24 | -------------------------------------------------------------------------------- /tools/apultra/src/libdivsufsort/examples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ## Add definitions ## 2 | add_definitions(-D_LARGEFILE_SOURCE -D_LARGE_FILES -D_FILE_OFFSET_BITS=64) 3 | 4 | ## Targets ## 5 | include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../include" 6 | "${CMAKE_CURRENT_BINARY_DIR}/../include") 7 | link_directories("${CMAKE_CURRENT_BINARY_DIR}/../lib") 8 | foreach(src suftest mksary sasearch bwt unbwt) 9 | add_executable(${src} ${src}.c) 10 | target_link_libraries(${src} divsufsort) 11 | endforeach(src) 12 | -------------------------------------------------------------------------------- /tools/apultra/src/libdivsufsort/include/divsufsort_config.h: -------------------------------------------------------------------------------- 1 | #define HAVE_STRING_H 1 2 | #define HAVE_STDLIB_H 1 3 | #define HAVE_MEMORY_H 1 4 | #define HAVE_STDINT_H 1 5 | #define INLINE inline 6 | 7 | #ifdef _MSC_VER 8 | #pragma warning( disable : 4244 ) 9 | #endif /* _MSC_VER */ 10 | -------------------------------------------------------------------------------- /tools/apultra/src/libdivsufsort/lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../include" 2 | "${CMAKE_CURRENT_BINARY_DIR}/../include") 3 | 4 | set(divsufsort_SRCS divsufsort.c sssort.c trsort.c utils.c) 5 | 6 | ## libdivsufsort ## 7 | add_library(divsufsort ${divsufsort_SRCS}) 8 | install(TARGETS divsufsort 9 | RUNTIME DESTINATION ${CMAKE_INSTALL_RUNTIMEDIR} 10 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} 11 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) 12 | set_target_properties(divsufsort PROPERTIES 13 | VERSION "${LIBRARY_VERSION}" 14 | SOVERSION "${LIBRARY_SOVERSION}" 15 | DEFINE_SYMBOL DIVSUFSORT_BUILD_DLL 16 | RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../examples") 17 | 18 | ## libdivsufsort64 ## 19 | if(BUILD_DIVSUFSORT64) 20 | add_library(divsufsort64 ${divsufsort_SRCS}) 21 | install(TARGETS divsufsort64 22 | RUNTIME DESTINATION ${CMAKE_INSTALL_RUNTIMEDIR} 23 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} 24 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) 25 | set_target_properties(divsufsort64 PROPERTIES 26 | VERSION "${LIBRARY_VERSION}" 27 | SOVERSION "${LIBRARY_SOVERSION}" 28 | DEFINE_SYMBOL DIVSUFSORT_BUILD_DLL 29 | COMPILE_FLAGS "-DBUILD_DIVSUFSORT64" 30 | RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../examples") 31 | endif(BUILD_DIVSUFSORT64) 32 | -------------------------------------------------------------------------------- /tools/apultra/src/libdivsufsort/pkgconfig/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ## generate libdivsufsort.pc ## 2 | set(W64BIT "") 3 | configure_file("${CMAKE_CURRENT_SOURCE_DIR}/libdivsufsort.pc.cmake" "${CMAKE_CURRENT_BINARY_DIR}/libdivsufsort.pc" @ONLY) 4 | install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libdivsufsort.pc" DESTINATION ${CMAKE_INSTALL_PKGCONFIGDIR}) 5 | if(BUILD_DIVSUFSORT64) 6 | set(W64BIT "64") 7 | configure_file("${CMAKE_CURRENT_SOURCE_DIR}/libdivsufsort.pc.cmake" "${CMAKE_CURRENT_BINARY_DIR}/libdivsufsort64.pc" @ONLY) 8 | install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libdivsufsort64.pc" DESTINATION ${CMAKE_INSTALL_PKGCONFIGDIR}) 9 | endif(BUILD_DIVSUFSORT64) 10 | -------------------------------------------------------------------------------- /tools/apultra/src/libdivsufsort/pkgconfig/libdivsufsort.pc.cmake: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | exec_prefix=${prefix} 3 | libdir=@CMAKE_INSTALL_LIBDIR@ 4 | includedir=@CMAKE_INSTALL_INCLUDEDIR@ 5 | 6 | Name: @PROJECT_NAME@@W64BIT@ 7 | Description: @PROJECT_DESCRIPTION@ 8 | Version: @PROJECT_VERSION_FULL@ 9 | URL: @PROJECT_URL@ 10 | Libs: -L${libdir} -ldivsufsort@W64BIT@ 11 | Cflags: -I${includedir} 12 | -------------------------------------------------------------------------------- /tools/apultra/src/matchfinder.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/tools/apultra/src/matchfinder.c -------------------------------------------------------------------------------- /tools/apultra/src/matchfinder.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/tools/apultra/src/matchfinder.h -------------------------------------------------------------------------------- /tools/apultra/src/shrink.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/tools/apultra/src/shrink.c -------------------------------------------------------------------------------- /tools/apultra/src/shrink.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/tools/apultra/src/shrink.h -------------------------------------------------------------------------------- /tools/chksize: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | import sys 3 | 4 | TOP_MEM = 0xc000 - 256 # video memory - stack 5 | 6 | def main(): 7 | if len(sys.argv) != 4: 8 | sys.exit("usage: %s code_limit_hex data_limit_hex filename.map" % 9 | sys.argv[0]) 10 | 11 | sizes = {"CODE": 0, "DATA": 0} 12 | 13 | with open(sys.argv[3], "r") as fd: 14 | for line in fd.readlines(): 15 | for seg in sizes.keys(): 16 | if "l__%s" % seg in line: 17 | sizes[seg] = int(line.split()[0], base=16) 18 | 19 | print("\nROM: %(CODE)05d bytes\nRAM: %(DATA)05d bytes\n" % sizes) 20 | 21 | if sizes["CODE"] > int(sys.argv[1], 16): 22 | sys.exit("ROM is over the limit") 23 | if sizes["DATA"] > int(sys.argv[2], 16): 24 | sys.exit("RAM is over the limit") 25 | 26 | 27 | if __name__ == "__main__": 28 | main() 29 | -------------------------------------------------------------------------------- /tools/hex2bin-2.0/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile hex2bin/mot2bin 2 | SRCDIR = src 3 | BINDIR = bin 4 | OBJDIR = obj 5 | TGTDIR = $(BINDIR) 6 | B_SRCFILES= $(foreach F, hex2bin.c common.c libcrc.c binary.c, $(SRCDIR)/$(F)) 7 | B_OBJFILES= $(foreach F, hex2bin.o common.o libcrc.o binary.o, $(OBJDIR)/$(F)) 8 | M_SRCFILES= $(foreach F, mot2bin.c common.c libcrc.c binary.c, $(SRCDIR)/$(F)) 9 | M_OBJFILES= $(foreach F, mot2bin.o common.o libcrc.o binary.o, $(OBJDIR)/$(F)) 10 | 11 | # For generating documentation (hex2bin.1, select the second line) 12 | # -- You will require pod2man installed for this to work 13 | TGT_FILES = $(foreach F, hex2bin mot2bin, $(TGTDIR)/$(F)) 14 | #TGT_FILES = $(foreach F, hex2bin mot2bin hex2bin.1, $(TGTDIR)/$(F)) 15 | 16 | CPFLAGS = -std=gnu99 -O3 -fsigned-char -Wall -pedantic -fcommon 17 | # Compile 18 | all: objectdir $(TGT_FILES) 19 | 20 | ifeq ($(OS),Windows_NT) 21 | TARGET = hex2bin.exe 22 | else 23 | TARGET = hex2bin 24 | endif 25 | 26 | $(OBJDIR)/%.o: $(SRCDIR)/%.c 27 | gcc -c $(CPFLAGS) $< -o $@ 28 | 29 | objectdir: 30 | @echo "Creating directory $(OBJDIR)..." 31 | mkdir -p $(OBJDIR) 32 | 33 | $(TGTDIR)/hex2bin.1: $(SRCDIR)/hex2bin.pod 34 | pod2man $(SRCDIR)/hex2bin.pod > $(TGTDIR)/hex2bin.1 35 | 36 | $(TGTDIR)/hex2bin: $(B_OBJFILES) 37 | gcc $(CPFLAGS) -o $(TGTDIR)/hex2bin $(B_OBJFILES) 38 | cp bin/$(TARGET) ../../bin 39 | 40 | $(TGTDIR)/mot2bin: $(M_OBJFILES) 41 | gcc $(CPFLAGS) -o $(TGTDIR)/mot2bin $(M_OBJFILES) 42 | 43 | clean: 44 | @echo "Removing objects directory $(OBJDIR)/ ..." 45 | @rm -rf $(OBJDIR) 46 | 47 | cleanall: clean 48 | @echo "Removing binary files in $(BINDIR)/ ..." 49 | @rm -f $(BINDIR)/* 50 | -------------------------------------------------------------------------------- /tools/hex2bin-2.0/doc/formats.txt: -------------------------------------------------------------------------------- 1 | Hex formats 2 | 3 | Intel 4 | ===== 5 | 6 | Hexadecimal values are always in uppercase. Each line is a record. 7 | The sum of all the bytes in each record should be 00 (modulo 256). 8 | 9 | Record types: 10 | 11 | 00: data records 12 | 01: end-of-file record 13 | 02: extended address record 14 | 15 | Data record 16 | ----------- 17 | 18 | :0D011C0000000000C3E0FF0000000000C30F 19 | 20 | : 0D 011C 00 00000000C3E0FF0000000000C3 0F 21 | | | | | -------------+------------ | 22 | | | | | | +--- Checksum 23 | | | | | +------------------ Data bytes 24 | | | | +--------------------------------- Record type 25 | | | +------------------------------------- Address 26 | | +----------------------------------------- Number of data bytes 27 | +-------------------------------------------- Start of record 28 | 29 | 30 | End of file record 31 | ------------------ 32 | 33 | :00000001FE 34 | 35 | : 00 0000 01 FE 36 | | | | | | 37 | | | | | +--- Checksum 38 | | | | +------ Record type 39 | | | +---------- Address 40 | | +-------------- Number of data bytes 41 | +----------------- Start of record 42 | 43 | 44 | 45 | Extended address record 46 | ----------------------- 47 | 48 | :02010002E0001B 49 | 50 | : 02 0100 02 E000 1B 51 | | | | | | | 52 | | | | | | +--- Checksum 53 | | | | | +-------- Segment address 54 | | | | +----------- Record type 55 | | | +--------------- Address 56 | | +------------------- Number of data bytes 57 | +---------------------- Start of record 58 | 59 | Following data records will start at E000:0100 or E0100 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /tools/hex2bin-2.0/src/binary.h: -------------------------------------------------------------------------------- 1 | #ifndef _BINARY_H_ 2 | #define _BINARY_H_ 3 | 4 | typedef enum {false, true} bool; 5 | 6 | extern const unsigned char Reflect8[256]; 7 | 8 | uint16_t Reflect16(uint16_t Value16); 9 | uint32_t Reflect24(uint32_t Value24); 10 | uint32_t Reflect32(uint32_t Value32); 11 | uint64_t Reflect40(uint64_t Value40); 12 | uint64_t Reflect64(uint64_t Value64); 13 | 14 | uint8_t u16_hi(uint16_t value); 15 | uint8_t u16_lo(uint16_t value); 16 | 17 | uint8_t u32_b3(uint32_t value); 18 | uint8_t u32_b2(uint32_t value); 19 | uint8_t u32_b1(uint32_t value); 20 | uint8_t u32_b0(uint32_t value); 21 | 22 | uint8_t u64_b7(uint64_t value); 23 | uint8_t u64_b6(uint64_t value); 24 | uint8_t u64_b5(uint64_t value); 25 | uint8_t u64_b4(uint64_t value); 26 | uint8_t u64_b3(uint64_t value); 27 | uint8_t u64_b2(uint64_t value); 28 | uint8_t u64_b1(uint64_t value); 29 | uint8_t u64_b0(uint64_t value); 30 | 31 | uint8_t nibble2ascii(uint8_t value); 32 | bool cs_isdecdigit(char c); 33 | unsigned char tohex(unsigned char c); 34 | unsigned char todecimal(unsigned char c); 35 | 36 | #endif /* _BINARY_H_ */ 37 | -------------------------------------------------------------------------------- /tools/pandocfilter-pygments.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | """ 3 | From: https://github.com/DoomHammer/pandocfilter-pygments 4 | 5 | Requires: 6 | 7 | - pygments 8 | - pandocfilters 9 | """ 10 | 11 | from pandocfilters import toJSONFilter, RawBlock 12 | from pygments import highlight 13 | from pygments.lexers import (get_lexer_by_name, guess_lexer, TextLexer) 14 | from pygments.formatters import get_formatter_by_name 15 | 16 | def pygmentize(key, value, format, meta): 17 | if key == 'CodeBlock': 18 | [[ident, classes, keyvals], code] = value 19 | lexer = None 20 | for klass in classes: 21 | try: 22 | lexer = get_lexer_by_name(klass) 23 | break 24 | except: 25 | pass 26 | if lexer is None: 27 | try: 28 | lexer = guess_lexer(code) 29 | except: 30 | lexer = TextLexer() 31 | if format == "html5": 32 | format = "html" 33 | return [RawBlock(format, highlight(code, lexer, get_formatter_by_name(format)))] 34 | 35 | if __name__ == "__main__": 36 | toJSONFilter(pygmentize) 37 | 38 | -------------------------------------------------------------------------------- /tools/rasm/Makefile: -------------------------------------------------------------------------------- 1 | all: rasm 2 | 3 | CC := gcc 4 | LDFLAGS := -lm 5 | 6 | ifeq ($(OS),Windows_NT) 7 | TARGET := rasm.exe 8 | else 9 | TARGET := rasm 10 | endif 11 | 12 | rasm: rasm_v0120.c 13 | $(CC) $< -s -O2 $(LDFLAGS) -o $@ 14 | cp $(TARGET) ../../bin 15 | rm -f $(TARGET) 16 | 17 | clean: 18 | rm -f $(TARGET) 19 | 20 | .PHONY: all clean 21 | 22 | -------------------------------------------------------------------------------- /tools/rasm/decrunch/lz48decrunch_v006.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; LZ48 decrunch 3 | ; 4 | ; hl compressed data adress 5 | ; de output adress of data 6 | ; 7 | 8 | 9 | org #8000 10 | 11 | ; CALL #8000,source,destination 12 | di 13 | 14 | ; parameters 15 | ld h,(ix+3) 16 | ld l,(ix+2) 17 | ld d,(ix+1) 18 | ld e,(ix+0) 19 | 20 | call LZ48_decrunch 21 | 22 | ei 23 | ret 24 | 25 | 26 | 27 | 28 | 29 | LZ48_decrunch 30 | ldi 31 | ld b,0 32 | 33 | nextsequence 34 | ld a,(hl) 35 | inc hl 36 | ld lx,a 37 | and #F0 38 | jr z,lzunpack ; no litteral bytes 39 | rrca 40 | rrca 41 | rrca 42 | rrca 43 | 44 | ld c,a 45 | cp 15 ; more bytes for length? 46 | jr nz,copyliteral 47 | 48 | getadditionallength 49 | ld a,(hl) 50 | inc hl 51 | inc a 52 | jr nz,lengthnext 53 | inc b 54 | dec bc 55 | jr getadditionallength 56 | lengthnext 57 | dec a 58 | add a,c 59 | ld c,a 60 | ld a,b 61 | adc a,0 62 | ld b,a ; bc=length 63 | 64 | copyliteral 65 | ldir 66 | 67 | lzunpack 68 | ld a,lx 69 | and #F 70 | add 3 71 | ld c,a 72 | cp 18 ; more bytes for length? 73 | jr nz,readoffset 74 | 75 | getadditionallengthbis 76 | ld a,(hl) 77 | inc hl 78 | inc a 79 | jr nz,lengthnextbis 80 | inc b 81 | dec bc 82 | jr getadditionallengthbis 83 | lengthnextbis 84 | dec a 85 | add a,c 86 | ld c,a 87 | ld a,b 88 | adc a,0 89 | ld b,a ; bc=length 90 | 91 | readoffset 92 | ; read encoded offset 93 | ld a,(hl) 94 | inc a 95 | ret z ; LZ48 end with zero offset 96 | inc hl 97 | push hl 98 | ld l,a 99 | ld a,e 100 | sub l 101 | ld l,a 102 | ld a,d 103 | sbc a,0 104 | ld h,a 105 | ; source=dest-copyoffset 106 | 107 | copykey 108 | ldir 109 | 110 | pop hl 111 | jr nextsequence 112 | 113 | 114 | -------------------------------------------------------------------------------- /tools/rasm/rasm.h: -------------------------------------------------------------------------------- 1 | 2 | struct s_debug_error { 3 | char *filename; 4 | int line; 5 | char *msg; 6 | int lenmsg,lenfilename; 7 | }; 8 | struct s_debug_symbol { 9 | char *name; 10 | int v; 11 | }; 12 | struct s_rasm_info { 13 | struct s_debug_error *error; 14 | int nberror,maxerror; 15 | struct s_debug_symbol *symbol; 16 | int nbsymbol,maxsymbol; 17 | }; 18 | 19 | 20 | //extern "C" { 21 | int RasmAssemble(const char *datain, int lenin, unsigned char **dataout, int *lenout); 22 | int RasmAssembleInfo(const char *datain, int lenin, unsigned char **dataout, int *lenout, struct s_rasm_info **debug); 23 | void RasmFreeInfoStruct(struct s_rasm_info *debug); 24 | //}; 25 | 26 | 27 | -------------------------------------------------------------------------------- /tools/rasm/rasm_v0120.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdpdds/ubox_example/8aa539cb730bed3bdfaa1bb5fd674208cfa65e21/tools/rasm/rasm_v0120.c -------------------------------------------------------------------------------- /tools/tilesconverter/.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Object files 5 | *.o 6 | *.ko 7 | *.obj 8 | *.elf 9 | 10 | # Linker output 11 | *.ilk 12 | *.map 13 | *.exp 14 | 15 | # Precompiled Headers 16 | *.gch 17 | *.pch 18 | 19 | # Libraries 20 | *.lib 21 | *.a 22 | *.la 23 | *.lo 24 | 25 | # Shared objects (inc. Windows DLLs) 26 | *.dll 27 | *.so 28 | *.so.* 29 | *.dylib 30 | 31 | # Executables 32 | *.exe 33 | *.out 34 | *.app 35 | *.i*86 36 | *.x86_64 37 | *.hex 38 | 39 | # Debug files 40 | *.dSYM/ 41 | *.su 42 | *.idb 43 | *.pdb 44 | 45 | # Kernel Module Compile Results 46 | *.mod* 47 | *.cmd 48 | .tmp_versions/ 49 | modules.order 50 | Module.symvers 51 | Mkfile.old 52 | dkms.conf 53 | 54 | bin 55 | build 56 | generated 57 | *.lst 58 | *.sym 59 | *.rel 60 | *.bak 61 | .vs 62 | Debug 63 | Release -------------------------------------------------------------------------------- /tools/tilesconverter/tilesconverter.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.31911.196 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tilesconverter", "tilesconverter.vcxproj", "{5D770089-76BA-4E5C-96BD-810D7BDFADBD}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {5D770089-76BA-4E5C-96BD-810D7BDFADBD}.Debug|x64.ActiveCfg = Debug|x64 17 | {5D770089-76BA-4E5C-96BD-810D7BDFADBD}.Debug|x64.Build.0 = Debug|x64 18 | {5D770089-76BA-4E5C-96BD-810D7BDFADBD}.Debug|x86.ActiveCfg = Debug|Win32 19 | {5D770089-76BA-4E5C-96BD-810D7BDFADBD}.Debug|x86.Build.0 = Debug|Win32 20 | {5D770089-76BA-4E5C-96BD-810D7BDFADBD}.Release|x64.ActiveCfg = Release|x64 21 | {5D770089-76BA-4E5C-96BD-810D7BDFADBD}.Release|x64.Build.0 = Release|x64 22 | {5D770089-76BA-4E5C-96BD-810D7BDFADBD}.Release|x86.ActiveCfg = Release|Win32 23 | {5D770089-76BA-4E5C-96BD-810D7BDFADBD}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {F3B03846-73DB-4370-90C8-318F0C427CA4} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /tools/tilesconverter/tilesconverter.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 소스 파일 20 | 21 | 22 | 소스 파일 23 | 24 | 25 | 26 | 27 | 소스 파일 28 | 29 | 30 | 소스 파일 31 | 32 | 33 | 소스 파일 34 | 35 | 36 | -------------------------------------------------------------------------------- /tools/tilesconverter/tilesconverter.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | test.png 5 | ./debug 6 | WindowsLocalDebugger 7 | 8 | 9 | test.png 10 | WindowsLocalDebugger 11 | $(ProjectDir) 12 | 13 | --------------------------------------------------------------------------------