Talking about MSX1 vdp:
After a HALT I'm in Vblank, right?
May I use OTIR to send data to vram or I have to use OUTI anyway?
Aangemeld of registreer om reacties te plaatsen
Talking about MSX1 vdp:
After a HALT I'm in Vblank, right?
May I use OTIR to send data to vram or I have to use OUTI anyway?
You can’t rely on just HALT to determine if you’re in vblank, since other interrupts may be active (though usually not). Poll the JIFFY system variable; if it changes, then a vblank interrupt has occurred.
I’m pretty sure during vblank you can access the VRAM at full speed. Even unrolling OTIR to OUTIs may work. Of course, you should test this on real hardware. If you test in an emulator, make sure to use openMSX because it has VDP timing limitations implemented which approach the real hardware pretty well.
Thank you! How can I poll JIFFY? Where is this system variable? Where I can find infos? Is any article in your site? (I like msx assembly page, so if there's what I need I'll go read there...)
Poll the JIFFY system variable; if it changes, then a vblank interrupt has occurred.
Ah yes.. nice one.
Thank you! How can I poll JIFFY? Where is this system variable?
JIFFY is a 16 bit counter found at FC9Eh, this address can eg. be found in the MSX Technical Data Book. BIOS interrupt routine (0038h) reads VDP's status register. When that indicates no VDP interrupt, then the interrupt routine doesn't do much. If it indicates a VDP interrupt, then (among other things) this JIFFY counter is increased. Tbh I don't know the exact purpose for this counter, but for programmers it's sometimes useful have a constant speed, auto-updated counter.
You don't need to use the full 16 bit value (or the exact value), just checking that it's changed from before an interrupt occurred should do. And since coding for the Z80, low byte comes first in memory. So in assembly you might do something like this:
(note - untested!)
JIFFY: equ 0FC9Eh
(do other stuff before waiting for vertical blank)
.
.
ld hl,JIFFY
ld a,(hl)
wait_vblank
halt ; execution continues after some interrupt occurred
cp (hl) ; counter changed from before?
jr z,wait_vblank ; no change -> interrupt, but from elsewhere than VDP
.
.
(do your vertical blank stuff)
Edit: just realized the HALT may not even be needed...
Thank you! How can I poll JIFFY? Where is this system variable? Where I can find infos? Is any article in your site? (I like msx assembly page, so if there's what I need I'll go read there...)
There are various places with overviews of BIOS function call and system variables:
http://map.grauw.nl/resources/msxsystemvars.php
https://www.msx.org/wiki/System_variables_and_work_area
https://www.konamiman.com/msx/msx2th/th-ap.txt
http://map.grauw.nl/resources/system/msxtech.pdf
Tbh I don't know the exact purpose for this counter, but for programmers it's sometimes useful have a constant speed, auto-updated counter.
It’s one of the most used system variables I’d say. It backs Basic’s TIME variable. And in general it’s useful for time-keeping, if you want to measure how long something takes, or do something every x frames, etc. Note MSX1 has not RTC, and the MSX2 RTC only has seconds precision...
openMSX isn't the only emulator that accurately models VDP access timing, for the record, but vanity aside: the JIFFY count is really useful if you're writing a game which runs at anything below the output frame rate. You run a loop like:
atomically read 16-bit JIFFY count;
compute difference with previous JIFFY count;
run that number of logic updates;
produce an output frame;
repeat;
16-bit is overkill, but my standard practice on a Z80 machine when hacking around with 3d rendering is always step one: establish an interrupt handler that just counts the number of frames ended.
I see. i have a LOT to learn! Thank you all for your hints!
Don't you have an account yet? Become an MSX-friend and register an account!
