nataliapc

SDCC/ASM. Play BASIC PLAY sentence from MSX-DOS

Sep 8th, 2024 (edited)
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Z80 Assembler 1.22 KB | Source Code | 0 0
  1. // by NataliaPC (@ishwin74)
  2. void basic_play(void *params) __naked __sdcccall(1)
  3. {
  4.     params;
  5.     __asm
  6.         push hl                                     ; Store the Param 'params'
  7.  
  8.         ld   hl, #.play_call                        ; Copy routine to _heap_top
  9.         ld   de, (_heap_top)                        ; _heap_top must be >= 0x8000
  10.         ld   bc, #.play_call_end - .play_call
  11.         ldir
  12.  
  13.         pop  hl                                     ; Copy the PLAY sentence from 'params'
  14.         push de                                     ; Store the start of PLAY sentence
  15.         ld   bc, #80                                ; Max length of PLAY sentence
  16.         ldir
  17.  
  18.         ld   ix, (_heap_top)
  19.         jp   (ix)
  20.  
  21.     .play_call:
  22.         pop  hl                                     ; Recover the start of PLAY sentence
  23.  
  24.         di                                          ; Store current slot configuration
  25.         in   a,(0xa8)
  26.         push af
  27.         and  #0b11110000                            ; Set ROMs pagination
  28.         ei
  29.         out  (0xa8),a       // TODO: take care of subslots
  30.  
  31.                             // TODO: hardcoded. Read (0x39AE) to get the PLAY address
  32.         call 0x73e5                                 ; HL = parameters for PLAY as Asciiz
  33.  
  34.     .wait_loop:
  35.         ld   hl, #VCBA
  36.         ld   a, (hl)
  37.         inc  hl
  38.         or (hl)
  39.         ld   hl, #VCBB
  40.         or (hl)
  41.         inc  hl
  42.         or (hl)
  43.         ld   hl, #VCBC
  44.         or (hl)
  45.         inc  hl
  46.         or (hl)
  47.         jr   nz, .wait_loop
  48.  
  49.         pop  af
  50.         di
  51.         ei
  52.         out  (0xa8),a       // TODO: take care of subslots
  53.         ret
  54.  
  55.     .play_call_end:
  56.     .play_sentence:
  57.     __endasm;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment