2020-07-28
After last week’s failure in sound this week(end) was a total win over sound 💪
I knew the game played better with some audible feedback and I also knew that the only way I could pull it off in NextBASIC was to use the interrupt handler at the machine code level. I’d previously tried and failed with im 2
but this time I looked at the native DRIVER
support that NextOS offers a hook in to the im 1
interrupt.
The short version is, once I groked the border example I managed to port the AYFX player from Shiru to a driver.
The bulk of my code involved handling the driver calls and make sure to swap in the user bank during the routines and swap back to the original bank into the slot I was using.
I made some silly mistakes in the code, but managed to debug successfully using Cspect, things like ld a, (addr)
must be read (and thought of) as “load a with addr” (and not “load a into addr”!).
My bank swapping code looks like this:
MMU6_C000_NR_56 equ $56
; ************************************************
; backup_bank
; Take the current bank in MMU 6 and store the value
; in (active_bank) for later restore.
; ************************************************
backup_bank:
push af ; make a backup of A
ld bc, $243b ; select NEXT register
in a,(c) ; save register state
ld (saved_reg), a
ld a, MMU6_C000_NR_56
out (c),a
inc b ; $253b to access (read or write) value
in a,(c)
ld (active_bank),a
dec b ; $243B
ld a,2
saved_reg equ $-1 ; this points saved_reg to the `2` above
out (c),a ; just in case IRQ was in between registry work
pop af
ret
; ************************************************
; activate_user_bank
; Switches in a user defined bank into MMU6
; ************************************************
activate_user_bank:
call backup_bank
ld a, (ayfx_bank)
nextreg MMU6_C000_NR_56, a
ret
; ************************************************
; restore_bank
; Returns the bank slot to it's original setting
; ************************************************
restore_bank:
ld a, (active_bank)
nextreg MMU6_C000_NR_56, a
ret
The result: uninterrupted game play with sound effects 🎉
Now the bug list is looking pretty small, the priority is a graphics glitch on level 4 (which can also be seen at the end of the game over on the letter “E”), then the scoring system (with high scores) and then… and then we’re there.
Get Go Mummy! (ZX Spectrum Next)
Go Mummy! (ZX Spectrum Next)
ZX Spectrum Next clone/reimagination/upgrade of Amsoft's Oh Mummy from the CPC 464
Status | Released |
Author | rem |
Genre | Survival |
Tags | nextbasic, Retro, specnext, spectrum-next, zx-next, zxnext, ZX Spectrum, zx-spectrum-next |
More posts
- Fin - 2020-08-25Aug 25, 2020
- 2020-08-09Aug 09, 2020
- 2020-07-20Jul 20, 2020
- 2020-07-07Jul 07, 2020
- 2020-06-25Jun 29, 2020
- 2020-06-15Jun 15, 2020
- 2020-06-07Jun 08, 2020
- 2020-06-03Jun 08, 2020
- 2020-06-01Jun 01, 2020
Leave a comment
Log in with itch.io to leave a comment.