Author
| Assembly information
|
LeandroCorreia msx professional Posts: 570 | Posted: November 26 2004, 13:32   |
Greetings, people!
I know MSX Basic fairly well, and I also know how to program games in high-level languages, but I want to learn Assembly to create MSX1 games. I have some questions...
1) Is there an Assembler for PC that generates MSX compatible ROMs?
2) Besides that, is there any other program I need to have?
3) What do I have to learn before knowing Assembly commands? Are there many commands too?
4) My idea is to program computer games for MSX1. I also need to use video and sound input / output. Do video and sound processors have other commands, or I simply use Z80 commands just to send / grab data from the other MSX processors?
5) There are differences between MSX models with 50 Mhz and 60 Mhz. This difference is relative only to videospeed or to the timer variable speed? My idea is to make games adjusting its framerate on the fly, just like modern MSX games, and so if I adjust game speed and frameskip to the timer, any MSX will run at the same speed. Is it possible?
6) How can I define (Can I define) vectors in Assembly language?
Thanks for the information!
|
|
Maggoo msx professional Posts: 599 | Posted: November 26 2004, 13:53   |
Assembly isn't all that hard actually, there aren't that many "commands" to know compared to Basic for example.
But before you start, make sure you understand how binary and hexadecimal works. Then learn some more about how to address memory, CPU registers, and mostly other chips (PSG/VDP/...), and on which ports to address then.
The next thing you want to do is create your own library of functions 'coz most of the time you'll end up re-creating the same functions all over again (joystick/keyboard input, VDP commands, Memory management, Music replayer). It's always more or less the same routines you'll end up using for any program so make sure they are good ones  |
|
LeandroCorreia msx professional Posts: 570 | Posted: November 26 2004, 14:18   |
So... If I am right...
Assembly is not hard. It's just plain simple tedious. I already know hex and bin. Does it uses functions and procedures too, or I have to use goto and gosub just like BASIC?
|
|
flyguille msx master Posts: 1354 | Posted: November 26 2004, 14:21   |
pick up tniASM, or CjASM...
those are very simple to use and fast.
|
|
chaos msx addict Posts: 276 | Posted: November 26 2004, 14:21   |
1) There are several: TniAsm, SjAsm, Tasm, etc.
2) For creation of games/demo's you need much more..
- gfx editors/converters (g-saurus/psp/polka etc.)
- music/sfx editors (SEE/Moonblaster/Scc blaffer etc)
- map/enemy editors (for games)
- sprite editors
- texteditor for ASM-code (context/ultraedit)
- project-dedicated tools
3) Here: you can find all mnemonics.. it's hard for a beginner to understand them.. maybe BiFi and I will create a document for beginning ASM coders..
4) There are Z80 commando's to control audio/video ('out' and 'in' and related commands)
5)
- 50 Hz means the interrupt is called 50 times a second.
- 60 Hz means the interrupt is called 60 times a second (there's less time to handle the routine)
6) vectors... you mean moving lines connected to eachother? |
|
LeandroCorreia msx professional Posts: 570 | Posted: November 26 2004, 14:37   |
Hello Chaos!
1) I'll check these out! I really wanna create ROMs, and not DSK files.
2) I can program most tools in a PC, using highlevel languages .  A game of mine could use about five or six different envelopes in a "tracker" manner.
3) If someone ever decides to create a newbies tutorial, that'd be great! I do know game programming logics. I just do not have the speed for that in MSX using high-level languages. Many people could be in the same way I am.
4) So, the Z80 only sends and receive bytes to sound and VDP registers/ addresses. If I want to set a pixel in an MSX1 screen, I order the Z80 to "out" a byte to the correct address (I am aware that a byte means 8 pixels, and that there's also a color byte too).
5) And the TIMER register keeps running at 60 Hz on both? So I can use any MSX for correct frameskip, just like a PC... I intend to do that to be sure that if a game has many onscreen enemies, the game will keep running at the same speed, without slowdowns as for instance, games made by Dinamic soft.
6) No, not this, sorry. In my native language, the words "vector" and "array" are the same. I meant "arrays".  |
|
wolf_
 msx legend Posts: 5178 | Posted: November 26 2004, 14:48   |
