Forums

Sega Master System / Mark III / Game Gear
SG-1000 / SC-3000 / SF-7000 / OMV
Home - Forums - Games - Scans - Maps - Cheats - Credits
Music - Videos - Development - Hacks - Translations - Homebrew

View topic - Why is it jumping to vector $0038? [Solved, VDP related]

Reply to topic
Author Message
  • Joined: 01 Mar 2022
  • Posts: 8
Reply with quote
Why is it jumping to vector $0038? [Solved, VDP related]
Post Posted: Mon Nov 27, 2023 9:23 pm
Last edited by xX_Pokeman2003_Xx on Mon Nov 27, 2023 10:28 pm; edited 2 times in total
Problem: Please do not forget that the IRQ line is set to vector $0038, and is called EVERY line interrupt so long as it is active.

Original Post:
Okay, so this is a bit of a stupid question. Basically, RST $08 is operating differently if I turn on or off the BIOS: It operates as I expect if I have the BIOS off, but if I turn on the BIOS, both interrupts just jump to $0038.
Programmatically, I have a ROM that looks quite a bit like this.

.MEMORYMAP
   DEFAULTSLOT 0
   SLOTSIZE $4000
   SLOT 0 $0000      ; ROM bank 0
   SLOT 1 $4000      ; ROM bank 1
   SLOT 2 $8000      ; ROM bank 2
   SLOT 3 $C000 $2000   ; RAM map
.ENDME

.ROMBANKMAP
   BANKSTOTAL 1
   BANKSIZE $2000
   BANKS 1
.ENDRO
; Fixed ROM space, before the actual initialization.

.BANK 0 SLOT 0
.SECTION "Initialization" FORCE ORG $0000 NAMESPACE "FixedBank"
   di      ; Disable interrupts.
   im 1   ; Interrupt mode 1.
   jp programStart
.ENDS

.SECTION "Interrupt 08" FORCE ORG $0008 NAMESPACE "FixedBank"
; RAM Clear.
   ; call programStart ; Temporarily replaced with placeholder.
   reti
.ENDS

.SECTION "Interrupt 10" FORCE ORG $0010 NAMESPACE "FixedBank"
; VRAM Clear.
   call programStart ; Temporarily replaced with placeholder.
   reti
.ENDS

.SECTION "Interrupt 18" FORCE ORG $0018 NAMESPACE "FixedBank"
   call $0000
   reti
.ENDS

.SECTION "Interrupt 20" FORCE ORG $0020 NAMESPACE "FixedBank"
   call $0000
   reti
.ENDS

.SECTION "Interrupt 28" FORCE ORG $0028 NAMESPACE "FixedBank"
   call $0000
   reti
.ENDS
   
.SECTION "Interrupt 30" FORCE ORG $0030 NAMESPACE "FixedBank"
   call $0000
   reti
.ENDS

.SECTION "Interrupt 38" FORCE ORG $0038 NAMESPACE "FixedBank"
   call $0000
   reti
.ENDS

.SECTION "NMI Interrupt" FORCE ORG $0068 NAMESPACE "FixedBank"
NMI:
   retn
.ENDS

.SECTION "Program Start" APPENDTO "NMI Interrupt" WINDOW $0000 $03FF NAMESPACE "FixedBank"
programStart:
   ; Initialize begin.
   ei
   ld sp, $DFFF
   rst $08   ; Clear RAM.
   rst $10   ; Clear VRAM.
   jr programStart
.ENDS

.SMSHEADER
.ENDSMS

All of this works "fine and dandy" without a BIOS. RST $08 and RST $10 jump to their respective interrupt vectors without an issue.
This stops working when you introduce the BIOS, at which point this assembled ROM starts jumping to vector $0038 when it hits RST $08. I cannot figure out why this is happening, but it is very frustrating to say the least. I cannot diagnose the problem either, because it only happens when I enable the US 1.3 BIOS, a ROM I know nothing about. I have zero clue on what it's doing in the background to suddenly break something that worked totally fine a minute ago.

If it helps to track down the problem, I am using WLA-dx version 10.5, the BIOS ROM is found here.
  View user's profile Send private message
  • Joined: 06 Mar 2022
  • Posts: 671
  • Location: London, UK
Reply with quote
Post Posted: Mon Nov 27, 2023 10:00 pm
Sorry to ask the obvious, but you're sure you're not seeing the VDP interrupt firing and taking you to $38, rather than your executing code? The VDP interrupt ought to be enabled on startup (possibly by the BIOS) and you are also calling `ei` so based on the code you posted I would expect interrupts to $38 to be occurring.
  View user's profile Send private message Visit poster's website
  • Joined: 01 Mar 2022
  • Posts: 8
Reply with quote
Post Posted: Mon Nov 27, 2023 10:16 pm
I do not think there is any way I could possibly word my frustrations towards myself for not missing such a bleedingly obvious problem in my thinking without getting banned on this platform.
willbritton wrote
Sorry to ask the obvious, but you're sure you're not seeing the VDP interrupt firing and taking you to $38, rather than your executing code?

I haven't tested it yet, but I am almost positive this is the problem. This is my first time messing with the VDP outside of some documentation reading, so I completely spaced that it had its own interrupt.
  View user's profile Send private message
  • Joined: 06 Mar 2022
  • Posts: 671
  • Location: London, UK
Reply with quote
Post Posted: Mon Nov 27, 2023 10:22 pm
xX_Pokeman2003_Xx wrote
I do not think there is any way I could possibly word my frustrations towards myself for not missing such a bleedingly obvious problem in my thinking without getting banned on this platform.
willbritton wrote
Sorry to ask the obvious, but you're sure you're not seeing the VDP interrupt firing and taking you to $38, rather than your executing code?

I haven't tested it yet, but I am almost positive this is the problem. This is my first time messing with the VDP outside of some documentation reading, so I completely spaced that it had its own interrupt.

Haha, no worries. Frustration goes with the territory, and if you're just starting out with the VDP there's plenty more to come I guarantee 😅

And you'd be surprised how hard it is to get banned from this platform 🤣
  View user's profile Send private message Visit poster's website
  • Joined: 01 Mar 2022
  • Posts: 8
Reply with quote
Post Posted: Mon Nov 27, 2023 10:32 pm
willbritton wrote
Haha, no worries. Frustration goes with the territory, and if you're just starting out with the VDP there's plenty more to come I guarantee 😅

Oh yeah, I'm aware. I'm still struggling to try to understand how WLA-dx's directives all work. I thought until recently that slot was a hole IN the bank, not a hole for the bank.
willbritton wrote
And you'd be surprised how hard it is to get banned from this platform 🤣

With all due respect, I don't think they want me testing their limits by using every slur I can possibly think of :P
After a quick search though, I have noticed that they seem a little looser with language restrictions than other forums though, which is great!
Misremembering a study's statistics, I remember that code that had programmers swearing in the comments was on average 40% better than code written by programmers who were not allowed to swear.
  View user's profile Send private message
Reply to topic



Back to the top of this page

Back to SMS Power!