diff --git a/temp/beebtrk.6502 b/temp/beebtrk.6502 deleted file mode 100644 index 6f0c7ba..0000000 --- a/temp/beebtrk.6502 +++ /dev/null @@ -1,385 +0,0 @@ -\ ****************************************************************** -\ * Beeb Tracker -\ * Music player & visualiser in MODE 7 -\ * Kieran Connell & Simon Morris -\ * Demo team name TBD! :) -\ ****************************************************************** - -\\ 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 = 27 - - -\ ****************************************************************** -\ * 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 = 20837 - -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 - - \\ 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 - - - - - 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 -} - - - -.code_end - - -\ ****************************************************************** -\ * Stored data -\ ****************************************************************** - -.data_start -<<<<<<< HEAD - - -.menu_data_filename EQUS "BeebDat", 13 -.loadscreen_data_filename EQUS "LSCREEN", 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 Battle of the Bits BeebTracker Demo... Showcasing 27 awesome VGM chiptune music files that have been converted from other platforms to work on your 4Mhz BBC Micro and replayed on your SN76489 programmable sound chip! " ;You've never heard chip tunes like this before! This production was brought to you by Kieran and Scrubbly ", 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 -\\ Now loaded at run-time so don't know end of data! -INCBIN "data/loader_volume1.bin.exo" - - -\ ****************************************************************** -\ * End address to be saved -\ ****************************************************************** - -.end - -ORG &0900 -GUARD &0CFF - -======= ->>>>>>> origin/master -.menu_data_start - -\\ No longer require loading_table but each entry must be exactly 8 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 :) - -.vgm_filenames -EQUS "V.A", 13,0,0,0,0 -EQUS "V.BB", 13,0,0,0 -EQUS "V.C", 13,0,0,0,0 -EQUS "V.D", 13,0,0,0,0 -EQUS "V.E", 13,0,0,0,0 -EQUS "V.F", 13,0,0,0,0 -EQUS "V.G", 13,0,0,0,0 -EQUS "V.H", 13,0,0,0,0 -EQUS "V.I", 13,0,0,0,0 -EQUS "V.J", 13,0,0,0,0 -EQUS "V.K", 13,0,0,0,0 -EQUS "V.L", 13,0,0,0,0 -EQUS "V.M", 13,0,0,0,0 -EQUS "V.N", 13,0,0,0,0 -EQUS "V.O", 13,0,0,0,0 -EQUS "V.P", 13,0,0,0,0 -EQUS "V.Q", 13,0,0,0,0 -EQUS "V.R", 13,0,0,0,0 -EQUS "V.S", 13,0,0,0,0 -EQUS "V.T", 13,0,0,0,0 -EQUS "V.U", 13,0,0,0,0 -EQUS "V.V", 13,0,0,0,0 -EQUS "V.W", 13,0,0,0,0 -EQUS "V.X", 13,0,0,0,0 -EQUS "V.Y", 13,0,0,0,0 -EQUS "V.Z", 13,0,0,0,0 -EQUS "V.ZZ", 13,0,0,0 - - - - -\\ 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. Master Tracker " -EQUS " 2. Exception " -EQUS " 3. Fluid Dynamics " -EQUS " 4. Bonus Zone " -EQUS " 5. MisSioN 76489 " -EQUS " 6. LOL I am late Sorry " -EQUS " 7. Sonic Enters a Dance Club " -EQUS " 8. I Can Haz D00ty " -EQUS " 9. Infiltration Mission " -EQUS "10. Overcast " -EQUS "11. iNTeNSiTY " -EQUS "12. Kill Chipsters on Sight! " -EQUS "13. Nintendo Entertainment Samba" -EQUS "14. Happy Fun Times " -EQUS "15. Pinky Plinky Thingy " -EQUS "16. Reg " -EQUS "17. Masks Revenge " -EQUS "18. Gost Haus " -EQUS "19. Adrenaline Lift " -EQUS "20. The Long Goodbye " -EQUS "21. Chilled Out Princess " -EQUS "22. The Circus Is In Town " -EQUS "23. Frozen Dancehall o/t Pharoah" -EQUS "24. PSG Strut " -EQUS "25. My Mission " -EQUS "26. My New Used Car " -EQUS "27. Run Under Fire " - -IF COMPILE_OPTION_EXIT -EQUS "Exit " -ENDIF - - - - -.menu_data_end - - -\ ****************************************************************** -\ * End address to be saved -\ ****************************************************************** - -.end - - - -\ ****************************************************************** -\ * EXO VGM data file -\ * This must be compressed using the following flags: -\ * exomizer.exe raw -c -m 1024 -o -\ ****************************************************************** - -.VGM_stream_data -\\ Now loaded at run-time so don't know end of data! -.VGM_end_of_data - - -\ ****************************************************************** -\ * 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 - - -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 " 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 -\ ****************************************************************** - -<<<<<<< HEAD - -SAVE "!Boot", start, end, main -SAVE "BeebDat", menu_data_start, menu_data_end - -PUTFILE "vgm_botb/BotB 7832 MasterTracker.raw.exo", "V.0", 0 -PUTFILE "vgm_botb/BotB 7383 exception.raw.exo", "V.1", 0 ; V.B fails for some wierd reason? -PUTFILE "vgm_botb/BotB 16433 Slimeball - Fluid Dynamics.raw.exo", "V.2", 0 -PUTFILE "vgm_botb/BonusZone.raw.exo", "V.3", 0 -PUTFILE "vgm_botb/MISSION76496.raw.exo", "V.4", 0 -PUTFILE "vgm_botb/BotB 7639 lol i am late sorry.raw.exo", "V.5", 0 -PUTFILE "vgm_botb/BotB 4406 sonic_enters_a_dance_club.raw.exo", "V.6", 0 -PUTFILE "vgm_botb/BotB 1643 flashbob - I can haz d00ty caiclz plz.raw.exo", "V.7", 0 -PUTFILE "vgm_botb/BotB 1819 Kulor - Snofer Apostrophy S Infiltration Mission.raw.exo", "V.8", 0 -PUTFILE "vgm_botb/BotB 2310 chunter - overcast.raw.exo", "V.9", 0 -PUTFILE "vgm_botb/BotB 5106 null1024 - iNTeNSiTY.raw.exo", "V.A", 0 -PUTFILE "vgm_botb/BotB 5135 b00daw - kill chipsters on sight!.raw.exo", "V.C", 0 -PUTFILE "vgm_botb/BotB 5181 Kulor - Nintendo Entertainment Samba.raw.exo", "V.D", 0 -PUTFILE "vgm_botb/BotB 7637 happyfuntimes.raw.exo", "V.E", 0 -PUTFILE "vgm_botb/BotB 8493 null1024 - pinky plinky thingy.raw.exo", "V.F", 0 -PUTFILE "vgm_botb/BotB 9302 reg.raw.exo", "V.G", 0 -PUTFILE "vgm_botb/BotB 10995 masks revenge.raw.exo", "V.H", 0 -PUTFILE "vgm_botb/BotB 10996 gost haus.raw.exo", "V.I", 0 -PUTFILE "vgm_botb/BotB 11925 Interrobang Pie - Adrenaline Lift.raw.exo", "V.J", 0 -PUTFILE "vgm_botb/BotB 12143 DimWiddy - The Long Goodbye.raw.exo", "V.K", 0 -PUTFILE "vgm_botb/BotB 14648 chilled out princess.raw.exo", "V.L", 0 -PUTFILE "vgm_botb/BotB 16712 stewboy - The Circus is in Town.raw.exo", "V.M", 0 -PUTFILE "vgm_botb/BotB 16439 Chip Champion - frozen dancehall of the pharaoh.raw.exo", "V.N", 0 -PUTFILE "vgm_botb/BotB 20609 Jredd - PSG Strut.raw.exo", "V.O", 0 -PUTFILE "vgm_botb/my_mission.raw.exo", "V.P", 0 -PUTFILE "vgm_botb/my_new_used_car.raw.exo", "V.Q", 0 -PUTFILE "vgm_botb/run_under_fire.raw.exo", "V.R", 0 -;PUTFILE "data/loader_volume1.bin", "LSCREEN", 0 -======= -SAVE "BeebTrk", start, end, main - -PUTFILE "vgm_botb/BotB 7832 MasterTracker.raw.exo", "V.A", 0 -PUTFILE "vgm_botb/BotB 7383 exception.raw.exo", "V.BB", 0 ; V.B fails for some wierd reason? -PUTFILE "vgm_botb/BotB 16433 Slimeball - Fluid Dynamics.raw.exo", "V.C", 0 -PUTFILE "vgm_botb/BonusZone.raw.exo", "V.D", 0 -PUTFILE "vgm_botb/MISSION76496.raw.exo", "V.E", 0 -PUTFILE "vgm_botb/BotB 7639 lol i am late sorry.raw.exo", "V.F", 0 -PUTFILE "vgm_botb/BotB 4406 sonic_enters_a_dance_club.raw.exo", "V.G", 0 -PUTFILE "vgm_botb/BotB 1643 flashbob - I can haz d00ty caiclz plz.raw.exo", "V.H", 0 -PUTFILE "vgm_botb/BotB 1819 Kulor - Snofer Apostrophy S Infiltration Mission.raw.exo", "V.I", 0 -PUTFILE "vgm_botb/BotB 2310 chunter - overcast.raw.exo", "V.J", 0 -PUTFILE "vgm_botb/BotB 5106 null1024 - iNTeNSiTY.raw.exo", "V.K", 0 -PUTFILE "vgm_botb/BotB 5135 b00daw - kill chipsters on sight!.raw.exo", "V.L", 0 -PUTFILE "vgm_botb/BotB 5181 Kulor - Nintendo Entertainment Samba.raw.exo", "V.M", 0 -PUTFILE "vgm_botb/BotB 7637 happyfuntimes.raw.exo", "V.N", 0 -PUTFILE "vgm_botb/BotB 8493 null1024 - pinky plinky thingy.raw.exo", "V.O", 0 -PUTFILE "vgm_botb/BotB 9302 reg.raw.exo", "V.P", 0 -PUTFILE "vgm_botb/BotB 10995 masks revenge.raw.exo", "V.Q", 0 -PUTFILE "vgm_botb/BotB 10996 gost haus.raw.exo", "V.R", 0 -PUTFILE "vgm_botb/BotB 11925 Interrobang Pie - Adrenaline Lift.raw.exo", "V.S", 0 -PUTFILE "vgm_botb/BotB 12143 DimWiddy - The Long Goodbye.raw.exo", "V.T", 0 -PUTFILE "vgm_botb/BotB 14648 chilled out princess.raw.exo", "V.U", 0 -PUTFILE "vgm_botb/BotB 16712 stewboy - The Circus is in Town.raw.exo", "V.V", 0 -PUTFILE "vgm_botb/BotB 16439 Chip Champion - frozen dancehall of the pharaoh.raw.exo", "V.W", 0 -PUTFILE "vgm_botb/BotB 20609 Jredd - PSG Strut.raw.exo", "V.X", 0 -PUTFILE "vgm_botb/my_mission.raw.exo", "V.Y", 0 -PUTFILE "vgm_botb/my_new_used_car.raw.exo", "V.Z", 0 -PUTFILE "vgm_botb/run_under_fire.raw.exo", "V.ZZ", 0 - ->>>>>>> origin/master - - - -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/temp/beebtrk.ssd b/temp/beebtrk.ssd deleted file mode 100644 index 33d4097..0000000 Binary files a/temp/beebtrk.ssd and /dev/null differ diff --git a/temp/data/Mode7 Font.url b/temp/data/Mode7 Font.url deleted file mode 100644 index aa5070e..0000000 --- a/temp/data/Mode7 Font.url +++ /dev/null @@ -1,5 +0,0 @@ -[{000214A0-0000-0000-C000-000000000046}] -Prop3=19,2 -[InternetShortcut] -IDList= -URL=http://edit.tf/#0:LuFjB4sYOFiR4sYPFiR4sSOFiRogaLHiRAgaNMCRogQdMDQu3Rte_NJl4MOvBL35sG6FBl5NW6Nrw6sMnBK3UsOvBg1QtS_RA0cLGDxYwcLGDxYwcLEix4kaIGjRA0aIGmTAkyYEizYkLtVLXLwSt0aDK5Yt1bDlzSIGqDLwSqnSB6pauFLBA1QeOLAu42MMDRAsWMFixhg2IHixI4WIFmxI4WMHCxgsWMEDRAgQIC-3il49W diff --git a/temp/data/Mode7 Layout.url b/temp/data/Mode7 Layout.url deleted file mode 100644 index cf83f0c..0000000 --- a/temp/data/Mode7 Layout.url +++ /dev/null @@ -1,5 +0,0 @@ -[{000214A0-0000-0000-C000-000000000046}] -Prop3=19,2 -[InternetShortcut] -IDList= -URL=http://edit.tf/#0:NEUDD_vaf16X-vS_97Rf_X6n_3Q_-6H_3U1_6n6_U_-oGCA0TzNf-5j_WIP6xB_3MUH9Bq-99T3_qaoNT1jqepNT3ug7pDRJAh__kv_40__Gn_8lQf0Gpr_1Nf6r6_1Nf-r781Nf6BCgQIEFPfuzug0Lf0hIKGjD0QTMufLuyIN-ZB00ZUFDRh5b1y5BB69NG_k6DQtOzZ5QQt-Lnr8oEyDpoyoO-HTsy8uaDJlXLi_hYsWLF diff --git a/temp/data/Mode7 Loading.url b/temp/data/Mode7 Loading.url deleted file mode 100644 index e2e50ca..0000000 --- a/temp/data/Mode7 Loading.url +++ /dev/null @@ -1,5 +0,0 @@ -[{000214A0-0000-0000-C000-000000000046}] -Prop3=19,2 -[InternetShortcut] -IDList= -URL=http://edit.tf/#0:Imv-xB-ToHixJqUtECzYs0bNjBBo2MHixJowPEDxIg1bUCAma972H9Yg6vEGpf1QINSBV--JUDZZt6oECh_0QfViDV-QICRr-sS_ViResXKliNAgVIEG9UsQJUCpUsSIEqpAuWLESZWgQIEFPfuzug0Lf0hIKGjD0QTMufLuyIN-ZB00ZUFDRh5b1y5BB69NG_k6DQtOzZ5QQt-Lnr8oEyDpoyoO-HTsy8uaDJlXLi_hYsWLF diff --git a/temp/data/font_5x5.mode7 b/temp/data/font_5x5.mode7 deleted file mode 100644 index e350c5b..0000000 --- a/temp/data/font_5x5.mode7 +++ /dev/null @@ -1 +0,0 @@ -—8,0<,08,$<,0<,$<,$8,$4 4,<$ 44`$4 t`4—7#5ws$ep0up%ws07! er57#5pu0dp%7)0up05!5—t 48,0<,08,0<,08,$,<$4 44 44 4d`$d`$,l$—5)5ep%7# e917+0rs$ 5 ep%*: =)58)0 5 xq0—8l0`4 ,,0,,0`l <,$8, ,l$8,08,0,,0 4 —mq%qu0vs0rs$-n$ss$gs$h! fs$bs% 3 1 0 \ No newline at end of file diff --git a/temp/data/font_5x5_shifted.mode7 b/temp/data/font_5x5_shifted.mode7 deleted file mode 100644 index ec196e4..0000000 --- a/temp/data/font_5x5_shifted.mode7 +++ /dev/null @@ -1 +0,0 @@ -—8,0<,08,$<,0<,$<,$8,$4 4,<$ 44`$4 t`4—7#5ws$ep0up%ws07! er57#5pu0dp%7)0up05!5—t 48,0<,08,0<,08,$,<$4 44 44 4d`$d`$,l$—5)5ep%7# e917+0rs$ 5 ep%*: =)58)0 5 xq0—8l0`4 ,,0,,0`l <,$8, ,l$8,08,0,,0 4 —mq%qu0vs0rs$-n$ss$gs$h! fs$bs% 3 1 0 ‘ ‘ ‘`,dh,d`,,h,dh,,h,,`,,h h(l, hh 8h h0x‘j#kjs9*ppjp:jsqj# *p{j#k`zp(p:j#djppj"j’h0h`,dh,d`,dh,d`,,(l,h hh hh h(08(08(,<’j"n*p:j#!*rfj#e`s9 j *p: e%j&n`&d j `vp“`,t x (,d(,d 84h,,`,$(,<`,d`,d(,d h “*v:bzphsq`s9*,=bs9*s9 6 (s9 s; b! b ` “ \ No newline at end of file diff --git a/temp/data/font_5x5_shifted_trimmed.mode7.bin b/temp/data/font_5x5_shifted_trimmed.mode7.bin deleted file mode 100644 index dc45529..0000000 --- a/temp/data/font_5x5_shifted_trimmed.mode7.bin +++ /dev/null @@ -1 +0,0 @@ -—8,0<,08,$<,0<,$<,$8,$4 4,<$ 44`$4 t`4—7#5ws$ep0up%ws07! er57#5pu0dp%7)0up05!5—t 48,0<,08,0<,08,$,<$4 44 44 4d`$d`$,l$—5)5ep%7# e917+0rs$ 5 ep%*: =)58)0 5 xq0—8l0`4 ,,0,,0`l <,$8, ,l$8,08,0,,0 4 —mq%qu0vs0rs$-n$ss$gs$h! fs$bs% 3 1 0 ‘ ‘ ‘`,dh,d`,,h,dh,,h,,`,,h h(l, hh 8h h0x‘j#kjs9*ppjp:jsqj# *p{j#k`zp(p:j#djppj"j’h0h`,dh,d`,dh,d`,,(l,h hh hh h(08(08(,<’j"n*p:j#!*rfj#e`s9 j *p: e%j&n`&d j `vp“`,t x (,d(,d 84h,,`,$(,<`,d`,d(,d h “*v:bzphsq`s9*,=bs9*s9 6 (s9 s; b! b ` “ \ No newline at end of file diff --git a/temp/data/loader_volume1.bin b/temp/data/loader_volume1.bin deleted file mode 100644 index 95b7df0..0000000 --- a/temp/data/loader_volume1.bin +++ /dev/null @@ -1 +0,0 @@ -—šžssss“ssss–ssss’ssss•ssss‘ssss”ssss1 —šž —šž j0b(=`>>>>>> origin/master - - \\ Load first file in our list - LDA #0 - STA file_no - - - \\ Intro screen goes here \\ - - -\\ ***** Loading state ***** \\ - - .loading_state - { - \\ Clear screen - LDA #12: JSR oswrch - JSR teletexel_init - - \\ Init scrolltext with loading message - LDA #LO(load_message):LDX #HI(load_message) - LDY #11:JSR init_scr - - \\ Start our event driven fx - ldx #LO(load_eventv) - ldy #HI(load_eventv) - JSR start_eventv - - \\ Blocking file load - JSR load_file_from_table - PHA ; store return value - - \\ Kill our event driven fx - JSR stop_eventv - - \\ Returned error? - PLA - BEQ no_error - - \\ Handle error (exit) - JMP return - - .no_error - } - -\\ ***** Demo (Tracker) state ***** \\ - - \\ Initialise demo state - JSR init_demo - - .enter_demo_state - - \\ Technically should populate the tracker display with genuine music data here! - \\ But at 20ms per line it fills up with data in a 140ms so is hardly noticable... - - \\ Demo loop - .demo_loop - { - \\ Check for pressed keys - LDA #121 - LDX #&10 - JSR osbyte - - \\ Still holding same key - CPX menu_key_held - BEQ no_key_pressed - - \\ Remember current key - STX menu_key_held - - \\ Any key pressed? - CPX #&FF - BEQ no_key_pressed - - \\ Check escape - CPX #MENU_key_toggle - BEQ enter_menu_state - - .no_key_pressed - - \\ Poll the music player - LDA player_ended - BNE song_ended - - \\ Wait for vsync - NO LONGER WAITING FOR VSYNC - ;LDA #19 - ;JSR osbyte - - \\ Actually sync to audio instead - LDA player_counter - .wait_for_audio_sync - CMP player_counter - BEQ wait_for_audio_sync - - \\ At this point we know audio data has just been sent to SN - \\ So all of our vars from the player are fresh - \\ Use these to render our demo FX (before next vsync!) - \\ May still want to do something clever to avoid flicker - - \\ Poll tracker - JSR poll_tracker - - \\ Poll our VU effects - LDA #&FF ; we do want beat bars - JSR poll_fx - - \\ Update scrolltext - JSR poll_scr - - \\ Loop - JMP demo_loop - - .song_ended - - \\ Deinitialise demo state - JSR deinit_demo - - \\ Increment file in table - LDX file_no - INX - CPX #NUM_vgm_files - BCC next_file - LDX #0 - .next_file - STX file_no - - \\ Automatically load next file - JMP loading_state - } - -\\ ***** Menu state ***** \\ - - .enter_menu_state - - \\ Initialise menu state - - JSR init_menu - JSR menu_populate - - \\ Menu loop - .menu_loop - { - \\ Check for pressed keys - LDA #121 - LDX #&10 - JSR osbyte - - \\ Still holding same key - CPX menu_key_held - BEQ no_key_pressed - - \\ Remember current key - STX menu_key_held - - \\ Any key pressed? - CPX #&FF - BEQ no_key_pressed - - \\ Check escape - CPX #MENU_key_toggle - BNE not_escape - - \\ Handle toggle key - \\ Revert file no - LDA menu_old_file - STA file_no - - \\ Cancel menu - .cancel_menu - JSR deinit_menu - JMP enter_demo_state - - .not_escape - CPX #MENU_key_up - BNE not_up - - \\ Handle up key - \\ Decrement file_no no lower than 0 - LDA file_no - BEQ not_up - DEC file_no - - \\ Update our menu on screen - JSR menu_populate - JMP no_key_pressed - - .not_up - CPX #MENU_key_down - BNE not_down - - \\ Handle down - \\ Increment file_no up to MAX - LDA file_no - IF COMPILE_OPTION_EXIT - CMP #NUM_vgm_files - ELSE - CMP #NUM_vgm_files - 1 - ENDIF - BEQ not_down - INC file_no - - \\ Update our menu on screen - JSR menu_populate - JMP no_key_pressed - - .not_down - CPX #MENU_key_select - BNE not_select - - \\ Handle select key - \\ Check if we're on the same track - LDA file_no - CMP menu_old_file - BEQ cancel_menu - - \\ Deinit the menu - JSR deinit_menu - - \\ Deinit the demo - JSR deinit_demo - - \\ Either file load or exit - LDA file_no - CMP #NUM_vgm_files - BEQ exit_app - - \\ Load new file - JMP loading_state - - .not_select - .no_key_pressed - - \\ If track has ended just keep menu around until user action - LDA player_ended - BEQ sync_to_audio - - \\ If no audio then sync to vsync instead! - LDA #19 - JSR osbyte - BNE skip_audio_sync - - \\ Sync to audio - .sync_to_audio - LDA player_counter - .wait_for_audio_sync - CMP player_counter - BEQ wait_for_audio_sync - - .skip_audio_sync - - \\ Poll our VU effects - LDA #0 ; we don't want beat bars - JSR poll_fx - - \\ Update scrolltext - JSR poll_scr - - \\ Loop - JMP menu_loop - - .exit_app - } - - - .return - RTS - - -} - - - - - - - - - -\ ****************************************************************** -\ * Menu state routines -\ ****************************************************************** - -.init_menu -{ - \\ Copy menu overlay to screen - 8x lines from line 14 - LDX #0 - .loop - LDA MENU_overlay_src_addr, X - STA MENU_overlay_dst_addr, X - INX - BNE loop - - LDX #(MENU_overlay_size - 1) - &100 - .loop2 - LDA MENU_overlay_src_addr + &100, X - STA MENU_overlay_dst_addr + &100, X - DEX - BPL loop2 - - \\ Remember stuff - LDA file_no - STA menu_old_file - - .return - RTS -} - -.menu_populate -{ - \\ Populate our menu with entries based on file_no - LDA file_no - SEC - SBC #1 - TAX - - LDY #MENU_top_line_ypos - - .loop - LDA mode7_row_addr_LO,Y - STA writeptr - LDA mode7_row_addr_HI,Y - STA writeptr+1 - - TXA:PHA - BPL positive - - .clamp - \\ Write blank line - LDX #MENU_entry_xpos:LDA #MENU_entry_xpos + MENU_entry_width - JSR teletexel_erase_row - JMP next - - .positive - IF COMPILE_OPTION_EXIT - CPX #NUM_vgm_files+1 ; include quit option - ELSE - CPX #NUM_vgm_files ; don't include quit option - ENDIF - BCS clamp - - \\ Write entry from loading_table - LDA #0:STA write_loop+2 - - TXA - ASL A - ROL write_loop+2 - ASL A - ROL write_loop+2 - ASL A - ROL write_loop+2 - ASL A - ROL write_loop+2 - ASL A - ROL write_loop+2 ; 16-bit multiply by 32 - - ; carry is zero - ADC #LO(menu_entries) - STA write_loop+1 - - LDA #HI(menu_entries) - ADC write_loop+2 - STA write_loop+2 - - \\ Store Y - TYA:PHA - - LDX #0 - LDY #MENU_entry_xpos - .write_loop - LDA menu_entries,X - STA (writeptr),Y - INY - INX - CPX #MENU_entry_width - BNE write_loop - - PLA:TAY - - .next - PLA:TAX - INX - - INY - CPY #TRACKER_dupe_line_ypos - BNE not_dupe - INY - .not_dupe - CPY #MENU_bottom_line_ypos + 1 - BNE loop - - \\ Duplicate line 17 to line 18 for double height - LDX #TRACKER_active_line_ypos - LDY #TRACKER_dupe_line_ypos - JSR mode7_copy_line - - .return - RTS -} - -.deinit_menu -{ - \\ Copy original tracker back to screen - 8x lines from line 14 - LDX #0 - .loop - LDA MENU_original_src_addr, X - STA MENU_overlay_dst_addr, X - INX - BNE loop - - LDX #(MENU_overlay_size - 1) - &100 - .loop2 - LDA MENU_original_src_addr + &100, X - STA MENU_overlay_dst_addr + &100, X - DEX - BPL loop2 - - .return - RTS -} - - -\ ****************************************************************** -\ * Demo state routines -\ ****************************************************************** - -.init_demo -{ - \\ Set load and store addresses - \\ Is it really necessary to use self-modifying code here?! - - LDA #LO(mode7_screen_data) - STA loop+1 - LDA #HI(mode7_screen_data) - STA loop+2 - - LDA #LO(MODE7_base_addr) - STA loop+4 - LDA #HI(MODE7_base_addr) - STA loop+5 - - \\ Initialise MODE 7 screen - LDY #0 - .loop - LDA mode7_screen_data,Y ; **SELF-MODIFIED CODE** - STA MODE7_base_addr,Y ; **SELF-MODIFIED CODE** - - INY - BNE loop - INC loop + 2 ; increment read address hi byte - INC loop + 5 ; increment write address hi byte - BPL loop ; until >= &8000 ; this is actually overcopying the data as we only have 1000 bytes... - - \\ Initialise our effects - JSR init_fx - - LDA #LO(demo_message): LDX #HI(demo_message) - LDY #23: JSR init_scr ; top of scroller at Y - - \\ Initialise music player - pass in VGM_stream_data address - \\ parses header from stream -; VGM_end_of_data needs to point to the address just after the address -; of the last byte of crunched data. - LDX #LO(VGM_stream_data - 1) - LDY #HI(VGM_stream_data - 1) - JSR init_vgm_stream - - \\ Copy meta data to screen - LDX #0 - .meta_loop - LDA player_song_title,X - STA META_title_addr,X - LDA player_song_author,X - STA META_author_addr,X - INX - CPX #META_max_width - BNE meta_loop - - \\ Copy clock to screen - LDA #LO(META_clock_addr) - STA writeptr - LDA #HI(META_clock_addr) - STA writeptr+1 - - LDX meta_clock_mins - LDY meta_clock_secs - JSR write_clock_at_writeptr - - \\ Copy duration to screen - LDA #LO(META_duration_addr) - STA writeptr - LDA #HI(META_duration_addr) - STA writeptr+1 - - LDX player_duration_mins - LDY player_duration_secs - JSR write_clock_at_writeptr - - \\ Setup the playtime bar - LDA player_packet_count - STA playtime_interval - LDA player_packet_count+1 - STA playtime_interval+1 - LDA #FX_playtime_width - STA playtime_index - - \\ Divide total packet count by FX_playtime_width using 16bit/8bit math = 16bit result - LDX #16 - LDA #0 - .div_loop - ASL playtime_interval - ROL playtime_interval+1 - ROL A - CMP playtime_index - BCC no_sub - SBC playtime_index - INC playtime_interval - .no_sub - DEX - BNE div_loop - - \\ A contains remainder but we discard as we dont need accuracy - \\ playtime_interval now contains # of 50Hz updates before playtime_index should be incremented - LDA #0 - STA playtime_index - STA playtime_counter - STA playtime_counter+1 - - \\ Hook up Event vector - starts player - ldx #LO(demo_eventv) - ldy #HI(demo_eventv) - JSR start_eventv - - .return - RTS -} - -.poll_demo -{ - \\ Poll tracker - JSR poll_tracker - - \\ Poll our VU effects - JSR poll_fx - - \\ Update scrolltext - JSR poll_scr - - \\ Poll the music player - LDA player_ended - - .return - RTS -} - -.deinit_demo -{ - \\ Unhook Event vector - stops player - JSR stop_eventv - - \\ Shutdown music player - silences all audio channels - JSR deinit_player - - .return - RTS -} - -.demo_eventv -{ - php - cmp #4 - bne not_vsync - - \\ Preserve registers - pha:TXA:PHA:TYA:PHA - - \\ Poll the music player - jsr poll_player - - \\ Restore registers - PLA:TAY:PLA:TAX:pla - - \\ Return - .not_vsync - plp - rts -} - - -\ ****************************************************************** -\ * File loading routines -\ ****************************************************************** -<<<<<<< HEAD -.load_menu_data -{ - \\ Set osfile param block - LDA #LO(menu_data_filename) - STA osfile_params + 0 - LDA #HI(menu_data_filename) - STA osfile_params + 1 - - LDA #LO(menu_data_start) - STA osfile_params + 2 - LDA #HI(menu_data_start) - 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 - RTS -} - -\\ *** Show loading screen *** -.show_intro -{ -; \\ Set osfile param block -; LDA #LO(loadscreen_data_filename) -; STA osfile_params + 0 -; LDA #HI(loadscreen_data_filename) -; STA osfile_params + 1 - -; LDA #LO(VGM_stream_data) -; STA osfile_params + 2 -; LDA #HI(VGM_stream_data) -; 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(VGM_stream_data) - LDY #HI(VGM_stream_data) - JSR exo_init_decruncher - - \\ unpack to screen - LDX #&00 - LDY #&7c - JSR exo_unpack - - - - JSR &FFE0 - RTS -} - -======= ->>>>>>> origin/master - -.load_file_from_table ; flle_no = index into our table -{ - LDA file_no - ASL A:ASL A: ASL A ; file_no * 8 - - \\ Set osfile param block - CLC - ADC #LO(vgm_filenames) - STA osfile_params + 0 - LDA #HI(vgm_filenames) - ADC #0 - STA osfile_params + 1 - - LDA #LO(VGM_stream_data) - STA osfile_params + 2 - LDA #HI(VGM_stream_data) - 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 - - \\ Error? ; turns out DFS doesn't return error from osfile A=&FF..! - LDA #0 ; should return whether error occurred - .return - RTS -} - -.load_eventv -{ - php - cmp #4 - beq vsync - JMP not_vsync - - .vsync - \\ Preserve registers - pha:TXA:PHA:TYA:PHA - -\\ ***** Loading FX ***** \\ - -\\ Must be cheap otherwise will callback will re-enter! - - \\ Poll scroll - JSR poll_scr - - \\ Restore registers - PLA:TAY:PLA:TAX:pla - - \\ Return - .not_vsync - plp - rts -} - - -\ ****************************************************************** -\ * Teletexel / MODE 7 functions & helpers -\ ****************************************************************** - -.teletexel_init ; set blank screen -{ - LDX #MODE7_contiguous - LDY #MODE7_char_height - 1 - - .loop - TYA:PHA - LDA #MODE7_graphic_black + 7 - JSR teletexel_set_row_start - PLA:TAY - DEY - BPL loop - - .return - RTS -} - -.teletexel_set_row_start ; set row Y to char A, X -{ - PHA - LDA mode7_row_addr_LO,Y - STA writeptr - LDA mode7_row_addr_HI,Y - STA writeptr+1 - - LDY #0 - PLA - STA (writeptr),Y - TXA:INY - STA (writeptr),Y - - .return - RTS -} - -.teletexel_erase_row ; row Y, start X, end A -{ - STA tmp_erase - - LDA mode7_row_addr_LO,Y - STA loop+1 - LDA mode7_row_addr_HI,Y - STA loop+2 - - LDA #32 - .loop - STA MODE7_base_addr,X ; **SELF-MODIFIED CODE** - INX - CPX tmp_erase - BNE loop - - .return - RTS -} - - -\ ****************************************************************** -\ * Scrolltext code -\ * Redraws entire message each frame -\ * Only scrolls with byte precision, i.e. two pixels per frame -\ * This is too fast for a 5x5 pixel font -\ * TODO - rewrite to be single pixel scroll -\ ****************************************************************** - -.init_scr ; Y = y pos drawn at, A, X = address of message -{ - \\ Set address of message - **MODIFIES CODE** - STA poll_scr_msg_addr_1+1 - STA poll_scr_msg_addr_2+1 - STX poll_scr_msg_addr_1+2 - STX poll_scr_msg_addr_2+2 - - \\ Set address that scrolltext drawn to - **MODIFIES CODE** - STY scr_y - LDA mode7_row_addr_LO,Y - STA poll_scr_line_1_addr+1 - LDA mode7_row_addr_HI,Y - STA poll_scr_line_1_addr+2 - INY - LDA mode7_row_addr_LO,Y - STA poll_scr_line_2_addr+1 - LDA mode7_row_addr_HI,Y - STA poll_scr_line_2_addr+2 - - LDA #0 - STA scr_msg_idx - STA scr_col - - .return - RTS -} - -.poll_scr -\\{ - \\ Copy our temp variables for drawing - LDA scr_col - LSR A - STA tmp_cur_col ; current column in font - - \\ Set font load address - BCC shifted_font - - \\ Not shifted - LDA #LO(mode7_font_data) - STA poll_scr_font_line1_addr + 1 - LDA #HI(mode7_font_data) - STA poll_scr_font_line1_addr + 2 - - JMP write_second_font_addr - - \\ Shifted by 1 pixel - .shifted_font - LDA #LO(mode7_font_data_shifted) - STA poll_scr_font_line1_addr + 1 - LDA #HI(mode7_font_data_shifted) - STA poll_scr_font_line1_addr + 2 - - .write_second_font_addr - CLC - LDA poll_scr_font_line1_addr + 1 - ADC #MODE7_char_width - STA poll_scr_font_line2_addr + 1 - LDA poll_scr_font_line1_addr + 2 - ADC #0 - STA poll_scr_font_line2_addr + 2 - - LDA scr_msg_idx - STA tmp_msg_idx ; current index into message - - \\ Loop over characters in row - LDX #2 ; X char position - ignore first two - .poll_scr_xloop - - LDY tmp_msg_idx - .poll_scr_msg_addr_1 - LDA demo_message,Y ; actually contains the offset into font data - **SELF-MODIFIED CODE** - BNE poll_scr_not_end_of_msg ; finish if zero - - LDY #0 - STY tmp_msg_idx - BEQ poll_scr_msg_addr_1 - - .poll_scr_not_end_of_msg - \\ Work out which column we're on - CLC - ADC tmp_cur_col - TAY - - \\ Draw a column of the font to the screen - .poll_scr_draw_col - - .poll_scr_font_line1_addr - LDA mode7_font_data_shifted,Y ; **SELF-MODIFIED CODE** - .poll_scr_line_1_addr - STA &7C00,X ; **SELF-MODIFIED CODE** - - .poll_scr_font_line2_addr - LDA mode7_font_data_shifted + MODE7_char_width,Y ; **SELF-MODIFIED CODE** - .poll_scr_line_2_addr - STA &7C28,X ; **SELF-MODIFIED CODE** - - \\ Next screen column - INX - CPX #MODE7_char_width - BEQ poll_scr_done - - \\ Next font column - INY - - INC tmp_cur_col - LDA tmp_cur_col - CMP #3 - BNE poll_scr_draw_col - - \\ Done all columns - LDY #0 - STY tmp_cur_col - - INC tmp_msg_idx ; next letter - - JMP poll_scr_xloop - - .poll_scr_done - INC scr_col ; increment column for scroll - LDA scr_col - CMP #6 - BNE poll_scr_return ; 8 columns - - LDA #0 - STA scr_col ; reset column - INC scr_msg_idx ; next char in scr_message - - LDY scr_msg_idx - .poll_scr_msg_addr_2 - LDA demo_message,Y ; **SELF-MODIFIED CODE** - BNE poll_scr_return - STA scr_msg_idx - - .poll_scr_return - RTS -\\} - - -\ ****************************************************************** -\ * Graphic equaliser effect -\ ****************************************************************** - -.init_fx -{ - \\ Initialise the frequency array & beat bar array - \\ freq_array is followed by chan_array, so we can process all together - LDY #(FX_num_freqs+FX_num_channels) - 1 - LDA #0 - .loop - STA freq_array,Y - DEY - BPL loop - - \\ hacky code to clear off the rogue bars left + right - \\ better solution is to clean up screen layout - LDX #0 - LDA #32 - STA FX_address_row0-1, X - STA FX_address_row1-1, X - STA FX_address_row2-1, X - STA FX_address_row3-1, X - STA FX_address_row4-1, X - STA FX_address_row4-1, X - LDX #FX_chr_w+1 - STA FX_address_row0-1, X - STA FX_address_row1-1, X - STA FX_address_row2-1, X - STA FX_address_row3-1, X - STA FX_address_row4-1, X - STA FX_address_row4-1, X - - \\ code to reset the playtime bar, serves two purposes: - \\ 1) resets the mockup - \\ 2) erases any bars from the previously played track - LDA #160+12 - LDX #FX_playtime_chrs-1 - .clear_playtime_loop - STA FX_playtime_address, X - DEX - BPL clear_playtime_loop - \\ set the first bar up - LDA #160+29 - STA FX_playtime_address - - - \\ init meta data vars - LDA #0 - STA meta_idx - STA meta_poll_count - STA meta_clock_mins - STA meta_clock_secs - - LDA #META_scroll_start_delay - STA meta_timer - - .return - RTS -} - -\\ Render a 3 character high graphic beat bar -\\ A is the channel, X is the char offset -.draw_beat_bar -{ - TAY - LDA chan_array, Y - CLC - ADC #1 - STA tmp_fx_y - ASL A - ASL A - CLC - ADC tmp_fx_y - TAY - - \\ render a 3 byte bar column, 1 chr per bar - LDA fx_table + 2, Y - STA FX_address_beat+0, X - LDA fx_table + 1, Y - STA FX_address_beat+40, X - LDA fx_table + 0, Y - STA FX_address_beat+80, X - - RTS -} - -.write_clock_at_writeptr ; X=mins, Y=secs -{ - TYA:PHA - LDY #0 - - CLC - TXA - ADC #'0' - STA (writeptr),Y - INY - - LDA #':' - STA (writeptr),Y - INY - - \\ Count tens - PLA - LDX #0 - .loop_10 - CMP #10 - BCC done_10 - SEC - SBC #10 - INX - JMP loop_10 - .done_10 - PHA - - \\ Write tens - CLC - TXA - ADC #'0' - STA (writeptr),Y - INY - - \\ Write units - PLA - ADC #'0' - STA (writeptr),Y - INY - - .return - RTS -} - -.poll_fx ; A = render beat bars or not (0) -{ - PHA ; remember this for later - - \\ render the bar fx in 15 by 5 character columns - LDX #0 - - .fx_column_loop - - \\ get frequency level - TXA - -IF FX_num_freqs == 16 - LSR A -ENDIF - - TAY - LDA freq_array, Y - - CLC - ADC #1 ; this hack forces levels to be a minimum of 1 - ; which means there's always a green bar showing - ; fx_table lookup has a duplicated extra entry to prevent overread - - \\ mult*5 and lookup teletext bar graphic - STA tmp_fx_y - ASL A - ASL A - CLC - ADC tmp_fx_y - TAY - -IF FX_num_freqs == 16 - \\ render the 5 byte bar column, 2 chrs per bar, 2nd bar has right hand column removed - LDA fx_table + 4, Y - STA FX_address_row0+0, X - AND #&B5 - STA FX_address_row0+1, X - LDA fx_table + 3, Y - STA FX_address_row1+0, X - AND #&B5 - STA FX_address_row1+1, X - LDA fx_table + 2, Y - STA FX_address_row2+0, X - AND #&B5 - STA FX_address_row2+1, X - LDA fx_table + 1, Y - STA FX_address_row3+0, X - AND #&B5 - STA FX_address_row3+1, X - LDA fx_table + 0, Y - STA FX_address_row4+0, X - AND #&B5 - STA FX_address_row4+1, X - \\ advance to next column - INX - INX - TXA - CMP #FX_num_freqs*2 -ELSE - \\ render the 5 byte bar column, 1 chr per bar - LDA fx_table + 4, Y - AND #&B5 - STA FX_address_row0+0, X - LDA fx_table + 3, Y - AND #&B5 - STA FX_address_row1+0, X - LDA fx_table + 2, Y - AND #&B5 - STA FX_address_row2+0, X - LDA fx_table + 1, Y - AND #&B5 - STA FX_address_row3+0, X - LDA fx_table + 0, Y - AND #&B5 - STA FX_address_row4+0, X - \\ advance to next column - INX - TXA - CMP #FX_num_freqs -ENDIF - - BNE fx_column_loop - - PLA:BEQ skip_beat_bars - - \\ Render the channel beat bars - LDA #0 - LDX #FX_ch0_x - JSR draw_beat_bar - LDA #1 - LDX #FX_ch1_x - JSR draw_beat_bar - LDA #2 - LDX #FX_ch2_x - JSR draw_beat_bar - LDA #3 - LDX #FX_ch3_x - JSR draw_beat_bar - - .skip_beat_bars - - \\ Let VU meter values fall to zero - LDY #(FX_num_freqs) - 1 - .loop - LDA freq_array,Y - BEQ zero - SEC - SBC #1 - STA freq_array,Y - .zero - DEY - BPL loop - - \\ Beat bars decay 2x faster - LDY #(FX_num_channels) - 1 - .loop2 - LDA chan_array,Y - BEQ zero2 - SEC - SBC #1 - STA chan_array,Y - BEQ zero2 - SEC - SBC #1 - STA chan_array,Y - .zero2 - DEY - BPL loop2 - - \\ Update playtime bar - INC playtime_counter - BNE no_hi - INC playtime_counter+1 - .no_hi - LDA playtime_counter - CMP playtime_interval - BNE not_yet - LDA playtime_counter+1 - CMP playtime_interval+1 - BNE not_yet - - \\ reset counter - LDA #0 - STA playtime_counter - STA playtime_counter+1 - - \\ clear current graphic at offset (we'll update next chr in a mo) - LDA playtime_index - LSR A - TAX - LDA #160+12 - STA FX_playtime_address, X - - \\ increment playtime offset & render new bar graphic - INC playtime_index - - \\ get the index, find chr X (index>>1, since 2 pixels per chr) - LDA playtime_index - TAY - LSR A - TAX - TYA - AND #1 ; odd or even, lookup graphic chr - TAY - LDA playtime_table, Y - STA FX_playtime_address, X - - .not_yet - - - - \\ Update meta data - { - DEC meta_timer - BNE done_meta - - \\ Reset meta scroll timer - LDA #META_scroll_update_delay - STA meta_timer - - \\ Update meta index - INC meta_idx - LDA meta_idx - CMP #PLAYER_string_max - META_max_width - 1 - BEQ longer_wait - CMP #PLAYER_string_max - META_max_width - BCC meta_no_wrap - - LDA #0 - STA meta_idx - .longer_wait - LDA #META_scroll_start_delay - STA meta_timer - - \\ Copy meta data to screen - .meta_no_wrap - - \\ End of string = idx + width clamped to string length - \\ Start of string = end - width clamped to zero - CLC - LDA meta_idx - ADC #META_max_width - STA tmp_var ; end - - \\ Handle title end - CMP player_song_title_len - BCC title_end_safe - LDA player_song_title_len - .title_end_safe - SEC - SBC #META_max_width ; start - BPL title_start_safe - LDA #0 - .title_start_safe - CLC - ADC #LO(player_song_title) - STA title_addr+1 - LDA #HI(player_song_title) - ADC #0 - STA title_addr+2 - - \\ Handle author end - LDA tmp_var - CMP player_song_author_len - BCC author_end_safe - LDA player_song_author_len - .author_end_safe - SEC - SBC #META_max_width ; start - BPL author_start_safe - LDA #0 - .author_start_safe - CLC - ADC #LO(player_song_author) - STA author_addr+1 - LDA #HI(player_song_author) - ADC #0 - STA author_addr+2 - - LDX #0 - .meta_loop - .title_addr - LDA player_song_title,X - STA META_title_addr,X - .author_addr - LDA player_song_author,X - STA META_author_addr,X - INX - CPX #META_max_width - BNE meta_loop - .done_meta - } - - \\ Increment counter for clock - { - INC meta_poll_count - LDA meta_poll_count - CMP #PLAYER_sample_rate - BNE not_sec_yet - - \\ Reset counter - LDA #0 - STA meta_poll_count - - \\ Update 1 second - INC meta_clock_secs - LDA meta_clock_secs - CMP #60 - BNE not_min_yet - - \\ Update 1 min - INC meta_clock_mins - LDA #0 - STA meta_clock_secs - - .not_min_yet - - \\ Display clock - LDA #LO(META_clock_addr) - STA writeptr - LDA #HI(META_clock_addr) - STA writeptr+1 - - LDX meta_clock_mins - LDY meta_clock_secs - JSR write_clock_at_writeptr - - .not_sec_yet - } - - .return - RTS -} - - -\ ****************************************************************** -\ * Tracker scrolling display -\ ****************************************************************** - -.write_decimal_at ; A = number, X,Y = location on MODE 7 screen -{ - PHA - LDA mode7_row_addr_LO,Y - STA writeptr - LDA mode7_row_addr_HI,Y - STA writeptr+1 - - TXA:TAY - - \\ Count hundreds - PLA - LDX #0 - .loop_100 - CMP #100 - BCC done_100 - SEC - SBC #100 - INX - JMP loop_100 - .done_100 - PHA - - \\ Write hundreds - CLC - TXA - ADC #'0' - STA (writeptr),Y - INY - - \\ Count tens - PLA - LDX #0 - .loop_10 - CMP #10 - BCC done_10 - SEC - SBC #10 - INX - JMP loop_10 - .done_10 - PHA - - \\ Write tens - CLC - TXA - ADC #'0' - STA (writeptr),Y - INY - - \\ Write units - CLC - PLA - ADC #'0' - STA (writeptr),Y - - .return - RTS -} - -.mode7_copy_line ; copy line X to line Y -{ - \\ From line X - LDA mode7_row_addr_LO,X - STA readptr - LDA mode7_row_addr_HI,X - STA readptr+1 - - \\ To line Y - LDA mode7_row_addr_LO,Y - STA writeptr - LDA mode7_row_addr_HI,Y - STA writeptr+1 - - LDY #0 - .loop - LDA (readptr),Y - STA (writeptr),Y - INY - CPY #MODE7_char_width - BNE loop - - .return - RTS -} - -.copy_channel_fields ; copy channel fields only from line X to line Y -{ - \\ From line X - LDA mode7_row_addr_LO,X - STA readptr - LDA mode7_row_addr_HI,X - STA readptr+1 - - \\ To line Y - LDA mode7_row_addr_LO,Y - STA writeptr - LDA mode7_row_addr_HI,Y - STA writeptr+1 - - \\ Tracker line number field - LDY #TRACKER_lineno_field_xpos - - \\ Copy 4 bytes - LDA (readptr),Y: STA (writeptr),Y - INY: LDA (readptr),Y: STA (writeptr),Y - INY: LDA (readptr),Y: STA (writeptr),Y - INY: LDA (readptr),Y: STA (writeptr),Y - - \\ Channel 3 field - LDY #TRACKER_ch3_field_xpos - - \\ Copy 4 bytes - LDA (readptr),Y: STA (writeptr),Y - INY: LDA (readptr),Y: STA (writeptr),Y - INY: LDA (readptr),Y: STA (writeptr),Y - INY: LDA (readptr),Y: STA (writeptr),Y - - \\ Channel 2 field - LDY #TRACKER_ch2_field_xpos - - \\ Copy 4 bytes - LDA (readptr),Y: STA (writeptr),Y - INY: LDA (readptr),Y: STA (writeptr),Y - INY: LDA (readptr),Y: STA (writeptr),Y - INY: LDA (readptr),Y: STA (writeptr),Y - - \\ Channel 1 field - LDY #TRACKER_ch1_field_xpos - - \\ Copy 4 bytes - LDA (readptr),Y: STA (writeptr),Y - INY: LDA (readptr),Y: STA (writeptr),Y - INY: LDA (readptr),Y: STA (writeptr),Y - INY: LDA (readptr),Y: STA (writeptr),Y - - \\ Noise channel field - LDY #TRACKER_noise_field_xpos - - \\ Copy 4 bytes - LDA (readptr),Y: STA (writeptr),Y - INY: LDA (readptr),Y: STA (writeptr),Y - INY: LDA (readptr),Y: STA (writeptr),Y - INY: LDA (readptr),Y: STA (writeptr),Y - - .return - RTS -} - -.write_note_name -{ - LDA note_name_table_0,X - STA (writeptr),Y - INY - - LDA note_name_table_1,X - STA (writeptr),Y - INY - - LDA note_name_table_2,X - STA (writeptr),Y - INY - - .return - RTS -} - -.write_note_blank -{ - LDA #'-' - STA (writeptr),Y - INY - STA (writeptr),Y - INY - STA (writeptr),Y - INY - - .return - RTS -} - -MACRO WRITE_VOL_CHAR -{ - LDA hex_to_ascii, X - STA (writeptr),Y -} -ENDMACRO - -MACRO WRITE_VOL_BLANK -{ - LDA #'-' - STA (writeptr),Y -} -ENDMACRO - -.poll_tracker -{ - \\ Temporary scroll values up - don't need to calc write addresses when locations fixed - LDX #TRACKER_top_line_ypos + 1 - LDY #TRACKER_top_line_ypos - JSR copy_channel_fields - - LDX #TRACKER_top_line_ypos + 2 - LDY #TRACKER_top_line_ypos + 1 - JSR copy_channel_fields - - LDX #TRACKER_active_line_ypos - LDY #TRACKER_top_line_ypos + 2 - JSR copy_channel_fields - - \\ **Should be writing our fields to active line!** - - LDX #TRACKER_bottom_line_ypos - 2 - LDY #TRACKER_active_line_ypos - JSR copy_channel_fields - - LDX #TRACKER_bottom_line_ypos - 1 - LDY #TRACKER_bottom_line_ypos - 2 - JSR copy_channel_fields - - LDX #TRACKER_bottom_line_ypos - LDY #TRACKER_bottom_line_ypos - 1 - JSR copy_channel_fields - - \\ **Instead writing our live data into bottom line!** - \\ Write our current line number as decimal - - LDA player_counter - LDX #TRACKER_lineno_field_xpos + 1 ; +1 because leading 0 is constant - LDY #TRACKER_bottom_line_ypos - JSR write_decimal_at - - \\ Can reuse writeptr here - pointing to start of line we're writing! - \\ Write channel values into fields - DO THIS BETTER? - - .write_field_channel3 - { - LDY #12 - LDA player_reg_bits - AND #SN_BIT_TONE3_FREQ ; channel 3 tone - BEQ no_ch3_tone - - LDX player_reg_vals + SN_REG_TONE3_FREQ - JSR write_note_name - BNE try_ch3_vol ; OK because last instruction is INY - - .no_ch3_tone - JSR write_note_blank - - .try_ch3_vol - LDA player_reg_bits - AND #SN_BIT_TONE3_VOL ; channel 3 vol - BEQ no_ch3_vol - - LDX player_reg_vals + SN_REG_TONE3_VOL - WRITE_VOL_CHAR - BNE done_ch3 ; OK because A is char therefore not zero - - .no_ch3_vol - WRITE_VOL_BLANK - - .done_ch3 - } - - .write_field_channel2 - { - LDY #19 - LDA player_reg_bits - AND #SN_BIT_TONE2_FREQ ; channel 2 tone - BEQ no_ch2_tone - - LDX player_reg_vals + SN_REG_TONE2_FREQ - JSR write_note_name - BNE try_ch2_vol ; OK because last instruction is INY - - .no_ch2_tone - JSR write_note_blank - - .try_ch2_vol - LDA player_reg_bits - AND #SN_BIT_TONE2_VOL ; channel 2 vol - BEQ no_ch2_vol - - LDX player_reg_vals + SN_REG_TONE2_VOL - WRITE_VOL_CHAR - BNE done_ch2 ; OK because A is char therefore not zero - - .no_ch2_vol - WRITE_VOL_BLANK - - .done_ch2 - } - - .write_field_channel1 - { - LDY #26 - LDA player_reg_bits - AND #SN_BIT_TONE1_FREQ ; channel 1 tone - BEQ no_ch1_tone - - LDX player_reg_vals + SN_REG_TONE1_FREQ - JSR write_note_name - BNE try_ch1_vol ; OK because last instruction is INY - - .no_ch1_tone - JSR write_note_blank - - .try_ch1_vol - LDA player_reg_bits - AND #SN_BIT_TONE1_VOL ; channel 1 vol - BEQ no_ch1_vol - - LDX player_reg_vals + SN_REG_TONE1_VOL - WRITE_VOL_CHAR - BNE done_ch1 ; OK because A is char therefore not zero - - .no_ch1_vol - WRITE_VOL_BLANK - - .done_ch1 - } - - .write_field_noise - { - LDY #33 - LDA player_reg_bits - AND #SN_BIT_NOISE_CTRL ; noise channel control - BEQ no_noise_tone - - \\ Check noise control - LDA player_reg_vals + SN_REG_NOISE_CTRL - AND #SN_FB_MASK - BEQ noise_periodic - LDA #'W' ; White Noise - EQUB &2C ; = BIT noise_periodic => skip next two bytes - .noise_periodic - LDA #'P' ; Periodic Noise - STA (writeptr),Y - INY - - LDA player_reg_vals + SN_REG_NOISE_CTRL - AND #SN_NF_MASK - ASL A ; *2 - TAX - LDA noise_note_0,X ; noise_note = Lo,Me,Hi,T1 - STA (writeptr),Y - INY - LDA noise_note_0+1,X ; 2nd char - STA (writeptr),Y - INY - - BNE try_noise_vol ; OK because last instruction is INY - - .no_noise_tone - JSR write_note_blank - - .try_noise_vol - LDA player_reg_bits - AND #SN_BIT_NOISE_VOL ; noise channel vol - BEQ no_noise_vol - - LDX player_reg_vals + SN_REG_NOISE_VOL - WRITE_VOL_CHAR - BNE done_noise ; OK because A is char therefore not zero - - .no_noise_vol - WRITE_VOL_BLANK - - .done_noise - } - - \\ Duplicate line 17 to line 18 for double height - LDX #TRACKER_active_line_ypos - LDY #TRACKER_dupe_line_ypos - JSR mode7_copy_line - - .return - RTS -} - - - -\ ****************************************************************** -\ * Event Vector Routines -\ ****************************************************************** - -.start_eventv ; new event handler in X,Y -{ - \\ Remove interrupt instructions - lda #NOP_OP - sta PSG_STROBE_SEI_INSN - sta PSG_STROBE_CLI_INSN - - \\ Set new Event handler - sei - LDA EVENTV - STA old_eventv - LDA EVENTV+1 - STA old_eventv+1 - - stx EVENTV - sty EVENTV+1 - cli - - \\ Enable VSYNC event. - lda #14 - ldx #4 - jsr osbyte - rts -} - -.stop_eventv -{ - \\ Disable VSYNC event. - lda #13 - ldx #4 - jsr osbyte - - \\ Reset old Event handler - SEI - LDA old_eventv - STA EVENTV - LDA old_eventv+1 - STA EVENTV+1 - CLI - - \\ Insert interrupt instructions back - lda #SEI_OP - sta PSG_STROBE_SEI_INSN - lda #CLI_OP - sta PSG_STROBE_CLI_INSN - rts -} - - -\ ****************************************************************** -\ * Debug helpers -\ ****************************************************************** - -IF _DEBUG -.debug_print_A ; trashes X -{ - PHA:PHA - LSR A:LSR A:LSR A:LSR A - TAX - LDA hex_to_ascii,X - JSR oswrch - PLA - AND #&0F - TAX - LDA hex_to_ascii,X - JSR oswrch - LDA #32 - JSR oswrch - PLA - RTS -} -ENDIF - - - - -\ ****************************************************************** -\ * Look up tables -\ ****************************************************************** - -.lookup_tables_start - -\\ Start address of each row in MODE 7 - wasteful but helpful -.mode7_row_addr_LO -FOR n, 0, MODE7_char_height-1, 1 -EQUB LO(MODE7_base_addr + n * MODE7_char_width) -NEXT - -.mode7_row_addr_HI -FOR n, 0, MODE7_char_height-1, 1 -EQUB HI(MODE7_base_addr + n * MODE7_char_width) -NEXT - -\\ 16 Arrangements of 5 teletext character bytes to render a vertical equalizer bar -.fx_table -EQUB 160, 160, 160, 160, 160 -EQUB 160+80, 160, 160, 160, 160 -EQUB 160+92, 160, 160, 160, 160 -EQUB 160+95, 160, 160, 160, 160 -EQUB 160+95, 160+80, 160, 160, 160 -EQUB 160+95, 160+92, 160, 160, 160 -EQUB 160+95, 160+95, 160, 160, 160 -EQUB 160+95, 160+95, 160+80, 160, 160 -EQUB 160+95, 160+95, 160+92, 160, 160 -EQUB 160+95, 160+95, 160+95, 160, 160 -EQUB 160+95, 160+95, 160+95, 160+80, 160 -EQUB 160+95, 160+95, 160+95, 160+92, 160 -EQUB 160+95, 160+95, 160+95, 160+95, 160 -EQUB 160+95, 160+95, 160+95, 160+95, 160+80 -EQUB 160+95, 160+95, 160+95, 160+95, 160+92 -EQUB 160+95, 160+95, 160+95, 160+95, 160+95 -EQUB 160+95, 160+95, 160+95, 160+95, 160+95 ; last row copied to enable fixed bar effect - -.playtime_table -EQUB 160+29, 160+78 ; 160+12 for 'empty' middle line dash - -.num_to_bit ; look up bit N -EQUB &01, &02, &04, &08, &10, &20, &40, &80 - -.hex_to_ascii ; for volume print -EQUS "0123456789abcdef" - -.noise_note_0 EQUS "Lo" -.noise_note_1 EQUS "Md" -.noise_note_2 EQUS "Hi" -.noise_note_3 EQUS "T1" - -.note_tables_start - -\\ Note name lookup table, index using upper 8 bits of a 10-bit tone value. -\\ Not mega accurate, but fast, and good enough for a reasonably convincing visual -;ALIGN &100 ; doesn't need to be page aligned -.note_name_table_0 EQUS "AAAAGECAFEDCAGGFEDDCCCAGGGFFFEDDDDCCCCAAGGGGGFFFFFFEEEDDDDDDCCCCCCCCAAAAGGGGGGGGFFFFFFFFFFEEEEEDDDDDDDDDDDDCCCCCCCCCCCCCBBBBBBBAAAAAAAAAAAAAAAAGGGGGGGGGGGGGGGGGFFFFFFFFFFFFFFFFFFFEEEEEEEEEEEDDDDDDDDDDDDDDDDDDDDDDDCCCCCCCCCCCCCCCCCCCCCCCCCCBBBBBBBBBBBBBBBAA" -;note_name_table_1 EQUS "----#-#-#--#-#---#-#---#--#---##--##----###--###------###---####--------####----#####----------######------######--------------########--------########---------#########---------------------###########------------#############----------------------------##" -\\ Quirk of MODE 7: ASCII 35='#' but in gfx mode 35+128='£' so need to use ASCII 95='_' so in gfx mode 95+128='#' -.note_name_table_1 EQUS "----_-_-_--_-_---_-_---_--_---__--__----___--___------___---____--------____----_____----------______------______--------------________--------________---------_________---------------------___________------------_____________----------------------------__" -.note_name_table_2 EQUS "9999999888887777777777666666666666666655555555555555555555555555555544444444444444444444444444444444444444444444444444443333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333322222222222222222" - -.note_tables_end - -.lookup_tables_end - - -\ ****************************************************************** -\ * MODE 7 screen data -\ ****************************************************************** - -.mode7_data_start - -.mode7_screen_data -INCBIN "data/screen3.mode7" - -MENU_original_src_addr = mode7_screen_data + MENU_overlay_ypos * MODE7_char_width - -.mode7_font_data ; we use 16/25 lines of this screen -INCBIN "data/font_5x5_shifted_trimmed.mode7.bin" - -mode7_font_data_shifted = mode7_font_data + 8 * 40 - -.mode7_menu_data -INCBIN "data/menu_overlay_trimmed.mode7.bin" ; ditto, we only use ~8/25 lines of this screen - -MENU_overlay_src_addr = mode7_menu_data ; stripped this off (+ MENU_overlay_ypos * MODE7_char_width) - -.mode7_data_end - - -\\ Map character ASCII values to the byte offset into our MODE 7 font -\\ This is "cunning" but only works because the font has fewer than 256/6 (42) glyphs.. - -MACRO SET_TELETEXT_FONT_CHAR_MAP - - MAPCHAR 'A', 1 - MAPCHAR 'B', 4 - MAPCHAR 'C', 7 - MAPCHAR 'D', 10 - MAPCHAR 'E', 13 - MAPCHAR 'F', 16 - MAPCHAR 'G', 19 - MAPCHAR 'H', 22 - MAPCHAR 'I', 25 - MAPCHAR 'J', 28 - MAPCHAR 'K', 31 - MAPCHAR 'L', 34 - MAPCHAR 'M', 37 - - MAPCHAR 'a', 1 - MAPCHAR 'b', 4 - MAPCHAR 'c', 7 - MAPCHAR 'd', 10 - MAPCHAR 'e', 13 - MAPCHAR 'f', 16 - MAPCHAR 'g', 19 - MAPCHAR 'h', 22 - MAPCHAR 'i', 25 - MAPCHAR 'j', 28 - MAPCHAR 'k', 31 - MAPCHAR 'l', 34 - MAPCHAR 'm', 37 - - MAPCHAR 'N', 81 - MAPCHAR 'O', 84 - MAPCHAR 'P', 87 - MAPCHAR 'Q', 90 - MAPCHAR 'R', 93 - MAPCHAR 'S', 96 - MAPCHAR 'T', 99 - MAPCHAR 'U', 102 - MAPCHAR 'V', 105 - MAPCHAR 'W', 108 - MAPCHAR 'X', 111 - MAPCHAR 'Y', 114 - MAPCHAR 'Z', 117 - - MAPCHAR 'n', 81 - MAPCHAR 'o', 84 - MAPCHAR 'p', 87 - MAPCHAR 'q', 90 - MAPCHAR 'r', 93 - MAPCHAR 's', 96 - MAPCHAR 't', 99 - MAPCHAR 'u', 102 - MAPCHAR 'v', 105 - MAPCHAR 'w', 108 - MAPCHAR 'x', 111 - MAPCHAR 'y', 114 - MAPCHAR 'z', 117 - - MAPCHAR '0', 161 - MAPCHAR '1', 164 - MAPCHAR '2', 167 - MAPCHAR '3', 170 - MAPCHAR '4', 173 - MAPCHAR '5', 176 - MAPCHAR '6', 179 - MAPCHAR '7', 182 - MAPCHAR '8', 185 - MAPCHAR '9', 188 - MAPCHAR '?', 191 - MAPCHAR '!', 194 - MAPCHAR '.', 197 - - MAPCHAR ' ', 241 - -ENDMACRO diff --git a/temp/lib/exomiser.h.6502 b/temp/lib/exomiser.h.6502 deleted file mode 100644 index 330c4fb..0000000 --- a/temp/lib/exomiser.h.6502 +++ /dev/null @@ -1,53 +0,0 @@ -\\ ****************************************************************** -\\ EXOMISER (compression library) -\\ ****************************************************************** - -\\ Uses memory: -\\ &0C00-0CFF -\\ &0400-0800 -\\ Plus ZP vars - -\\ Compress data using: -\\ exomizer.exe raw -c -m 1024 -o - -\ ****************************************************************** -\ * Space reserved for runtime buffers not preinitialised -\ ****************************************************************** - -EXO_buffer_len = 1024 ; this is now packed in to language workspace at &0400 -\\ If you want to make this bigger than 1024 then need to find somewhere else to put it!! - -\\ Exomiser unpack buffer (must be page aligned) -\\ Now moved this to the language workspace at &0400 - &0800 -EXO_buffer_start = &400 -EXO_buffer_end = EXO_buffer_start + EXO_buffer_len - -; ------------------------------------------------------------------- -; this 156 byte table area may be relocated. It may also be clobbered -; by other data between decrunches. -; Located at spare OS memory page &0c00 reserved for Econet -; ------------------------------------------------------------------- - -EXO_TABL_SIZE = 156 -tabl_bi = &0c00 -tabl_lo = tabl_bi + 52 -tabl_hi = tabl_bi + 104 - - -\\ Declare ZP vars -.EXO_zp_src_hi SKIP 1 -.EXO_zp_src_lo SKIP 1 -.EXO_zp_src_bi SKIP 1 -.EXO_zp_bitbuf SKIP 1 - -.EXO_zp_len_lo SKIP 1 -.EXO_zp_len_hi SKIP 1 - -.EXO_zp_bits_lo SKIP 1 -.EXO_zp_bits_hi SKIP 1 - -.EXO_zp_dest_hi SKIP 1 -.EXO_zp_dest_lo SKIP 1 ; dest addr lo -.EXO_zp_dest_bi SKIP 1 ; dest addr hi - - diff --git a/temp/lib/exomiser.s.6502 b/temp/lib/exomiser.s.6502 deleted file mode 100644 index d2716e5..0000000 --- a/temp/lib/exomiser.s.6502 +++ /dev/null @@ -1,305 +0,0 @@ - -\ ****************************************************************** -\ * Exomiser (decompression library) -\ ****************************************************************** - -.exo_start - -; ------------------------------------------------------------------- -; Unpack a compressed data stream previously initialized by exo_init_decruncher -; to the memory address specified in X,Y -.exo_unpack -{ - STX write_chr+1 - STY write_chr+2 - - .next_chr - JSR exo_get_decrunched_byte - BCS all_done - .write_chr STA &ffff ; **SELF-MODIFIED** - INC write_chr+1 - BNE next_chr - INC write_chr+2 - BNE next_chr - .all_done - RTS -} - -; ------------------------------------------------------------------- -; Fetch byte from an exomiser compressed data stream -; for this get_crunched_byte routine to work the crunched data has to be -; crunced using the -m and possibly the -l flags. Any other -; flag will just mess things up. -.get_crunched_byte -{ - INC _byte_lo - bne _byte_skip_hi - INC _byte_hi ; forward decrunch -._byte_skip_hi: - -._byte - lda &ffff ; EXO data stream address ; **SELF-MODIFIED CODE** -_byte_lo = _byte + 1 -_byte_hi = _byte + 2 - rts ; decrunch_file is called. -} - -; ------------------------------------------------------------------- - - -EXO_crunch_byte_lo = get_crunched_byte + 9 -EXO_crunch_byte_hi = get_crunched_byte + 10 - - - -; ------------------------------------------------------------------- -; jsr this label to init the decruncher, it will init used zeropage -; zero page locations and the decrunch tables -; no constraints on register content, however the -; decimal flag has to be #0 (it almost always is, otherwise do a cld) -; X/Y contains address of EXO crunched data stream -; ------------------------------------------------------------------- -.init_decruncher ; pass in address of (crunched data-1) in X,Y -{ - STX EXO_crunch_byte_lo - STY EXO_crunch_byte_hi - - jsr get_crunched_byte - sta EXO_zp_bitbuf - - ldx #0 - stx EXO_zp_dest_lo - stx EXO_zp_dest_hi - stx EXO_zp_len_lo - stx EXO_zp_len_hi - ldy #0 -; ------------------------------------------------------------------- -; calculate tables (49 bytes) -; x and y must be #0 when entering -; -._init_nextone - inx - tya - and #$0f - beq _init_shortcut ; starta pε ny sekvens - - txa ; this clears reg a - lsr a ; and sets the carry flag - ldx EXO_zp_bits_lo -._init_rolle - rol a - rol EXO_zp_bits_hi - dex - bpl _init_rolle ; c = 0 after this (rol EXO_zp_bits_hi) - - adc tabl_lo-1,y - tax - - lda EXO_zp_bits_hi - adc tabl_hi-1,y -._init_shortcut - sta tabl_hi,y - txa - sta tabl_lo,y - - ldx #4 - jsr _bit_get_bits ; clears x-reg. - sta tabl_bi,y - iny - cpy #52 - bne _init_nextone -} -\\ Fall through! - -._do_exit - rts - -; ------------------------------------------------------------------- -; decrunch one byte -; -.get_decrunched_byte -{ - ldy EXO_zp_len_lo - bne _do_sequence - ldx EXO_zp_len_hi - bne _do_sequence2 - - jsr _bit_get_bit1 - beq _get_sequence -; ------------------------------------------------------------------- -; literal handling (13 bytes) -; - jsr get_crunched_byte - bcc _do_literal -; ------------------------------------------------------------------- -; count zero bits + 1 to get length table index (10 bytes) -; y = x = 0 when entering -; -._get_sequence -._seq_next1 - iny - jsr _bit_get_bit1 - beq _seq_next1 - cpy #$11 - bcs _do_exit -; ------------------------------------------------------------------- -; calulate length of sequence (zp_len) (17 bytes) -; - ldx tabl_bi - 1,y - jsr _bit_get_bits - adc tabl_lo - 1,y - sta EXO_zp_len_lo - lda EXO_zp_bits_hi - adc tabl_hi - 1,y - sta EXO_zp_len_hi -; ------------------------------------------------------------------- -; here we decide what offset table to use (20 bytes) -; x is 0 here -; - bne _seq_nots123 - ldy EXO_zp_len_lo - cpy #$04 - bcc _seq_size123 -._seq_nots123 - ldy #$03 -._seq_size123 - ldx tabl_bit - 1,y - jsr _bit_get_bits - adc tabl_off - 1,y - tay -; ------------------------------------------------------------------- -; calulate absolute offset (zp_src) (27 bytes) -; - ldx tabl_bi,y - jsr _bit_get_bits; - adc tabl_lo,y - bcc _seq_skipcarry - inc EXO_zp_bits_hi - clc -._seq_skipcarry - adc EXO_zp_dest_lo - sta EXO_zp_src_lo - lda EXO_zp_bits_hi - adc tabl_hi,y - adc EXO_zp_dest_hi -; ------------------------------------------------------------------- - cmp #HI(EXO_buffer_len) - bcc _seq_offset_ok - sbc #HI(EXO_buffer_len) - clc -; ------------------------------------------------------------------- -._seq_offset_ok - sta EXO_zp_src_hi - adc #HI(EXO_buffer_start) - sta EXO_zp_src_bi -._do_sequence - ldy #0 -._do_sequence2 - ldx EXO_zp_len_lo - bne _seq_len_dec_lo - dec EXO_zp_len_hi -._seq_len_dec_lo - dec EXO_zp_len_lo -; ------------------------------------------------------------------- - ldx EXO_zp_src_lo - bne _seq_src_dec_lo - ldx EXO_zp_src_hi - bne _seq_src_dec_hi -; ------- handle buffer wrap problematics here ---------------------- - ldx #HI(EXO_buffer_len) - stx EXO_zp_src_hi - ldx #HI(EXO_buffer_end) - stx EXO_zp_src_bi -; ------------------------------------------------------------------- -._seq_src_dec_hi - dec EXO_zp_src_hi - dec EXO_zp_src_bi -._seq_src_dec_lo - dec EXO_zp_src_lo -; ------------------------------------------------------------------- - lda (EXO_zp_src_lo),y -; ------------------------------------------------------------------- -._do_literal - ldx EXO_zp_dest_lo - bne _seq_dest_dec_lo - ldx EXO_zp_dest_hi - bne _seq_dest_dec_hi -; ------- handle buffer wrap problematics here ---------------------- - ldx #HI(EXO_buffer_len) - stx EXO_zp_dest_hi - ldx #HI(EXO_buffer_end) - stx EXO_zp_dest_bi -; ------------------------------------------------------------------- -._seq_dest_dec_hi - dec EXO_zp_dest_hi - dec EXO_zp_dest_bi -._seq_dest_dec_lo - dec EXO_zp_dest_lo -; ------------------------------------------------------------------- - sta (EXO_zp_dest_lo),y - clc - rts -} - -; ------------------------------------------------------------------- -; two small static tables (6 bytes) -; -.tabl_bit -{ - EQUB 2,4,4 -} -.tabl_off -{ - EQUB 48,32,16 -} - -; ------------------------------------------------------------------- -; get x + 1 bits (1 byte) -; -._bit_get_bit1 - inx -; ------------------------------------------------------------------- -; get bits (31 bytes) -; -; args: -; x = number of bits to get -; returns: -; a = #bits_lo -; x = #0 -; c = 0 -; EXO_zp_bits_lo = #bits_lo -; EXO_zp_bits_hi = #bits_hi -; notes: -; y is untouched -; other status bits are set to (a == #0) -; ------------------------------------------------------------------- -._bit_get_bits -{ - lda #$00 - sta EXO_zp_bits_lo - sta EXO_zp_bits_hi - cpx #$01 - bcc _bit_bits_done - lda EXO_zp_bitbuf -._bit_bits_next - lsr a - bne _bit_ok - jsr get_crunched_byte - ror a -._bit_ok - rol EXO_zp_bits_lo - rol EXO_zp_bits_hi - dex - bne _bit_bits_next - sta EXO_zp_bitbuf - lda EXO_zp_bits_lo -._bit_bits_done - rts -} -; ------------------------------------------------------------------- -; end of decruncher -; ------------------------------------------------------------------- - - -.exo_end - diff --git a/temp/lib/vgmplayer.h.6502 b/temp/lib/vgmplayer.h.6502 deleted file mode 100644 index e155ebd..0000000 --- a/temp/lib/vgmplayer.h.6502 +++ /dev/null @@ -1,43 +0,0 @@ - -\\ VGM Player module -\\ Include file -\\ Define ZP and constant vars only in here - - - -\ ****************************************************************** -\ * Define global constants -\ ****************************************************************** - -FX_num_freqs = 32 ; number of VU bars - can be 16 or 32 -FX_num_channels = 4 ; number of beat bars (one per channel) - - -\\ Player -PLAYER_string_max = 42 ; size of our meta data strings (title and author) -PLAYER_sample_rate = 50 ; locked to 50Hz - -\ ****************************************************************** -\ * Declare ZP variables -\ ****************************************************************** - -\\ Frequency array for vu-meter effect, plus beat bars for 4 channels -\\ These two must be contiguous in memory -.freq_array SKIP FX_num_freqs -.chan_array SKIP FX_num_channels -.player_reg_vals SKIP SN_REG_MAX ; data values passed to each channel during audio playback (4x channels x pitch + volume) - -\\ Copied out of the RAW VGM header -.player_packet_count SKIP 2 ; number of packets -.player_duration_mins SKIP 1 ; song duration (mins) -.player_duration_secs SKIP 1 ; song duration (secs) - -.player_packet_offset SKIP 1 ; offset from start of file to beginning of packet data - - -\\ Player vars -.player_ended SKIP 1 ; non-zero when player has reached end of tune -.player_data SKIP 1 ; temporary variable when decoding sound data - must be separate as player running on events -.player_last_reg SKIP 1 ; last channel (register) refered to by the VGM sound data -.player_counter SKIP 1 ; increments by 1 every poll (20ms) - used as our tracker line no. & to sync fx with audio update -.player_reg_bits SKIP 1 ; bits 0 - 7 set if SN register 0 - 7 updated this frame, cleared at start of player poll diff --git a/temp/lib/vgmplayer.s.6502 b/temp/lib/vgmplayer.s.6502 deleted file mode 100644 index 4c92f03..0000000 --- a/temp/lib/vgmplayer.s.6502 +++ /dev/null @@ -1,416 +0,0 @@ -\\ VGM Player -\\ Code module -\\ Uses memory &C00-CFF - -\\ Store current assembler address so we can restore later -VGMPLAYER_ORG = * - -\ ****************************************************************** -\ * Space hijacked from OS for runtime buffers not preinitialised -\ ****************************************************************** - -ORG &0c00 + EXO_TABL_SIZE ; soft-key storage -GUARD &0cff - -.player_song_title_len SKIP 1 -.player_song_title SKIP PLAYER_string_max -.player_song_author_len SKIP 1 -.player_song_author SKIP PLAYER_string_max - - -ORG VGMPLAYER_ORG - -.vgm_player_start - -\ ****************************************************************** -\ * VGM music player -\ * Plays a RAW format VGM music stream from an Exomiser compressed data stream -\ ****************************************************************** - -\ * EXO VGM data file -\ * This must be compressed using the following flags: -\ * exomizer.exe raw -c -m 1024 -o - - -\\ Initialise the VGM player with an Exomizer compressed data stream -\\ X - lo byte of data stream to be played -\\ Y - hi byte of data stream to be played -.init_vgm_stream -{ - \\ Initialise exomizer - must have some data ready to decrunch - JSR init_decruncher - - \\ Initialise music player - parses header - JSR init_player - - RTS -} - - -.init_player ; return non-zero if error -{ -\\
-\\ [byte] - header size - indicates number of bytes in header section - - LDA #1 - STA player_packet_offset - - jsr get_decrunched_byte - STA tmp_var - CMP #5 - BCS parse_header ; we need at least 5 bytes to parse! - JMP error - - .parse_header - CLC - ADC player_packet_offset - STA player_packet_offset - -\\ [byte] - indicates the required playback rate in Hz eg. 50/60/100 - - jsr get_decrunched_byte ; should really check carry status for EOF - CMP #PLAYER_sample_rate ; we only support 50Hz files - BEQ is_50HZ ; return non-zero to indicate error - JMP error - .is_50HZ - DEC tmp_var - -\\ [byte] - packet count lsb - - jsr get_decrunched_byte ; should really check carry status for EOF - STA player_packet_count - DEC tmp_var - -\\ [byte] - packet count msb - - jsr get_decrunched_byte ; should really check carry status for EOF - STA player_packet_count+1 - DEC tmp_var - -\\ [byte] - duration minutes - - jsr get_decrunched_byte ; should really check carry status for EOF - STA player_duration_mins - DEC tmp_var - -\\ [byte] - duration seconds - - jsr get_decrunched_byte ; should really check carry status for EOF - STA player_duration_secs - - .header_loop - DEC tmp_var - BEQ done_header - - jsr get_decrunched_byte ; should really check carry status for EOF - \\ don't know what this byte is so ignore it - JMP header_loop - - .done_header - -\\ -\\ [byte] - title string size - - INC player_packet_offset - - jsr get_decrunched_byte ; should really check carry status for EOF - STA tmp_var - - CLC - ADC player_packet_offset - STA player_packet_offset - -\\ [dd] ... - ZT title string - - LDX #0 - .title_loop - STX tmp_msg_idx - LDA tmp_var - BEQ done_title ; make sure we consume all the title string - DEC tmp_var - - jsr get_decrunched_byte ; should really check carry status for EOF - LDX tmp_msg_idx - CPX #PLAYER_string_max - BCS title_loop ; don't write if buffer full - STA player_song_title,X - INX - JMP title_loop - - \\ Where title string is smaller than our buffer - .done_title - STX player_song_title_len - LDA #' ' - .title_pad_loop - CPX #PLAYER_string_max - BCS done_title_padding - STA player_song_title,X - INX - JMP title_pad_loop - .done_title_padding - -\\ <author section> -\\ [byte] - author string size - - INC player_packet_offset - - jsr get_decrunched_byte ; should really check carry status for EOF - STA tmp_var - - CLC - ADC player_packet_offset - STA player_packet_offset - -\\ [dd] ... - ZT author string - - LDX #0 - .author_loop - STX tmp_msg_idx - LDA tmp_var - BEQ done_author ; make sure we consume all the author string - DEC tmp_var - - jsr get_decrunched_byte ; should really check carry status for EOF - LDX tmp_msg_idx - CPX #PLAYER_string_max - BCS author_loop - STA player_song_author,X ; don't write if buffer full - INX - JMP author_loop - - \\ Where author string is smaller than our buffer - .done_author - STX player_song_author_len - LDA #' ' - .author_pad_loop - CPX #PLAYER_string_max - BCS done_author_padding - STA player_song_author,X - INX - JMP author_pad_loop - .done_author_padding - - \\ Initialise vars - LDA #&FF - STA player_counter - - LDA #0 - STA player_ended - STA player_last_reg - STA player_reg_bits - - \\ Return zero - RTS - - \\ Return error - .error - LDA #&FF - RTS -} - -.deinit_player -{ - \\ Zero volume on all channels - LDA #&9F: JSR psg_strobe - LDA #&BF: JSR psg_strobe - LDA #&DF: JSR psg_strobe - LDA #&FF: JSR psg_strobe - - .return - RTS -} - -.poll_player -{ - \\ Assume this is called every 20ms.. - LDA #0 - STA player_reg_bits - - LDA player_ended - BNE _sample_end - -\\ <packets section> -\\ [byte] - indicating number of data writes within the current packet (max 11) -\\ [dd] ... - data -\\ [byte] - number of data writes within the next packet -\\ [dd] ... - data -\\ ...` -\\ <eof section> -\\ [0xff] - eof - - \\ Get next byte from the stream - jsr get_decrunched_byte - bcs _sample_end - - cmp #&ff - beq _player_end - - \\ Byte is #data bytes to send to sound chip: - TAY - .sound_data_loop - BEQ wait_20_ms - TYA:PHA - jsr get_decrunched_byte - bcc not_sample_end - PLA - JMP _sample_end - - .not_sample_end - JSR psg_decode - JSR psg_strobe - PLA:TAY:DEY - JMP sound_data_loop - - .wait_20_ms - INC player_counter ; indicate we have completed another frame of audio - - CLC - RTS - - ._player_end - STA player_ended - - \\ Silence sound chip - JSR deinit_player - - INC player_counter ; indicate we have completed one last frame of audio - - ._sample_end - SEC - RTS -} - -.psg_strobe -{ - sei ; **SELF-MODIFIED CODE** - ldy #255 - sty $fe43 - - sta $fe41 - lda #0 - sta $fe40 - nop - nop - nop - nop - nop - nop - lda #$08 - sta $fe40 - cli ; **SELF-MODIFIED CODE** - RTS -} - -PSG_STROBE_SEI_INSN = psg_strobe -PSG_STROBE_CLI_INSN = psg_strobe + 25 - -.psg_decode -{ - STA player_data - AND #SN_FREQ_BYTE_MASK - BEQ second_byte - - \\ First byte - - \\ Obtain register fields - - \\ Get register from bits 7,6,5 - LDA player_data - AND #SN_REG_MASK - LSR A:LSR A:LSR A:LSR A - STA player_last_reg - - \\ Y is our register number - TAY - - \\ Set bit field for each register used this frame - LDA num_to_bit,Y ; look up bit for reg number - ORA player_reg_bits ; mask in bit - STA player_reg_bits - - \\ Is this tone or volume register? - TYA - AND #&01 - BEQ process_tone_data - - \\ Volume data - LDA player_data - AND #SN_VOL_MASK - STA player_reg_vals,Y - - \\ Invert volume (0 = max 15 = off) - SEC - LDA #SN_VOL_MAX - SBC player_reg_vals,Y - STA player_reg_vals,Y - JMP return - - \\ Frequency / tone data - .process_tone_data - CPY #SN_REG_NOISE_CTRL ; Y already register number - BNE tone_channel - - \\ Noise channel - LDA player_data - AND #(SN_NF_MASK OR SN_FB_MASK) ; store noise freq data - STA player_reg_vals,Y - - JMP trigger_beat - - .tone_channel - LDA player_data - AND #SN_FREQ_FIRST_BYTE_MASK ; F3 - F0 - LSR A: LSR A ; lose bottom 2 bits - STA player_reg_vals,Y - - .trigger_beat - \\ trigger the beat effect for this channel - TYA:LSR A:TAY ; channel is register / 2 - LDA #9 - STA chan_array, Y - - JMP return - - .second_byte - LDA player_data - AND #SN_FREQ_SECOND_BYTE_MASK ; F9 - F4 - STA tmp_var - ASL A: ASL A ; put 6 bits to top of byte - LDY player_last_reg - ORA player_reg_vals,Y ; combine with bottom 2 bits - STA player_reg_vals,Y - - \\ trigger the beat effect for this channel -; technically correct, but better visuals without this. -; TYA:LSR A:TAY ; channel is register / 2 -; LDA #9 -; STA chan_array, Y - - LDA tmp_var -IF FX_num_freqs == 16 - \\ 16 frequency bars, so use top 4 bits - LSR A : LSR A -ELSE - \\ 32 frequency bars, so use top 5 bits - LSR A -ENDIF - - \\ clamp final frequency to array range and invert - AND #FX_num_freqs-1 - STA tmp_var - LDA #FX_num_freqs-1 - SEC - SBC tmp_var - TAX - LDA #15 - STA freq_array,X - - .return - LDA player_data - RTS -} - - - -.vgm_player_end -