hm.. o_O .. I'd say an array is just a piece of mem .. if you want an array of 256 bytes .. then that'll cost you 256 bytes mem  |
|
LeandroCorreia msx professional Posts: 570 | Posted: November 26 2004, 14:51   |
Must I address manually every piece of memory I want to use, being sure that I won't overlap memory addresses, or I simply use a kind of Malloc function, just like in C?
|
|
sjoerd msx addict Posts: 457 | Posted: November 26 2004, 15:05   |
You'll have to program the malloc function yourself first  |
|
chaos msx addict Posts: 276 | Posted: November 26 2004, 15:05   |
aah.. that kind of vector.. 
you can simulate a vector with a pointer and a table..
a table is an array with bytes
you can use the pointer (2 bytes) to locate the right byte:
---------------------
ld hl,(pointer)
ld a,(hl) ; a = 1
inc hl
ld a,(hl) ; a = 2
ret
pointer:
.dw data
data:
.db 1,2,3,4,5,6,...
|
|
LeandroCorreia msx professional Posts: 570 | Posted: November 26 2004, 15:17   |
WEIRD!!!
In BASIC:
Clean your house.
In C:
Get broom and clear your house.
In Assembly:
Turn 90 degress left, walk two meters, turn 45 degrees right, stitch your arm, open hand, get hand near the broom, close hand, remove grain of dust at floor, remove grain of dust at ceiling, etc...
|
|
pitpan msx master Posts: 1567 | Posted: November 26 2004, 15:20   |
For creating MSX ROMs you can check asMSX v.0.10.
Get it at http://www.robsy.net/asmsx.htm
For creating a ROM file using asMSX v.0.10 you only need to include the following header to your source code:
.bios ; this defines all MSX1 subroutine names: ENASCR, LDIRVM, GTSTCK, etc.
.page 1 ; set at 4000h. Use .page 2 to start at 8000h
.rom ; defines the output file as a ROM
.start MY_PROGRAM ; defines the boot address for the ROM file
MY_PROGRAM:
; Include here your code
After assembling you will get a corretly sized (8, 16 o 32 KB) ROM file.
The package has got some simple examples. You can also download a full commented opensource game at http://www.robsy.net/progs.htm
At the moment all the documentation and comments are in spanish, but that shouldn't be a problem for you, being brazilian. Anyway, an updated v.0.11 version will be published by the end of this month, with a translated documentation and several other examples and tiny helpful tools (file converters, compressors, examples, etc.)
Another full-source MSX game is coming. And an updated version of the crappy PONG CLASSIC v.0.10 aswell.
Give it a try, Leandro.
|
|
LeandroCorreia msx professional Posts: 570 | Posted: November 26 2004, 15:33   |
Sure I will try it!
Just in case, what do I have in mind...
One or two players game running and shooting just like Son Son, Risky Woods or Metal Slug. Scenery composed by graphic blocks, simple background tune. 10 stages, and graphics would change at each two stages. Scroll would be 8x8 pixels, of course, but enemies would move smoothly (just like in Magical KidWiz). Five bosses that would be just 32x32 pixel sprites. It can be done in 32 Kbytes, I guess.
I wonder if your compiler could be adapted to generate 64, 128, 256 and 512 Kbytes ROMs as well.  |
|
sjoerd msx addict Posts: 457 | Posted: November 26 2004, 15:39   |
I rewrote a hello world that was lying around here somewhere:
; hoi.asm
; bios routine addresses
Init32 equ 7bh
SetWrt equ 53h
ChGet equ 9fh
ChPut equ 0a2h
; rom header
size 8000h ; 32KB ROM
org 4000h ; ROM starts on address 4000h
db "AB"
dw Start ; init address
dw 0,0,0
dw 0,0,0
Start
call Init32 ; bios routine to init screen 1
ld hl,6144 ; put writeaddress in registerpair HL
call SetWrt ; set vdp for writing from address in HL
ld hl,HelloWorldTxt ; put adress of our string in registerpair HL
call Print ; subroutine that prints string to screen
call ChGet ; bios routine to read a character from the keyboard
ret ; return to BASIC ROM
Print
ld a,(hl) ; put char that HL points to in register A
or a ; A=A OR A, and set flags, like the zeroflag when A=0
ret z ; return if the zeroflag is set
call ChPut ; bios routine to output char in A to the screen
inc hl ; increase the stringpointer
jr Print ; jump to start of the routine to print next char
HelloWorldTxt ; Label for our string
db "Hello World!",0 ; an array so to say :)
Of course I am using SjASM  (like "sjasm -l hoi.asm hoi.rom"  .
To create ROM files, you could use asMSX, that has even a ROM directive. |
|
pitpan msx master Posts: 1567 | Posted: November 26 2004, 15:47   |
Of course that it can be adapted for that. All that you need is to import the symbols table, create different files for every ROM page and then just link them alltogether.
Anyway, I would suggest you to start with an easier project. Assembler is tricky, try some basic concepts before starting with a BIG project. And look at ADVENTURE ISLAND, MAGICAL KID WIZ and several others: they are only 32 KB long.
Regards,
Edward Robsy
|
|
|
|
|