|
Post by alchemist on Sept 27, 2017 9:20:12 GMT
Hi everyone How can i redefine keys in my game (after game starts, i mean)? And where? Intro/menu event or Game initialisation event? Thanks
|
|
|
Post by alessandro on Sept 29, 2017 15:55:16 GMT
Redefine keys routines must be executed externally before you start the game, or called with an ASM 205 command placed in the Intro/menu event.
First of all you must take memory locations for keys into account. In AGD 4.0-4.6, keys are located at the following addresses:
Right 35331 Left 35332 Down 35333 Up 35334 Fire 35335 Custom 1 35336 Custom 2 35337 In 4.7 they have been changed as follows:
Right 35339 Left 35340 Down 35341 Up 35342 Fire 35343 Custom 1 35344 Custom 2 35345 In my first games I used a BASIC subprogram which did the job but was rather slow and prevented the user to select some keys like CAPS and SYMBOL SHIFT. Then I adapted an existing Assembly routine, far quickier and without that limitation. So far I used it for Seto Taisho Vs Yokai, Seto Taisho To Kazan and two other projects I cannot tell anything more about at the moment. The key location addresses are those for v4.7, if you wish to employ it for a title created with a previous version of AGD you must substitute the value of KEYS with 35331.
KEYS EQU 35339
LD HL, KEYS LD B,7 CLEARKEYS: LD (HL),255 INC HL DJNZ CLEARKEYS ; clear previous key values
LD HL, 30543 CALL LOOP LD (KEYS+1),A ; redefine left
LD HL, 30520 CALL LOOP LD (KEYS),A ; redefine right LD HL, 30561 CALL LOOP LD (KEYS+3),A ; redefine up LD HL, 30561 CALL LOOP LD (KEYS+2),A ; redefine down LD HL, 30568 CALL LOOP LD (KEYS+4),A ; redefine fire
LD HL, 30577 CALL LOOP LD (KEYS+5),A ; redefine custom 1
LD HL, 30577 CALL LOOP LD (KEYS+6),A ; redefine custom 2 RET ; exit LOOP: CALL 654 LD A,E INC A JR Z,LOOP LD B,05 LD HL,KEYS LD A,E LOOP_1: CP (HL) JR Z, LOOP INC HL DJNZ LOOP_1 RET
Then, supposing your routine is located at address 55000, you could call it from within AGD by putting the following lines in the Intro/menu event:
ASM 205 ASM 216 ASM 214
|
|
|
Post by alchemist on Oct 2, 2017 15:38:32 GMT
Thanks
|
|
|
Post by alchemist on Nov 29, 2017 16:56:36 GMT
Hi Alessandro, it works fine. I can redefine keys in my game now Thanks!
|
|
|
Post by lukebord1 on Mar 30, 2018 19:43:00 GMT
Hi Alessandro... can you please explain the meaning of the memory addresses loaded into HL (30520,30543,30561,30561,30568,30577,30577)? Also, a couple of them seem duplicated. I tried this short routine (one for each key), and it works without the "LD,30520" before the CALL LOOP:
org ... KEYS EQU 35339
LD HL, KEYS ; right (KEYS+1=left, KEYS+2=down, etc) LD (HL),255 ; clear key
CALL LOOP LD (KEYS),A ; redefine right (KEYS+1=left, KEYS+2=down, etc) RET
LOOP: CALL 654 LD A,E INC A JR Z,LOOP LD B,6 ; number of keys to check LD HL,KEYS LD A,E LOOP_1: CP (HL) JR Z, LOOP INC HL DJNZ LOOP_1 RET
|
|
|
Post by alessandro on Apr 1, 2018 13:49:45 GMT
Hi Luca,
these were arbitrarily chosen locations in unused memory space, working as a buffer. The most recent version of the routine - as implemented in my latest titles - uses a fixed location instead, which also serves for other uses, e.g. the sorting of scores for the high score table.
|
|
|
Post by picachu on Apr 16, 2018 7:03:48 GMT
Hi, I'm new to the forum and I've been a PC and Android game developer for about 3 years ... But I have the need to make a scary game because it was the one I played with when I was 5 years old, and I owe it to him. The truth is that I'm not very into the creation of game for spectrum, now is when I'm studying it and knowing a bit like it is the basic and some engines. of all of them I think A.G.D is the best, for ease of use, speed and possibilities. But right now, I just met him, I have many doubts and I found this fantastic forum. I have done some tests and I am quite well understood with the engine, but if I have some questions, such as how to redefine the keys, I have tried the lines that you have commented and I get an error in the AGD v4.7 this scripts do you execute in an external program? Well I hope you help me and well, from then on I'll spend a lot here because I'm a novice is this kind of game creation. Greetings and many thanks.
|
|
|
Post by lukebord1 on Apr 16, 2018 8:27:32 GMT
I have some questions, such as how to redefine the keys, I have tried the lines that you have commented and I get an error in the AGD v4.7 this scripts do you execute in an external program? Hi picachu, the above lines cannot be used in AGD, it's pure assembly. If you're not familiar with the ZX Spectrum and its memory mechanics, it's hard to explain in a post how to write a routine in assembly, store it in a free memory location and recall it in an AGD project. Anyway, here're some first basic concepts: - AGD works in a 128K ZX Spectrum, it has a standalone syntax which helps writing games for the 48K machines; - it doesn't offer directly the possibility to redefine the keys in a completed game (or to do absolutely anything, e.g. to scroll the screen), however, it has the ASM calls commands which handle memory addresses where the user can store special routines apart; - using a PC (and a ZX Spectrum emulator), the advantages given by external tools are many, such as manipulating binary data for the routines and create graphics outside AGD (e.g. loading screens or graphic frames to compress and use through the ASM commands). And here're some useful tools/links to start: - BASin by Paul Dunn: it includes an Assembler and a Tape Creatorsites.google.com/site/ulaplus/home/zx-spin-and-basin- ZX Paintbrushwww.zx-modules.de/zxpaintbrush/zxpaintbrush.html- AGD video tutorials by Paul Jenkinson www.thespectrumshow.co.uk/agd.aspx- more in-depth AGD tutorials www.funspot.it/category/agd/
|
|
|
Post by picachu on Apr 17, 2018 9:52:45 GMT
Thank you very much for answering. Well, the truth is that machine code is 0. And for now, I want to do something simple and go into other aspects. As for example how to export sprites from external applications etc. I already knew some of those programs, but others did not. I will come very well. Thank you very much. As I mentioned before, I'm going to focus on studying how to import external aplococaion sprites using the spectaculator emulator. If anyone knows something please comment. I have some questions, such as how to redefine the keys, I have tried the lines that you have commented and I get an error in the AGD v4.7 this scripts do you execute in an external program? Hi picachu, the above lines cannot be used in AGD, it's pure assembly. If you're not familiar with the ZX Spectrum and its memory mechanics, it's hard to explain in a post how to write a routine in assembly, store it in a free memory location and recall it in an AGD project. Anyway, here're some first basic concepts: - AGD works in a 128K ZX Spectrum, it has a standalone syntax which helps writing games for the 48K machines; - it doesn't offer directly the possibility to redefine the keys in a completed game (or to do absolutely anything, e.g. to scroll the screen), however, it has the ASM calls commands which handle memory addresses where the user can store special routines apart; - using a PC (and a ZX Spectrum emulator), the advantages given by external tools are many, such as manipulating binary data for the routines and create graphics outside AGD (e.g. loading screens or graphic frames to compress and use through the ASM commands). And here're some useful tools/links to start: - BASin by Paul Dunn: it includes an Assembler and a Tape Creatorsites.google.com/site/ulaplus/home/zx-spin-and-basin- ZX Paintbrushwww.zx-modules.de/zxpaintbrush/zxpaintbrush.html- AGD video tutorials by Paul Jenkinson www.thespectrumshow.co.uk/agd.aspx- more in-depth AGD tutorials www.funspot.it/category/agd/
|
|
|
Post by Jonathan Cauldwell on Apr 20, 2018 18:10:04 GMT
Picachu, if it helps there is a command to redefine any or all of the keys in the new multi-platform version with the x64 Windows editor. As you're a novice one option might be to develop your game with the Spectrum version, then convert it to the new version as a .AGD file. Then you could edit the .AGD file in any text or code editor and write some new code in the initialisation event - or elsewhere - to take advantage of this new command or indeed any of the others that are now included.
An example of the new code might be
LET CONTROL = KEYBOARD AT 1 1 PRINT "PRESS KEY FOR" AT 5 1 PRINT "LEFT" REDEFINE LEFT AT 7 1 PRINT "RIGHT" REDEFINE RIGHT AT 9 1 PRINT "FIRE" REDEFINE FIRE
I'm hoping to release the latest version this weekend.
|
|
|
Post by picachu on Apr 23, 2018 21:43:08 GMT
It says that in your new version there will be a command to redefine keys ?? And could I adapt my project to the new version? If so, it would be great. We would all appreciate this improvement. By the way, it's an honor to be able to write with you, you're the great teacher. Regards!!! Picachu, if it helps there is a command to redefine any or all of the keys in the new multi-platform version with the x64 Windows editor. As you're a novice one option might be to develop your game with the Spectrum version, then convert it to the new version as a .AGD file. Then you could edit the .AGD file in any text or code editor and write some new code in the initialisation event - or elsewhere - to take advantage of this new command or indeed any of the others that are now included. An example of the new code might be LET CONTROL = KEYBOARD AT 1 1 PRINT "PRESS KEY FOR" AT 5 1 PRINT "LEFT" REDEFINE LEFT AT 7 1 PRINT "RIGHT" REDEFINE RIGHT AT 9 1 PRINT "FIRE" REDEFINE FIRE
I'm hoping to release the latest version this weekend.
|
|
|
Post by Jonathan Cauldwell on Apr 30, 2018 16:07:47 GMT
Migrating a project to the new version should simply be a question of saving a 48K snapshot .SNA file and then selecting the option to import a snapshot from the file menu. AGD will then extract your game and create a new project. As part of this process it will generate placeholder graphics for the Timex and Amstrad so you can run the game on those machines, so it might be a good idea to finish your game on the Spectrum and then import it when you want to create the control menu and any conversions
|
|
|
Post by Packobilly on Nov 15, 2019 9:45:53 GMT
Redefine keys routines must be executed externally before you start the game, or called with an ASM 205 command placed in the Intro/menu event. First of all you must take memory locations for keys into account. In AGD 4.0-4.6, keys are located at the following addresses: Right 35331 Left 35332 Down 35333 Up 35334 Fire 35335 Custom 1 35336 Custom 2 35337 In 4.7 they have been changed as follows: Right 35339 Left 35340 Down 35341 Up 35342 Fire 35343 Custom 1 35344 Custom 2 35345 In my first games I used a BASIC subprogram which did the job but was rather slow and prevented the user to select some keys like CAPS and SYMBOL SHIFT. Then I adapted an existing Assembly routine, far quickier and without that limitation. So far I used it for Seto Taisho Vs Yokai, Seto Taisho To Kazan and two other projects I cannot tell anything more about at the moment. The key location addresses are those for v4.7, if you wish to employ it for a title created with a previous version of AGD you must substitute the value of KEYS with 35331. KEYS EQU 35339
LD HL, KEYS LD B,7 CLEARKEYS: LD (HL),255 INC HL DJNZ CLEARKEYS ; clear previous key values
LD HL, 30543 CALL LOOP LD (KEYS+1),A ; redefine left
LD HL, 30520 CALL LOOP LD (KEYS),A ; redefine right LD HL, 30561 CALL LOOP LD (KEYS+3),A ; redefine up LD HL, 30561 CALL LOOP LD (KEYS+2),A ; redefine down LD HL, 30568 CALL LOOP LD (KEYS+4),A ; redefine fire
LD HL, 30577 CALL LOOP LD (KEYS+5),A ; redefine custom 1
LD HL, 30577 CALL LOOP LD (KEYS+6),A ; redefine custom 2 RET ; exit LOOP: CALL 654 LD A,E INC A JR Z,LOOP LD B,05 LD HL,KEYS LD A,E LOOP_1: CP (HL) JR Z, LOOP INC HL DJNZ LOOP_1 RET Then, supposing your routine is located at address 55000, you could call it from within AGD by putting the following lines in the Intro/menu event: ASM 205 ASM 216 ASM 214
|
|
|
Post by Packobilly on Nov 15, 2019 9:48:48 GMT
Ji, Alexandro. Im a newbie with agd. Ive just made a couple Of games based in the basic tutorials. I think AGD is awesome. My cuestion is, wich program may I use to write/compile this kind of code? Thanks a lot.
|
|
|
Post by alessandro on Nov 15, 2019 15:21:17 GMT
Hi Packobilly and welcome to the forum The Z80 Assembly code (of which I am definitely not an expert!) can be either written, or copied and pasted, into a simple text editor like Windows's Notepad. If you want to use a more flexible tool you can use Notepad++ but for the very beginning the default Notepad will do. In any case remember to save your file not with a .TXT extension, but .ASM To assemble pure ASM code I use Pasmo. It is a command-line tool, that is, you must open a command prompt window where both PASMO.EXE and the .ASM file you wish to assemble are located. In Windows, you can do it by opening the folder in File Manager and then typing "CMD" in the address bar where the path for the current directory is displayed between the icons and the folder contents. This means you must have both PASMO.EXE and the .ASM source file in the same directory. Under Windows, you can also modify the PATH system variable so that the directory where PASMO.EXE is located can be accessed through the command prompt in any other directory of your PC. The syntax varies according to which kind of file you wish to create out of the .ASM source. For example: pasmo MYFILE.ASM MYFILE.BIN will produce a .BIN binary file, which is best used in conjunction with other .ASM files, while pasmo MYFILE.ASM --tap MYFILE.TAP will produce a .TAP binary file, which can be loaded into an emulator or even into a real Spectrum through an interface like the DivIDE and DivMMC or the audio output of a PC. A final note: the above code will be of little use on its own. It is meant to be inserted into a larger program used to recall the AGD game code, manage memory banks in case of a 128K game etc. Hope that helps!
|
|