home *** CD-ROM | disk | FTP | other *** search
- >SIDE Left
- >POSITION 20,1900
- >STYLE Heading
- ARM coding graphics
- >STYLE Sub
- The principle
- >STYLE Body
- One thing that usually stops people writing games is the problem of plotting
- sprites quickly. Hopefully I can clear this up so anybody with a rudimentary
- knowledge of ARM code can set about writing a game. (If you don't know
- any thing about ARM code then I reccomend 'Archimedes Assembly Language'
- By Dabs presss) The Idea behind plotting sprites is simple:
- Get some bytes form the sprite and store them in the screen memory.
- First of course, you must load the sprite into memory, and then must get the
- address of the screen memory.
-
- THis sprite plottor is intended for use in mode 13 with a 16 by 16 sprite.
- However, this can eiasly be changed for use in a different mode or with a
- different sized sprite.
-
- >STYLE Sub
- Putting theroy into practise.
- >STYLE Body
- First then, to load the sprite file in use this:
-
- >FONT Corpus.Medium
- >COLOUR
- &0A0A8500
- &FFFFFF00
- sprite_file%=OPENIN "<Obey$Dir>.Sprites"
- size%=EXT#sprite_file%+4:CLOSE#sprite_file%
- DIM spritearea% size%
- !spritearea%=size%:spritearea%!8=16
- SYS "OS_SpriteOp",&10A,spritearea%,"<Obey$Dir>.Sprites"
-
- >STYLE Body
- The first two lines get the size of the sprite file.
- The second two lines setup the sprite area.
- The last line loads the sprite file into the sprite area.
- Then all that needs to be done is write the actual plotting routine! This is it:
-
- >FONT Corpus.Medium
- >COLOUR
- &0A0A8500
- &FFFFFF00
- DEF PROCassemble
- pic%=spritearea%+60
- DIM p_page% 1000
- SYS"OS_ReadDynamicArea",2 TO screen%
- FOR pass=0 TO 2 STEP 2
- P%=p_page%
- [OPT pass
- .plot LDR r12,spriteat ;call with: r0 as x
- LDR r11,screenat ; r1 as y
- MOV r4,#&14000 ; r2 as screen bank
- MUL r3,r4,r2 ;Get correct memory for bank
- ADD r11,r11,r3 ;add to position in screen mem
- MOV r4,#&140 ;&140 is one 'row' of memory
- MUL r3,r1,r4 ;get y offset
- ADD r11,r11,r3 ;Add it to position in memory
- ADD r11,r11,r0 ;Add x offset
- >POSITION 1300,2000
- >SIDE Right
- MOV r0,#0 ;row counter
- .loop LDMIA r12!,{r3-r6} ;loads 32 bytes of pic
- STMIA r11,{r3-r6} ;stores the bytes at screen
- ADD r11,r11,#320 ;add row to screen memory
- ADD r0,r0,#1 ;add 1 to row count
- CMP r0,#16 ;check if plotted all rows
- BLT loop ;if not goto loop
- MOV PC,r14
-
- .spriteat DCD 0
- .screenat DCD 0
-
- ]NEXT
-
- !spriteat=pic%+56
- !screenat=screen%
- ENDPROC
-
- >STYLE Body
- The problems with this are that the sprite's width in pixels must be divisible by 4
- and that the plotter can only be used in mode 13.
-
- A program that uses these routines can be found in the Magazine's Extras
- directory.
-
- >STYLE Sub
- Thanks...
- >STYLE Body
- Thanks to chris Hubble for the code in this article. - You're a GREAT guy,
- I love you! - Ooer. - Getting a bit carried away.