diff --git a/beebtrk2.6502 b/beebtrk2.6502 new file mode 100644 index 0000000..26d0d86 --- /dev/null +++ b/beebtrk2.6502 @@ -0,0 +1,426 @@ +\ ****************************************************************** +\ * Beeb Tracker +\ * Volume 2 - Ninja Gaiden Edition +\ * Music player & visualiser in MODE 7 +\ * Kieran Connell & Simon Morris +\ * A Bitshifters Production +\ ****************************************************************** + +\\ Common global defines +INCLUDE "lib/bbc.h.6502" + +\ ****************************************************************** +\ * Define compilation flags +\ ****************************************************************** + +CODE_ORIGIN = &1100 ; assuming standard BBC Micro DFS this is safe! +_DEBUG = FALSE ; include extra stuff for debugging + +COMPILE_OPTION_EXIT = FALSE ; enable "Exit" in selection menu + + + +\ ****************************************************************** +\ * Define global constants +\ ****************************************************************** + + + + +\ ****************************************************************** +\ * Define app constants +\ ****************************************************************** + +\\ Number of entries in our file table +NUM_vgm_files = 17 + + +\ ****************************************************************** +\ * Define fast (zero page) runtime variables +\ ****************************************************************** + +\\ Our own app variables +ORG &00 +GUARD &9F ; user ZP + econet ZP + + +\\ Any includes here can declare ZP vars from the pool using SKIP +INCLUDE "lib/exomiser.h.6502" +INCLUDE "lib/vgmplayer.h.6502" +INCLUDE "lib/beebtracker.h.6502" + + + +\ ****************************************************************** +\ * Start address to be saved +\ ****************************************************************** + +LARGEST_VGM_SIZE = 20560 + +ORG CODE_ORIGIN ; code origin - assume standard BBC Micro +GUARD MODE7_base_addr-LARGEST_VGM_SIZE ; ensure code size plus size of largest VGM file doesn't hit start of screen memory + +.start + + +\ ****************************************************************** +\ * Code entry +\ ****************************************************************** + +INCLUDE "lib/exomiser.s.6502" +INCLUDE "lib/vgmplayer.s.6502" +INCLUDE "lib/beebtracker.s.6502" + +\ ****************************************************************** +\ * Main loop including high-level state machine +\ ****************************************************************** + +.main +{ +\\ ***** System initialise ***** \\ + + \\ *FX 200,3 - clear memory on break as we use OS memory areas and can cause nasty effects + LDA #200 + LDX #3 + JSR osbyte + + JSR clear_vram + + \\ Set MODE 1 + LDA #22: JSR oswrch + LDA #1: JSR oswrch + + \\ Turn off cursor by directly poking crtc + SEI + LDA #10: STA &FE00 + LDA #32: STA &FE01 + CLI + + + \\ Present intro screen + JSR show_title + + + + \\ Set MODE 7 + LDA #22: JSR oswrch + LDA #7: JSR oswrch + + \\ Turn off cursor by directly poking crtc + SEI + LDA #10: STA &FE00 + LDA #32: STA &FE01 + CLI + + \\ Present intro screen + JSR show_intro + + \\ Run the tracker demo + JSR tracker_main + +\\ ***** Exit app entirely ***** \\ + + \\ Credits / Outro screen goes here \\ + + \\ Exit cleanly - tidy up anything else here! + LDA #12: JSR oswrch + + \\ Would be nice to clear escape state and issue BASIC NEW to avoid "Bad Program" error + + .return + RTS +} + +\\ *** Show loading screen *** +.show_intro +{ + \\ Initialize compressed data stream + \\ the title screen is an included binary at the VGM_stream_data memory address + \\ (later overwritten by loaded VGMs) + LDX #LO(VGM_stream_data) + LDY #HI(VGM_stream_data) + JSR exo_init_decruncher + + \\ unpack to screen + LDX #&00 + LDY #&7c + JSR exo_unpack + + + \\ wait for keypress + JSR &FFE0 + RTS +} + +TITLE_LOAD_ADDRESS = &8000 - 8946 ; length of compressed title screen +.show_title +{ +\\ conceal vram while we load & unpack + SEI + LDA #1: STA &FE00 + LDA #0: STA &FE01 + CLI + + \\ Set osfile param block + LDA #LO(title_data_filename) + STA osfile_params + 0 + LDA #HI(title_data_filename) + STA osfile_params + 1 + + LDA #LO(TITLE_LOAD_ADDRESS) + STA osfile_params + 2 + LDA #HI(TITLE_LOAD_ADDRESS) + STA osfile_params + 3 + + LDA #0 + STA osfile_params + 6 + + \\ Issue osfile call + LDX #LO(osfile_params) + LDY #HI(osfile_params) + LDA #&FF + JSR osfile + + + \\ Initialize compressed data stream + LDX #LO(TITLE_LOAD_ADDRESS) + LDY #HI(TITLE_LOAD_ADDRESS) + JSR exo_init_decruncher + + \\ unpack to screen + LDX #&00 + LDY #&30 + JSR exo_unpack + +\\ reveal vram at vsync + LDA #19 + LDX #0 + JSR osbyte + + SEI + LDA #1: STA &FE00 + LDA #80: STA &FE01 + CLI + + \\ wait for keypress + JSR &FFE0 + RTS +} + +\\ reset all memory from &3000 to &8000 to zero +\\ hides unsightly mode switches +.clear_vram +{ + sei + lda #&30 + sta loop2+2 + lda #0 + ldy #&50 +.loop + ldx #0 +.loop2 + sta &3000,x + inx + bne loop2 + inc loop2+2 + dey + bne loop + cli + rts +} + + +.code_end + + +\ ****************************************************************** +\ * Stored data +\ ****************************************************************** + +.data_start + + +.menu_data_filename EQUS "BeebDat", 13 +.title_data_filename EQUS "Title", 13 + +\\ Need to put this macro last as I don't know how to undo the character map! +\\ +SET_TELETEXT_FONT_CHAR_MAP + +\\ Scrolltext messages stored as font glyph byte offsets +.scrolltext_start + +.demo_message +EQUS " Welcome to the Bitshifters Ninja Gaiden BeebTracker Demo... 17 awesome VGM chiptune music files ported from Sega Master System to your BBC Micro " +EQUB 0 + +.load_message +EQUS "Loading... ", 0 + +\\ ** ANY EQUS LINES AFTER THIS POINT WILL STILL CONTAIN REMAPPED CHARACTERS ** \\ + +.scrolltext_end + +\\ Clear character mappings +RESET_MAPCHAR + + + + +\ ****************************************************************** +\ * EXO VGM data file +\ * This must be compressed using the following flags: +\ * exomizer.exe raw -c -m 1024 -o +\ ****************************************************************** + +.VGM_stream_data + +INCBIN "data/loader_volume2.bin.exo" + + + +\ ****************************************************************** +\ * End address to be saved +\ ****************************************************************** + +.end + +ORG &0900 +GUARD &0CFF + +.menu_data_start + +\\ No longer require loading_table but each entry must be exactly 4 bytes +\\ Does not have to be aligned but entries have to be fixed size +\\ This isn't actually any smaller than using pointer tables but fewer things to type I suppose :) +\\ V.B is an invalid filename for some reason with BeebASM + +.vgm_filenames +EQUS "V.0", 13 +EQUS "V.1", 13 +EQUS "V.2", 13 +EQUS "V.3", 13 +EQUS "V.4", 13 +EQUS "V.5", 13 +EQUS "V.6", 13 +EQUS "V.7", 13 +EQUS "V.8", 13 +EQUS "V.9", 13 +EQUS "V.A", 13 +EQUS "V.C", 13 +EQUS "V.D", 13 +EQUS "V.E", 13 +EQUS "V.F", 13 +EQUS "V.G", 13 +EQUS "V.H", 13 + + + + + +\\ No longer require pointer table but each entry must be exactly 32 bytes +\\ Does not have to be aligned but entries have to be fixed size +\\ Code to multiple by 32 probably takes up as much space as the previous pointer tables! + +.menu_entries +EQUS " 1. Intro " +EQUS " 2. Title Screen " +EQUS " 3. Story " +EQUS " 4. Level Start " +EQUS " 5. Escape In a Forest " +EQUS " 6. Boss " +EQUS " 7. Pursuit In Tokyo " +EQUS " 8. Samurai in Tsutenkaku " +EQUS " 9. Rescue Geisha " +EQUS "10. The Land of Enemy " +EQUS "11. Raid " +EQUS "12. Overcome " +EQUS "13. A Decisive Battle " +EQUS "14. End Credits " +EQUS "15. Death " +EQUS "16. Continue " +EQUS "17. Game Over " + + +IF COMPILE_OPTION_EXIT +EQUS "Exit " +ENDIF +.menu_entries_end + + + +.menu_data_end + + + +\ ****************************************************************** +\ * Print out code & data metrics +\ ****************************************************************** + +D_MENU_SIZE = menu_data_end-menu_data_start +D_LOOKUP_SIZE = lookup_tables_end-lookup_tables_start +D_NOTES_SIZE = note_tables_end-note_tables_start +D_SCROLLTEXT_SIZE = scrolltext_end-scrolltext_start +D_SCREENS_SIZE = mode7_data_end-mode7_data_start +D_EXO_CODE_SIZE = exo_end-exo_start +D_VGM_PLAYER_CODE_SIZE = vgm_player_end-vgm_player_start +D_MENU_ENTRIES_SIZE = menu_entries_end-menu_entries + +PRINT "------------------------------------------------------------" +PRINT "Code origin = ", ~CODE_ORIGIN + +PRINT "Code size =", end-start-D_MENU_SIZE-D_LOOKUP_SIZE-D_NOTES_SIZE-D_SCROLLTEXT_SIZE-D_SCREENS_SIZE +PRINT " menu data size =",D_MENU_SIZE +PRINT " menu entries size =",D_MENU_ENTRIES_SIZE +PRINT " lookup tables size =",D_LOOKUP_SIZE +PRINT " note tables size =",D_NOTES_SIZE +PRINT " scrolltext size =",D_SCROLLTEXT_SIZE +PRINT " MODE 7 screen size =", D_SCREENS_SIZE +PRINT " VGM Player code size = ", D_VGM_PLAYER_CODE_SIZE +PRINT " EXO code size = ", D_EXO_CODE_SIZE +PRINT "Run-time vars (above origin) =", VGM_stream_data-end +PRINT "------------------------------------------------------------" +PRINT "Total size (disk) =", end-start +PRINT "Total size (code + data + vars above origin) =", VGM_stream_data-start +PRINT "Available memory (above origin) =", &7C00 - CODE_ORIGIN +PRINT "Max song size =", &7C00 - VGM_stream_data +PRINT "------------------------------------------------------------" + + +\ ****************************************************************** +\ * Save the code +\ ****************************************************************** + + +SAVE "!Boot", start, end, main +SAVE "BeebDat", menu_data_start, menu_data_end + +PUTFILE "vgm_ng/Ninja Gaiden - 01 - Intro.raw.exo", "V.0", 0 +PUTFILE "vgm_ng/Ninja Gaiden - 02 - Title Screen.raw.exo", "V.1", 0 +PUTFILE "vgm_ng/Ninja Gaiden - 03 - Story.raw.exo", "V.2", 0 +PUTFILE "vgm_ng/Ninja Gaiden - 04 - Level Start.raw.exo", "V.3", 0 +PUTFILE "vgm_ng/Ninja Gaiden - 05 - Escape in a Forest.raw.exo", "V.4", 0 +PUTFILE "vgm_ng/Ninja Gaiden - 06 - Boss.raw.exo", "V.5", 0 +PUTFILE "vgm_ng/Ninja Gaiden - 07 - Pursuit in Tokyo.raw.exo", "V.6", 0 +PUTFILE "vgm_ng/Ninja Gaiden - 08 - Samurai in Tsutenkaku.raw.exo", "V.7", 0 +PUTFILE "vgm_ng/Ninja Gaiden - 09 - Rescue Geisha.raw.exo", "V.8", 0 +PUTFILE "vgm_ng/Ninja Gaiden - 10 - The Land of Enemy.raw.exo", "V.9", 0 +PUTFILE "vgm_ng/Ninja Gaiden - 11 - Raid.raw.exo", "V.A", 0 +PUTFILE "vgm_ng/Ninja Gaiden - 12 - Overcome.raw.exo", "V.C", 0 +PUTFILE "vgm_ng/Ninja Gaiden - 13 - A Decisive Battle.raw.exo", "V.D", 0 +PUTFILE "vgm_ng/Ninja Gaiden - 14 - End Credits.raw.exo", "V.E", 0 +PUTFILE "vgm_ng/Ninja Gaiden - 15 - Death.raw.exo", "V.F", 0 +PUTFILE "vgm_ng/Ninja Gaiden - 16 - Continue.raw.exo", "V.G", 0 +PUTFILE "vgm_ng/Ninja Gaiden - 17 - Game Over.raw.exo", "V.H", 0 + +PUTFILE "data/ninja_gaiden.bin.exo", "Title", 0 + + + + +IF _DEBUG ; only needed for debug purposes +PUTFILE "data/screen3.mode7", "screen", &7C00 +PUTFILE "data/font_5x5.mode7", "font", &7C00 +PUTFILE "data/font_5x5_shifted.mode7", "font2", &7C00 +PUTFILE "data/menu_overlay.mode7", "menu", &7C00 +ENDIF \ No newline at end of file diff --git a/beebtrk2.ssd b/beebtrk2.ssd new file mode 100644 index 0000000..9ef7a9e Binary files /dev/null and b/beebtrk2.ssd differ diff --git a/data/loader_volume2.bin b/data/loader_volume2.bin new file mode 100644 index 0000000..1f27911 --- /dev/null +++ b/data/loader_volume2.bin @@ -0,0 +1 @@ +—šžssss“ssss–ssss’ssss•ssss‘ssss”ssss1 —šž —šž j0b(=`