|
Post by AndyJF on Dec 12, 2019 9:32:33 GMT
I've got my basic loader working so it loads a loading screen and then loads and executes my AGD game. What I'd like to do now is create an intro menu screen in the BASIC loader for defining keys etc. Is there a way to access the font and / or the graphics blocks in the AGD code from within BASIC? Thanks.
|
|
|
Post by alessandro on Dec 12, 2019 12:07:55 GMT
Hi Andy, yes there is, the custom character set in AGD v4.x is always located at 31232. In order to employ it you must insert these BASIC commands in your program after you have loaded (and decompressed, if you used data compression) your AGD game:
RANDOMIZE 31232 : POKE 23606, PEEK 23670 : POKE 23607, PEEK 23671-1
The current character set will then be substituted by that embedded in the game.
As for the blocks, their location changes. AGDX lets you know where they are stored in memory, but if I remember correctly, they are stored pixels first, then attributes, like the screen image. So be careful!
|
|
|
Post by AndyJF on Dec 12, 2019 12:51:20 GMT
That's great, thank you
|
|
|
Post by AndyJF on Dec 13, 2019 12:44:29 GMT
Hi Alessandro. I tried the above but it didn't work, I was getting out of memory errors. After a bit of googling, I've managed to get it to work with a single poke - POKE 23607, 121. This seems to work fine, do you think I will run into any problems doing it this way? How did you arrive at the above values?
Edit - I think I've figured it out. Is it like making the asm calls in AGD? You have two values - the INT of the address(-256) divided by 256 and the the remainder value? I've managed to redirect the UDGs in BASIC to their address in the AGD code too. So all seems to be working, thanks
|
|
|
Post by alessandro on Dec 13, 2019 17:29:51 GMT
Hi Andy, as per the Spectrum BASIC programming manual, Chapter 25, if you need to modify a two-byte value in memory, you have to POKE the two memory locations containing the least significant byte first, followed by the most significant byte. This byte order is called "little-endian". That is the reason behind the two values in ASM instructions in AGD script, besides ASM 205 which is the code for the Z80 Assembly CALL instruction. The syntax I provided you always worked for me, it inserts the needed value (31232) in the SEED system variable located at address 23670, in order to change the current character set, by poking the values at 23606 and 23607, which hold the two bytes of the address of the current character set minus 256 - this is conventionally referred to as the CHARS system variable. However, since (31232-256)/256 = 121, you could also simply enter POKE 23607,121 and it should work too.
|
|
|
Post by AndyJF on Dec 13, 2019 17:42:33 GMT
That's the page I eventually got the formula from, it works for both redirecting the font and the UDGs. Anyway, it works so I'm really pleased about that! Thanks.
|
|
|
Post by Jonathan Cauldwell on Dec 13, 2019 20:44:28 GMT
One other option you might want to consider next time might be to import an AGD game into MPAGD and write a redefine keys routine in that if you find it easier. In fact, if you start your game in MPAGD it can automatically generate a routine for you in your menu.
|
|