Issue with re-enabling amsdos when Arkos Player used

Started by bart71, 11:13, 25 July 25

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

bart71

Hello
In fact it is a continuation of my previous thread https://www.cpcwiki.eu/forum/software-related/problems-with-loading-next-game-level/ but as it is a problem of different matter (the issue described there has been actually solved) - decided to open a new one.

Basically I am trying to load next game level and things generally work - next part of the game is loaded using mc_boot_program firmware routine.

All works on condition that I disable music playback on the "parent" game level. 
Game is written using cpctelera and uses Arkos Tracker player

I use tihis code to load next level:

.area _LOADER (ABS)
;;_loadlevel::
.org 0xA650
_loadlevel::
  ;;himem equ #0xb0ff
  ld c,#0xff          ;; disable all roms
  ld hl, #_dummy         ;; execution address for program
  call #0xbd16  ;;mc_start_program    ;; start it
  _dummy:: nop
  call _initialise_amsdos
  ;call #0xbccb  ;;kl_rom_walk     ;; enable all roms
   
    ld c,#0x07
    ld de,#0x40
    ld hl,#0xb0ff
    call #0xbcce
    ld hl,#_loader
    call #0xbd13 ;;mc_boot_program
    _loader:: ;; this is a loader which loads fileto specific address and returns start addr in (HL)
    ;;call #0xbccb
    ld b, #10 ;;filename length
    ld hl,#filename ;;pointer to filename string
    ld de, #0x0 ;; 2k buffer - anything in this case
    call #0xbc77 ;;cas_in_open
    ;
    LD L, #0x00
    LD H, #0x01
    ;; read file
    call #0xbc83 ;;cas_in_direct
    ;; firmware function to close a file opened for reading
    call #0xbc7a ;;cas_in_close
    ;;LD L, #0xf7
    ;;LD H, #0x9e for LEVEL2
    LD L, #0x62
    LD H, #0xa1
    ;;scf
    ret
    _initialise_amsdos::
    ld hl,(#0xbe7d)       ;Get address where current drive number is stored
    inc hl              ;Move forward 2 bytes to the address where the drive
    inc hl              ;number of the most recently loaded file is stored
    ld a,(hl)           ;Get drive number (A = 0, B = 1)
    push af             ;Store drive number on the stack
    ld de,#0x40
    ld hl,#0xb0ff         ;Highest usable byte of memory
    ld c,#7              ;AMSDOS ROM is located in slot 7
    call #0xbcce          ;Initialise the selected ROM
    pop af              ;Get drive number
    ld hl,(#0xbe7d)       ;Get new address where drive number is stored
    ld (hl),a           ;Set drive number
    ret
    filename: .asciz "LEVEL3.BIN"
   
  

commenting out PlaySound() in interrupt handler makes it working:

void sInterruptHandler(void)
{
   static u8 sInterrupt = 0;
   // Play sound at 1/50th
   if (++sInterrupt == 6)
   {
      //PlaySound();
      // cpct_scanKeyboard_if();
      sInterrupt = 0;
   }
   cpct_scanKeyboard();
   //if (intro)
   //{
   if (cpct_isAnyKeyPressed()) {graj=1;}
   //}
}

...
cpct_reenableFirmware(firmwareptr);
    loadlevel();


As loading next level is a complete reload, I don't think it is required to restore any registers or stack pointer or anything?
Looks like firmware/amsdos is not fully restored, can I add anything to my loader to force full enablement?
I am quite new to assembler / firmware programming for CPC, any help or suggestins highly appreciated :-)




Powered by SMFPacks Menu Editor Mod