asMSX
asMSX copied to clipboard
MEGAROM and ORG directive Just Won't Splice
Title origin: link
Exemple code
;Uncomment next line and...BOOM!
;USE38 = 1; to use 38h as interruption hook
;Comment next line if you uncomment line before.
USE38 = 0; to use 0FD9Fh as interruption hook
ZILOG
BIOS
MEGAROM KonamiSCC
START THEGAME
db "The Game is not The Game"
IF USE38 == 1
ORG 38h
db 0C3h
dw TIMER_RUTINE
ENDIF
THEGAME:
ei
halt
di
SEARCH
ld SP,PILA
SELECT 1 AT 06000h
SELECT 2 AT 08000h
SELECT 3 AT 0A000h
call TIMER_INI
xor A
ld (BGCOLOR),A
ei
LOOP_THEGAME:
halt
ld A,(BGCOLOR)
inc A
and 0Fh
ld (BGCOLOR),A
call COLORBR
jr LOOP_THEGAME
SUBPAGE 1 AT 06000h
db 1
COLORBR:
out (099h),A
ld A,87h
out (099h),A
ret
SUBPAGE 2 AT 08000h
db 2
TIMER_INI:
ld HL,0FD9Fh
ld BC,TIMER_RUTINE
ld (HL),0C3h
inc HL
ld (HL),C
inc HL
ld (HL),B
ret
TIMER_RUTINE:
push AF
push BC
push DE
push HL
push IX
push IY
in A,(99h) ; acknowledge?
;NO BIOS. This "in" RESET EI.
nop ; thing to do here
pop IY
pop IX
pop HL
pop DE
pop BC
pop AF
ld A,1
call COLORBR
IF USE38 == 1
ei
reti
ELSE
ret
ENDIF
SUBPAGE 3 AT 0A000h
db 3
nop ; thing to do here
BUILDPAGES = 4
REPT 59
SUBPAGE BUILDPAGES AT 0A000h
db BUILDPAGES
BUILDPAGES = BUILDPAGES + 1
ENDR
PAGE 3 ; RAM
PILA0:
ds 256
PILA: byte
BGCOLOR: byte
And with MEGAROM directive you can't use PAGE 0, PAGE 1 or PAGE 2. If you use it asmsx says:
code/data without subpage
PAGE 3 yes. No problem.
I got a SEGFAULT. Nice.
Maybe we can throw an error when using PSEUDO_ORG when if(megarom && addr < LIMIT_ADDR). We have to decide which is LIMIT_ADDR.
This also crashes (Super minimal example):
MEGAROM KonamiSCC
ORG 38h
db 0C3h
The code is incorrect. With MEGAROM 38h hook cannot be used.
A PRENDRE PEL CUL.