Karoshi MSX Community

Desarrollo MSX => Rutinas - Snipets => Mensaje iniciado por: jltursan en 02 de Octubre de 2006, 07:17:16 pm



Título: A very simple sc1 starfield
Publicado por: jltursan en 02 de Octubre de 2006, 07:17:16 pm
Código:
; AsMSX Rules!

.MSX
.BASIC
.ORG $9000

VDPREG EQU $F3DF ;VDP REGISTERS
S_ATTRIBUTE EQU $1B00 ;Sprite attribute table
S_PATTERN EQU $3800 ;Sprite character patterns

CALL $0072

;SPRITES 16X16
;VDP(1) OR 00000010B
LD A,[VDPREG+1]
OR 00000010B
LD B,1
OUT [099H],A ;VDP(B)=A
LD A,B
OR 10000000B
OUT [099H],A
;DEFINE SPRITES
DI
LD C,$98
LD HL,S_PATTERN
CALL INIVPOKE
LD HL,SPRITES
LD B,11*2 ;N� SPRITESX2
SPRBC0: PUSH BC
LD B,8
OTIR
PUSH HL
LD DE,$B0-8 ;N� ((SPRITESX2)-1)*8
ADD HL,DE
LD B,8
OTIR
POP HL
POP BC
DJNZ SPRBC0
LD HL,INICIO
LD [$FDA0],HL
LD A,$C3
LD [$FD9F],A
LOOP: DI
CALL INICIO
EI
JP LOOP

INICIO: LD HL,COORDENADAS+$7F-4
LD DE,COORDENADAS+$7F
LD BC,$80-4
LDDR
LD DE,VELOCIDAD
LD HL,COORDENADAS
CBC0: LD A,96-10
CALL FUNCION
INC DE
INC HL
LD A,128-10
CALL FUNCION
INC DE
INC HL
LD A,5*4
CALL FUNCION
LD HL,$1B00
CALL INIVPOKE
LD BC,$8098
LD HL,COORDENADAS
OTIR
RET

;V=V+INT(X0-X)/32

FUNCION: LD C,[HL]
SBC C ;X0-X
CALL DIV16 ;(X0-X)/32
LD C,A
LD A,[DE]
ADD C ;V=V+INT(X0-X)
LD [DE],A
;X=X+INT(V/32)
CALL DIV16
LD C,A
LD A,[HL]
ADD C
LD [HL],A
RET

;[A]/16 CON SIGNO

DIV16: BIT 7,A
JR NZ,NEGATIVO
POSITIVO: NOP
SRA A
SRA A
SRA A
SRA A
NOP
NOP
RET

NEGATIVO: CPL
SRA A
SRA A
SRA A
SRA A
CPL
INC A
RET
INIVPOKE:
LD A,L
OUT [099H],A ; SEND LOW BYTETO VDP
LD A,H
OR 01000000B ; SET BIT 6 IN HIGH BYTE TO
; INDICATE WRITE
OUT [099H],A ; SEND MSB TO VDP
RET

SPRITES:

DB $07,$1F,$3F,$7F,$7F,$FF,$FF,$FF,$E0,$F8,$FC,$FE,$FE,$FF,$FF,$FF
DB $00,$07,$1F,$1F,$3F,$7F,$7F,$7F,$00,$E0,$F8,$FC,$FC,$FE,$FE,$FE
DB $00,$00,$03,$0F,$1F,$1F,$3F,$3F,$00,$00,$E0,$F8,$FC,$FC,$FE,$FE
DB $00,$00,$00,$07,$0F,$1F,$3F,$3F,$00,$00,$00,$C0,$E0,$F0,$F8,$F8
DB $00,$00,$00,$03,$07,$0F,$1F,$1F,$00,$00,$00,$C0,$E0,$F0,$F8,$F8
DB $00,$00,$00,$00,$03,$07,$0F,$0F,$00,$00,$00,$00,$C0,$E0,$F0,$F0
DB $00,$00,$00,$00,$00,$03,$07,$07,$00,$00,$00,$00,$00,$C0,$E0,$E0
DB $00,$00,$00,$00,$00,$00,$01,$03,$00,$00,$00,$00,$00,$00,$C0,$E0
DB $00,$00,$00,$00,$00,$00,$00,$03,$00,$00,$00,$00,$00,$00,$00,$80
DB $00,$00,$00,$00,$00,$00,$00,$01,$00,$00,$00,$00,$00,$00,$00,$80
DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
DB $FF,$FF,$FF,$7F,$7F,$3F,$1F,$07,$FF,$FF,$FF,$FE,$FE,$FC,$F8,$E0
DB $7F,$7F,$7F,$3F,$3F,$0F,$07,$00,$FE,$FE,$FE,$FC,$F8,$F8,$E0,$00
DB $3F,$3F,$3F,$1F,$1F,$0F,$03,$00,$FE,$FE,$FE,$FC,$FC,$F8,$E0,$00
DB $3F,$3F,$3F,$1F,$0F,$07,$00,$00,$F8,$F8,$F8,$F0,$E0,$C0,$00,$00
DB $1F,$1F,$0F,$07,$03,$00,$00,$00,$F8,$F8,$F0,$E0,$C0,$00,$00,$00
DB $0F,$0F,$07,$03,$00,$00,$00,$00,$F0,$F0,$E0,$C0,$00,$00,$00,$00
DB $07,$07,$03,$00,$00,$00,$00,$00,$E0,$E0,$C0,$00,$00,$00,$00,$00
DB $03,$01,$00,$00,$00,$00,$00,$00,$E0,$C0,$00,$00,$00,$00,$00,$00
DB $03,$03,$00,$00,$00,$00,$00,$00,$80,$80,$00,$00,$00,$00,$00,$00
DB $01,$00,$00,$00,$00,$00,$00,$00,$80,$00,$00,$00,$00,$00,$00,$00
DB $00,$00,$00,$00,$00,$00,$00,$00,$80,$00,$00,$00,$00,$00,$00,$00


VELOCIDAD: DB 0,0,0,0
COORDENADAS: DB $20,$20,4,$0F