News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_Cwiiis

Booting from a cart on a GX4000

Started by Cwiiis, 16:25, 30 January 24

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Cwiiis

I'm having an issue now where my game works fine as a .cpr running from a C4CPC but doesn't work when burnt as binary to a ROM. I've verified that the EPROM and PCB are good by burning other ROMs and I've verified that the binary of my .cpr is correct. Indeed, converting it back to a .cpr results in a ROM that works fine in emulators (which is making debugging basically impossible...)

My presumption is that I'm missing some initialisation or relying on uninitialised memory being zeroed or something like this that wouldn't show up in an emulator, or when running from C4CPC (which will do its own initialisation), but does show up when running direct on real hardware.

My game boots, does the usual initialisation and copies the program code into RAM, it doesn't do anything fancy or special. Here's the bootloader:


      ORG &00

          di
          im 1
          ld sp,&C000-3 ; We bank in C000, put stack before that
          jp Start

EnablePlusSeq
      BYTE &FF,&00,&FF,&77,&B3,&51,&A8,&D4
      BYTE &62,&39,&9C,&46,&2B,&15,&8A,&CD,&EE

          ; ROM interrupt handler
      SKIP &38-$
          ei
          ret

Start
          ; Initialise ppi
          ld bc,&F782
          out (c),c
          ld bc,&F400
          out (c),c
          ld bc,&F600
          out (c),c

          ; Configure ram (redundant?)
          ld bc,&7FC0
          out (c),c

          ; Enable Plus features
          ld hl,EnablePlusSeq
          ld b,&BC
          ld e,17
EnablePlusLoop
          ld a,(hl)
          out (c),a
          inc hl
          dec e
          jr nz,EnablePlusLoop

          ; Install a just-return interrupt handler
          ld hl,&C9FB
          ld (&38),hl

          ; Copy bootstrap to ram
          ld hl,BootstrapStart
          ld de,BootstrapStart
          ld bc,BootstrapEnd-BootstrapStart
          ldir

BootstrapStart
          ; Put bank 1 at &8000
          ld bc,&7FB1   ;%10110001
          out (c),c

          ; Copy bank 1 to ram
          ld hl,&8000
          ld de,&8000
          ld bc,&4000
          ldir

          ; Unmap lower rom bank
          ld bc,&7FA0   ;%10100000
          out (c),c

          ; Unmap upper and lower banks, set mode 1
          ld bc,&7F8D
          out (c),c

          jp &8000
BootstrapEnd

I've looked at what a few other games do in WinAPE's disassembler and haven't spotted what I'm doing differently (and what I do does work in WinAPE). Anyone got any ideas? Perhaps I'm making a bad assumption about the CRTC setup - I set registers 1, 2, 3, 6, 7, 12 and 13... I was under the impression that there are default values for the others, but I guess that might just be when running from firmware and I should set *all* the registers? Going to try that.

Cwiiis

Yes, that was the issue. Don't forget to set all your CRTC registers, folks! :picard:

asertus

Which are all default values? are they documented anywhere?

roudoudou

Quote from: asertus on 17:28, 30 January 24Which are all default values? are they documented anywhere?
yep, on cpcwiki :)

default values are for AMSDOS prompt after init, the real default values are bad anyway

https://www.cpcwiki.eu/index.php?title=CRTC
My pronouns are RASM and ACE

andycadley

Yeah, as far as I know all the CRTC registers are effectively random at start up. Generally with the Plus machine I found it better to assume that about everything because you're booting into completely bare hardware.

Powered by SMFPacks Menu Editor Mod