Emotion, j'ai fait hier soir mon premier programme Gp32. J'ai meme pas la console.
Meme pas le kit de developement de GamePark. tout a la main, en assembleur
Qu'est-ce que ca fait ? Rien du tout. C'etait juste pour debugguer le bios de la becane
; Affichage d'un sprite par transparence sans clipping en mode 16 bits !
; In:
; r0 = x
; r1 = y
; r2 = Sprite ptr
DrawSprite
stmfd sp!,{r4,r5,r6,lr} ; Preserve registres
ldrh r4,[r2],#2 ; Charge Taille Y
ldrh lr,[r2],#2 ; Charge Taille X
ldr r3,Screen ; Charge l'ecran actuel
rsb r0,r0,r0 lsl #4 ; x * 15
add r0,r1,r0 lsl #4 ; x = 16 * (15 * x) + y
add r3,r3,r0 lsl #1 ; r3 = Screen ptr
mov r1,#31*32+31 ; Couleur de transparence (Attention a verifier si l'ássembleur genere bien 2 instructions).
mov r5,#240*2
sub r5,r5,lr lsl #1 ; Correction au ptr d'écran apres scan d'1 ligne
LoopX
mov r6,lr ; Recharge nbr de pixel verticaux
LoopY
ldrh r0,[r2],#2 ; Charge pixel
cmp r0,r1 ; Transparent ?
strne r0,[r3] ; Affichage
add r3,r3,#2 ; Avancee ptr ecran
subs r6,r6,#1 ; Boucle Y
bne LoopY
add r3,r3,r5 ; Increment X
subs r4,r4,#1 ; Boucle X
bne LoopX
ldmfd sp!,{r4,r5,r6,pc} ; Pop et retour a l'appelant
TechNIC a écrit :
Franchement, je n'ai pas vu un seul bon site francais (desole fx-man) avec des vraies infos...
Du style comment faire tourner un jeu sur l'emu.
Quel est le hardware en detail de la GP32
Comment la programmer.
Des liens importants.
Des dl de roms, demos, betas, ...
Des puds détaillés avec images à l'appuie. etc .etc ...
; GP32 Startup Boot Code
CODE32
AREA Init, CODE, READONLY
IMPORT |Image$$RO$$Base|
IMPORT |Image$$RO$$Limit|
IMPORT |Image$$RW$$Base|
IMPORT |Image$$RW$$Limit|
IMPORT |Image$$ZI$$Base|
IMPORT |Image$$ZI$$Limit|
; HEADER of the file
ENTRY
B _GpInit
DCD |Image$$RO$$Base| ; Start of Read Only section
DCD |Image$$RO$$Limit| ; End "
DCD |Image$$RW$$Base| ; Start of Read/Write section
DCD |Image$$RW$$Limit| ; End "
DCD |Image$$ZI$$Base| ; Base of Zero Initialized section
DCD |Image$$ZI$$Limit| ; End "
DCD 0x44450011 ; Magic numbers ?
DCD 0x44450011
DCD 0x01234567
DCD 0x12345678
DCD 0x23456789
DCD 0x34567890
DCD 0x45678901
DCD 0x56789012
DCD 0x23456789
DCD 0x34567890
DCD 0x45678901
DCD 0x56789012
DCD 0x23456789
DCD 0x34567890
DCD 0x45678901
DCD 0x56789012
IMPORT main
IMPORT GenInit
_GpInit
stmfd sp!,{r0-r14}
bl GenInit
bl main
ldmfd sp!,{r0-r13,pc}
END
; On se place en Read Write pour pouvoir acceder plus rapidement aux variables globales
; Sans indirection supplementaire
CODE32
AREA Generic, CODE, READWRITE
EXPORT GenInit
GenInit
; Save Lr
mov r11,lr
; Get pointer to GpSurfaceSet routine
mov r0,#0
swi 0xb
str r0,SurfaceSet
; Get time passed
mov r0,#6
swi 0xb
str r0,Timer
ldr r0,[r0]
str r0,OldTime
; 16-bits mode
mov r0,#16
mov r1,#0
mov r2,#0
swi 8
; Allocate 2 DrawSurface
ldr r0,AdrSurface1
mov r1,#0
mov r2,#1
swi 8
ldr r0,AdrSurface2
mov r1,#1
mov r2,#1
swi 8
; Set Current Displayed Surface
ldr r0,AdrSurface1
ldr r1,SurfaceSet
mov lr,pc ; Y'a pas a dire l'arm
mov pc,r1 ; C'est special !
; Set Current Working Screen
ldr r0,AdrSurface2
ldr r0,[r0] ; Ptr is the first one
str r0,Screen
mov pc,r11 ; Return
EXPORT SwapBuffer
SwapBuffer
ldr r1,=AdrSurface1
ldr r0,Flip ; Current Flip
ldr r2,[r1,r0] ; Read current working DrawSurface
eor r0,r0,#4 ; Swap Surface
ldr r2,[r2] ; Read Screen
str r0,Flip ; Save Flip value
str r2,Screen ; Save current working screen
ldr r2,SurfaceSet ; Read Surface Set function
ldr r0,[r1,r0] ; Read current displayed adress
mov pc,r2 ; Jump to surface set
EXPORT Synchro
Synchro
ldr r2,Timer ; Read Timer
ldr r1,OldTime ; Read old Time
add r1,r0,r1 ; Get new time
Loop
ldr r0,[r2]
cmp r0,r1
bls Loop
mov pc,lr
EXPORT GetScreen
GetScreen
ldr r0,Screen
mov pc,lr
EXPORT BlendFunc
; In:
; r0 = x
; r1 = y
; r2 = r
; Out
; r0 warning r0.uw is corupted !
BlendFunc
ldr r3,=0xFC1F03E ; Masque
orr r0,r0,r0 lsl #16
orr r1,r1,r1 lsl #16
and r0,r0,r3
and r1,r1,r3
sub r0,r0,r1
mul r0,r0,r2
add r0,r1,r0 lsr #5
and r0,r0,r3
orr r0,r0,r0 lsr #16
mov pc,lr
DrawSurface1 DCD 0,0,0,0,0,0,0
DrawSurface2 DCD 0,0,0,0,0,0,0
AdrSurface1 DCD DrawSurface1
AdrSurface2 DCD DrawSurface2
Flip DCD 0
Screen DCD 0
SurfaceSet DCD 0
Timer DCD 0
OldTime DCD 0
END
AREA Program, CODE, READONLY
EXPORT main
IMPORT GetScreen
IMPORT SwapBuffer
main
bl GetScreen
mov r3,#0
mainloop ldr r2,=320*240/64
loop strh r3,[r0],#2
subs r2,r2,#1
bne loop
add r3,r3,#1
cmp r3,#32*2
bne mainloop
bl SwapBuffer
Stop b Stop
END