[HELP ME] I'm having a weird jump when writing to the VDP Mode Register 1

Page 1/2
| 2

By tsMKG

Resident (48)

tsMKG's picture

11-02-2018, 04:10

Hello, as y'all know, I'm learning assembly, and thing were going good (I've had a moving sprite previously).

But now, in my objective of initialize the graphics and video modes, I am stuck with this problem: After disabling the display, and doing some things (clearing up the VRAM with $00 and loading graphics in it) , when I go to enable the display again through VDP Register 1, I get kicked out of the out instruction and instead directly jump to somewhere VERY early (maybe one of the BIOS routines). Strangest of all is that then sometime I get back, and continue the program, only that the writing to the VDP register 1 has been skipped, not letting me display the elements and as a result, the display is still disabled.
The error occurs somewhere around here:

and here's a video of me debugging the program:
https://youtu.be/JHbAVeNsquE
(The jump occurs around the 0:50 mark)

Any help? Also, I'm using SJASM

Late edit: Oh, I also forgot to say this:
IDEFINE SetVDPRegister(value,reg) ld b,value\ ld e,reg+128\ out (c),b\ nop\ out (c),e\ nop

Login or register to post comments

By TomH

Champion (335)

TomH's picture

11-02-2018, 04:57

You've checked that one of your subroutines doesn't inadvertently leave interrupts enabled? Is the jump into the BIOS to 0038h?

By tsMKG

Resident (48)

tsMKG's picture

11-02-2018, 05:18

From what I remember, even disabling the interrupts (with di) just before writing to VDP Register 1 would still jump me to 0038h Evil

That's what's annoying: not being get rid of that jump even with the interrupts disabled.

I have a video prepared, I'll upload it in a moment.

By tsMKG

Resident (48)

tsMKG's picture

11-02-2018, 05:23

Apparently, it kinda solved the situation but the screen is still blank and now jump when it gets to ei.

By tsMKG

Resident (48)

tsMKG's picture

11-02-2018, 05:37

The video I promised tho:
https://youtu.be/IkdjK249P8I

Also, the extended source code:
https://mega.nz/#F!F7AVhCxR!WIL3Y3ZOXA6bC42jRdT2XQ

By Victor

Champion (509)

Victor's picture

11-02-2018, 05:57

Changes:

SetVDPRegister(value,reg)
ld b,value\ ld e,reg+128\ di \ out (c),b\ nop\ ei\ out (c),e\ nop

By tsMKG

Resident (48)

tsMKG's picture

11-02-2018, 05:59

Why the ei though? oO

By Victor

Champion (509)

Victor's picture

11-02-2018, 06:06

tsMKG wrote:

Why the ei though? oO

The interrupts have to be disabled ONLY when you're writting to the VDP registers.... If you have that as a subroutine, I think that you'll like the process works correctly after that.. Right??

If you're not sure about the VDP routines, you can take the BIOS calls...

By tsMKG

Resident (48)

tsMKG's picture

11-02-2018, 19:32

I know about that, the writes are all done when the Interrupts are disabled. And your solution didn't help much, it's still blank though an OpenMSX VRAM dump indicates that I have written the data correctly (three different background colours for each section of the screen).

Strangest enough even the ENASCR bios call still displays a blank screen, I might have messed up something really bad.

I'll link the new source files when they're done uploading.

By tsMKG

Resident (48)

tsMKG's picture

11-02-2018, 19:34

By Grauw

Ascended (10699)

Grauw's picture

11-02-2018, 19:51

According to the debug window in the middle, interrupts are enabled (it says EI in the flags area). So you’re just getting a regular interrupt service request, the CPU jumps to 38H.

So I guess the question is, why are interrupts enabled? Guess one of the routines before enables it.

In general I find it good practice to always leave the interrupts enabled, and only disable them briefly when it is necessary. So, to not keep interrupts disabled for extended periods of time. That way, the code can just work based on the assumption that interrupts are enabled, rather than it being sometimes-enabled-sometimes-not.

Page 1/2
| 2