Conway's Game of Life: Difference between revisions
Content added Content deleted
m (→{{header|Phix}}: limit to 10K cells, added online link) |
Puppydrum64 (talk | contribs) |
||
Line 263: | Line 263: | ||
sta $03 |
sta $03 |
||
rts</lang> |
rts</lang> |
||
=={{header|68000 Assembly}}== |
|||
I went a little further and created a 40x30 grid, but this implementation is accurate and does have a blinker in it. As always, thanks to Keith of Chibiakumas for the cartridge header and hardware routines. This is the source code for a Sega Genesis game that you can compile with VASM. (It was tested in the Fusion emulator but it should work anywhere.) |
|||
Explanation of macros: |
|||
* pushRegs = <tt>MOVEM.L ___,-(SP)</tt> |
|||
* popRegs = <tt>MOVEM.L (SP)+,___</tt> |
|||
* pushLong = <tt>MOVE.L ___,-(SP)</tt> |
|||
* popLong = <tt>MOVE.L (SP)+,___</tt> |
|||
<lang 68000devpac>include "\SrcALL\68000_Macros.asm" |
|||
;Ram Variables |
|||
Cursor_X equ $00FF0000 ;Ram for Cursor Xpos |
|||
Cursor_Y equ $00FF0000+1 ;Ram for Cursor Ypos |
|||
conwayTilemapRam equ $00FF1000 |
|||
conwayBackupTilemapRam equ $00FF2000 |
|||
;Video Ports |
|||
VDP_data EQU $C00000 ; VDP data, R/W word or longword access only |
|||
VDP_ctrl EQU $C00004 ; VDP control, word or longword writes only |
|||
;constants |
|||
ROWLENGTH equ 40 |
|||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|||
; Traps |
|||
DC.L $FFFFFE00 ;SP register value |
|||
DC.L ProgramStart ;Start of Program Code |
|||
DS.L 7,IntReturn ; bus err,addr err,illegal inst,divzero,CHK,TRAPV,priv viol |
|||
DC.L IntReturn ; TRACE |
|||
DC.L IntReturn ; Line A (1010) emulator |
|||
DC.L IntReturn ; Line F (1111) emulator |
|||
DS.L 4,IntReturn ; Reserverd /Coprocessor/Format err/ Uninit Interrupt |
|||
DS.L 8,IntReturn ; Reserved |
|||
DC.L IntReturn ; spurious interrupt |
|||
DC.L IntReturn ; IRQ level 1 |
|||
DC.L IntReturn ; IRQ level 2 EXT |
|||
DC.L IntReturn ; IRQ level 3 |
|||
DC.L IntReturn ; IRQ level 4 Hsync |
|||
DC.L IntReturn ; IRQ level 5 |
|||
DC.L IntReturn ; IRQ level 6 Vsync |
|||
DC.L IntReturn ; IRQ level 7 |
|||
DS.L 16,IntReturn ; TRAPs |
|||
DS.L 16,IntReturn ; Misc (FP/MMU) |
|||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|||
; Header |
|||
DC.B "SEGA GENESIS " ;System Name |
|||
DC.B "(C)CHBI " ;Copyright |
|||
DC.B "2019.JAN" ;Date |
|||
DC.B "ChibiAkumas.com " ; Cart Name |
|||
DC.B "ChibiAkumas.com " ; Cart Name (Alt) |
|||
DC.B "GM CHIBI001-00" ;TT NNNNNNNN-RR T=Type (GM=Game) N=game Num R=Revision |
|||
DC.W $0000 ;16-bit Checksum (Address $000200+) |
|||
DC.B "J " ;Control Data (J=3button K=Keyboard 6=6button C=cdrom) |
|||
DC.L $00000000 ;ROM Start |
|||
DC.L $003FFFFF ;ROM Length |
|||
DC.L $00FF0000,$00FFFFFF ;RAM start/end (fixed) |
|||
DC.B " " ;External RAM Data |
|||
DC.B " " ;Modem Data |
|||
DC.B " " ;MEMO |
|||
DC.B "JUE " ;Regions Allowed |
|||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|||
; Generic Interrupt Handler |
|||
IntReturn: |
|||
rte |
|||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|||
; Program Start |
|||
ProgramStart: |
|||
;initialize TMSS (TradeMark Security System) |
|||
move.b ($A10001),D0 ;A10001 test the hardware version |
|||
and.b #$0F,D0 |
|||
beq NoTmss ;branch if no TMSS chip |
|||
move.l #'SEGA',($A14000);A14000 disable TMSS |
|||
NoTmss: |
|||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|||
; Set Up Graphics |
|||
lea VDPSettings,A5 ;Initialize Screen Registers |
|||
move.l #VDPSettingsEnd-VDPSettings,D1 ;length of Settings |
|||
move.w (VDP_ctrl),D0 ;C00004 read VDP status (interrupt acknowledge?) |
|||
move.l #$00008000,d5 ;VDP Reg command (%8rvv) |
|||
NextInitByte: |
|||
move.b (A5)+,D5 ;get next video control byte |
|||
move.w D5,(VDP_ctrl) ;C00004 send write register command to VDP |
|||
; 8RVV - R=Reg V=Value |
|||
add.w #$0100,D5 ;point to next VDP register |
|||
dbra D1,NextInitByte ;loop for rest of block |
|||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|||
; Set up palette and graphics |
|||
move.l #$C0000000,d0 ;Color 0 |
|||
move.l d0,VDP_Ctrl |
|||
MOVE.W #$0A00,VDP_Data ;BLUE |
|||
move.l #$C01E0000,d0 ;Color 0 |
|||
move.l d0,VDP_Ctrl |
|||
MOVE.W #$00EE,VDP_Data ;YELLOW |
|||
lea Graphics,a0 ;background tiles |
|||
move.w #(GraphicsEnd-Graphics)-1,d1 ;data size |
|||
CLR.L D2 ;start loading at tile 0 of VRAM |
|||
jsr DefineTiles |
|||
clr.b Cursor_X ;Clear Cursor XY |
|||
clr.b Cursor_Y |
|||
;Turn on screen |
|||
move.w #$8144,(VDP_Ctrl);C00004 reg 1 = 0x44 unblank display |
|||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|||
; TESTING AREA |
|||
;load the tilemaps |
|||
LEA Conway_Tilemap,a3 |
|||
LEA ConwayTilemapRam,A2 |
|||
move.l #(Conway_Backup_Tilemap-Conway_Tilemap),d1 |
|||
JSR LDIR |
|||
LEA Conway_Backup_Tilemap,a3 |
|||
LEA conwayBackupTilemapRam,A2 |
|||
move.l #(Conway_Backup_Tilemap-Conway_Tilemap),d1 |
|||
JSR LDIR |
|||
CLR.B Cursor_X |
|||
CLR.B Cursor_Y |
|||
;print the tilemap once |
|||
LEA ConwayTilemapRam,A3 |
|||
JSR Conway_Print |
|||
main: |
|||
;do the behavior |
|||
jsr Conway_CheckTilemap |
|||
;copy the tilemap |
|||
lea conwayBackupTilemapRam,A3 |
|||
LEA ConwayTilemapRam,A2 |
|||
move.l #(Conway_Backup_Tilemap-Conway_Tilemap),d1 |
|||
jsr LDIR |
|||
CLR.B Cursor_X |
|||
CLR.B Cursor_Y |
|||
;print the tilemap |
|||
LEA ConwayTilemapRam,A3 |
|||
JSR Conway_Print |
|||
;repeat |
|||
JMP main |
|||
Conway_CheckTilemap: |
|||
;since we don't want the partial results of the checks to mess with later ones, we'll copy the changes to a buffer, and then |
|||
;have that buffer clobber the original. That way, all changes to the ecosystem are effectively atomic. |
|||
LEA ConwayTilemapRam,A0 |
|||
LEA conwayBackupTilemapRam,A6 |
|||
LEA (ROWLENGTH+3,A0),A0 ;actual data starts here |
|||
LEA (ROWLENGTH+3,A6),A6 ;actual data starts here |
|||
.loop: |
|||
MOVE.B (A0),D2 |
|||
CMP.B #255,D2 |
|||
BEQ .done |
|||
CMP.B #2,D2 |
|||
BEQ .overhead |
|||
JSR Conway_CheckNeighbors |
|||
pushLong D0 |
|||
JSR popcnt_8 |
|||
MOVE.B D0,D3 |
|||
popLong D0 |
|||
;now implement the table here. |
|||
;neighbor bits in D0 |
|||
;current state in D2 |
|||
;popcnt in D3 |
|||
;pointer to where we are in A0 |
|||
;the only time the current state is relevant to the output, is when popcnt = 2. Otherwise, it's entirely determined by popcnt. |
|||
CMP.B #4,D3 |
|||
BCC .DeadCell |
|||
CMP.B #1,D3 |
|||
BLS .DeadCell |
|||
CMP.B #3,D3 |
|||
BEQ .LiveCell |
|||
;else, must be 2. |
|||
MOVE.B D2,(A6) ;store current value into backup table. |
|||
bra .overhead |
|||
.LiveCell: |
|||
MOVE.B #1,(A6) |
|||
BRA .overhead |
|||
.DeadCell: |
|||
MOVE.B #0,(A6) ;store in backup table. |
|||
.overhead: |
|||
ADDA.L #1,A0 |
|||
ADDA.L #1,A6 |
|||
JMP .loop |
|||
.done: |
|||
RTS |
|||
popcnt_8: |
|||
pushRegs D2-D5 |
|||
MOVEQ #8-1,D5 |
|||
MOVEQ #0,D3 |
|||
.loop: |
|||
ROR.B #1,D0 |
|||
BCC .overhead |
|||
ADDQ.B #1,D3 |
|||
.overhead: |
|||
dbra d5,.loop |
|||
MOVE.B D3,D0 |
|||
popRegs D2-D5 |
|||
RTS |
|||
Conway_CheckNeighbors: |
|||
;A0 = pointer to where we are in the tilemap. |
|||
;returns: D0.B = uUrRdDlL |
|||
;u = top left |
|||
;U = top |
|||
;r = top Right |
|||
;R = Right |
|||
;d = bottom right |
|||
;D = bottom |
|||
;l = bottom Left |
|||
;L = Left |
|||
pushRegs D2-D5/A0 |
|||
MOVEQ #0,D0 |
|||
MOVE.L A0,A1 |
|||
MOVE.L A1,A2 |
|||
SUBA.L #ROWLENGTH+2,A1 ;POINTS ABOVE |
|||
ADDA.L #ROWLENGTH+2,A2 ;POINTS BELOW |
|||
MOVE.B (A1),D1 |
|||
MOVE.B (A2),D2 |
|||
CMP.B #1,D1 |
|||
BNE .noUpper |
|||
BSET #6,D0 |
|||
bra .next |
|||
.noUpper: |
|||
BCLR #6,D0 |
|||
.next: |
|||
CheckLower: |
|||
CMP.B #1,D2 |
|||
BNE .noLower |
|||
BSET #2,D0 |
|||
bra .next |
|||
.noLower: |
|||
BCLR #2,D0 |
|||
.next: |
|||
SUBA.L #1,A0 ;left |
|||
SUBA.L #1,A1 ;upper-left |
|||
SUBA.L #1,A2 ;lower-left |
|||
MOVE.B (A1),D1 |
|||
MOVE.B (A2),D2 |
|||
MOVE.B (A0),D3 |
|||
CheckUpperLeft: |
|||
CMP.B #1,D1 |
|||
BNE .noUpperLeft |
|||
BSET #7,D0 |
|||
bra .next |
|||
.noUpperLeft: |
|||
BCLR #7,D0 |
|||
.next: |
|||
CheckLowerLeft: |
|||
CMP.B #1,D2 |
|||
BNE .noLowerLeft |
|||
BSET #1,D0 |
|||
bra .next |
|||
.noLowerLeft: |
|||
BCLR #1,D0 |
|||
.next: |
|||
CheckLeft: |
|||
CMP.B #1,D3 |
|||
BNE .noLeft |
|||
BSET #0,D0 |
|||
bra .next |
|||
.noLeft: |
|||
BCLR #0,D0 |
|||
.next: |
|||
addA.L #2,A0 |
|||
addA.L #2,A1 |
|||
addA.L #2,A2 |
|||
MOVE.B (A1),D1 |
|||
MOVE.B (A2),D2 |
|||
MOVE.B (A0),D3 |
|||
CheckUpperRight: |
|||
CMP.B #1,D1 |
|||
BNE .noUpperRight |
|||
BSET #5,D0 |
|||
bra .next |
|||
.noUpperRight: |
|||
BCLR #5,D0 |
|||
.next: |
|||
CheckLowerRight: |
|||
CMP.B #1,D2 |
|||
BNE .noLowerRight |
|||
BSET #3,D0 |
|||
bra .next |
|||
.noLowerRight: |
|||
BCLR #3,D0 |
|||
.next: |
|||
CheckRight: |
|||
CMP.B #1,D3 |
|||
BNE .noRight |
|||
BSET #4,D0 |
|||
bra .next |
|||
.noRight: |
|||
BCLR #4,D0 |
|||
.next: |
|||
popRegs D2-D5/A0 |
|||
rts |
|||
Conway_Print: |
|||
;input: A3 = base address of tilemap |
|||
MOVE.B (A3)+,D0 |
|||
CMP.B #255,D0 |
|||
BEQ .done |
|||
CMP.B #2,D0 |
|||
BEQ .skip |
|||
;else, print |
|||
JSR Conway_PrintChar |
|||
.skip |
|||
BRA Conway_Print |
|||
.done |
|||
rts |
|||
Conway_PrintChar: ;Show D0 to screen |
|||
moveM.l d0-d7/a0-a7,-(sp) |
|||
and.l #$FF,d0 ;Keep only 1 byte |
|||
Move.L #$40000003,d5 ;top 4=write, bottom $3=Cxxx range |
|||
MOVEQ #0,D4 ;Tilemap at $C000+ |
|||
Move.B (Cursor_Y),D4 |
|||
rol.L #8,D4 ;move $-FFF to $-FFF---- |
|||
rol.L #8,D4 |
|||
rol.L #7,D4 ;2 bytes per tile * 64 tiles per line |
|||
add.L D4,D5 ;add $4------3 |
|||
Move.B (Cursor_X),D4 |
|||
rol.L #8,D4 ;move $-FFF to $-FFF---- |
|||
rol.L #8,D4 |
|||
rol.L #1,D4 ;2 bytes per tile |
|||
add.L D4,D5 ;add $4------3 |
|||
MOVE.L D5,(VDP_ctrl) ; C00004 write next character to VDP |
|||
MOVE.W D0,(VDP_data) ; C00000 store next word of name data |
|||
addq.b #1,(Cursor_X) ;INC Xpos |
|||
move.b (Cursor_X),d0 |
|||
cmp.b #39,d0 |
|||
bls .nextpixel_Xok |
|||
jsr NewLine ;If we're at end of line, start newline |
|||
.nextpixel_Xok: |
|||
moveM.l (sp)+,d0-d7/a0-a7 |
|||
rts |
|||
;don't forget, these are in ROM so we can't write to them directly. |
|||
;instead, they will be copied to ram and worked with from there. |
|||
Conway_Tilemap: ;(screenwidth + 2) by (screenheight+2) |
|||
DC.B $02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02 |
|||
DC.B $02,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$02 |
|||
DC.B $02,$00,$00,$01,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$01,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$02 |
|||
DC.B $02,$00,$00,$00,$01,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$01,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$02 |
|||
DC.B $02,$00,$01,$01,$01,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$01,$01,$01,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$02 |
|||
DC.B $02,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$02 |
|||
DC.B $02,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$02 |
|||
DC.B $02,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$02 |
|||
DC.B $02,$00,$00,$00,$00,$00,$00,$00,$00,$00,$01,$01,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$02 |
|||
DC.B $02,$00,$00,$00,$00,$00,$00,$00,$00,$01,$00,$00,$01,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$02 |
|||
DC.B $02,$00,$01,$01,$00,$00,$00,$00,$00,$00,$01,$01,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$02 |
|||
DC.B $02,$00,$01,$01,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$02 |
|||
DC.B $02,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$02 |
|||
DC.B $02,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$02 |
|||
DC.B $02,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$02 |
|||
DC.B $02,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$02 |
|||
DC.B $02,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$02 |
|||
DC.B $02,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$02 |
|||
DC.B $02,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$02 |
|||
DC.B $02,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$02 |
|||
DC.B $02,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$02 |
|||
DC.B $02,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$02 |
|||
DC.B $02,$00,$00,$00,$00,$01,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$02 |
|||
DC.B $02,$00,$00,$00,$00,$01,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$02 |
|||
DC.B $02,$00,$00,$00,$00,$01,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$02 |
|||
DC.B $02,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$02 |
|||
DC.B $02,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$02 |
|||
DC.B $02,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$02 |
|||
DC.B $02,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$02 |
|||
DC.B $02,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$02 |
|||
DC.B $02,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$02 |
|||
DC.B $02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02 |
|||
DC.B 255 |
|||
EVEN |
|||
Conway_Backup_Tilemap: ;(screenwidth + 2) by (screenheight+2) |
|||
DC.B $02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02 |
|||
rept 30 |
|||
DC.B $02,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$02 |
|||
endr |
|||
DC.B $02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02 |
|||
DC.B 255 |
|||
EVEN |
|||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|||
NewLine: |
|||
addq.b #1,(Cursor_Y) ;INC Y |
|||
clr.b (Cursor_X) ;Zero X |
|||
rts |
|||
LDIR: ;COPY D1 BYTES FROM A3 TO A2 |
|||
move.b (a3)+,(a2)+ |
|||
DBRA D1,LDIR |
|||
rts |
|||
DefineTiles: ;Copy D1 bytes of data from A0 to VDP memory D2 |
|||
jsr prepareVram ;Calculate the memory location we want to write |
|||
.again: ; the tile pattern definitions to |
|||
move.l (a0)+,(VDP_data) |
|||
dbra d1,.again |
|||
rts |
|||
prepareVram: ;To select a memory location D2 we need to calculate |
|||
;the command byte... depending on the memory location |
|||
pushall ;$7FFF0003 = Vram $FFFF.... $40000000=Vram $0000 |
|||
move.l d2,d0 |
|||
and.w #%1100000000000000,d0 ;Shift the top two bits to the far right |
|||
rol.w #2,d0 |
|||
and.l #%0011111111111111,d2 ; shift all the other bits left two bytes |
|||
rol.l #8,d2 |
|||
rol.l #8,d2 |
|||
or.l d0,d2 |
|||
or.l #$40000000,d2 ;Set the second bit from the top to 1 |
|||
;#%01000000 00000000 00000000 00000000 |
|||
move.l d2,(VDP_ctrl) |
|||
popallRTS: |
|||
popall |
|||
rts |
|||
Graphics: |
|||
DC.L $0000000F,$0000000F,$0000000F,$0000000F,$0000000F,$0000000F,$0000000F,$FFFFFFFF |
|||
DC.L $FFFFFFFF,$FFFFFFFF,$FFFFFFFF,$FFFFFFFF,$FFFFFFFF,$FFFFFFFF,$FFFFFFFF,$FFFFFFFF |
|||
GraphicsEnd: |
|||
VDPSettings: |
|||
DC.B $04 ; 0 mode register 1 ---H-1M- |
|||
DC.B $04 ; 1 mode register 2 -DVdP--- |
|||
DC.B $30 ; 2 name table base for scroll A (A=top 3 bits) --AAA--- = $C000 |
|||
DC.B $3C ; 3 name table base for window (A=top 4 bits / 5 in H40 Mode) --AAAAA- = $F000 |
|||
DC.B $07 ; 4 name table base for scroll B (A=top 3 bits) -----AAA = $E000 |
|||
DC.B $6C ; 5 sprite attribute table base (A=top 7 bits / 6 in H40) -AAAAAAA = $D800 |
|||
DC.B $00 ; 6 unused register -------- |
|||
DC.B $00 ; 7 background color (P=Palette C=Color) --PPCCCC |
|||
DC.B $00 ; 8 unused register -------- |
|||
DC.B $00 ; 9 unused register -------- |
|||
DC.B $FF ;10 H interrupt register (L=Number of lines) LLLLLLLL |
|||
DC.B $00 ;11 mode register 3 ----IVHL |
|||
DC.B $81 ;12 mode register 4 (C bits both1 = H40 Cell) C---SIIC |
|||
DC.B $37 ;13 H scroll table base (A=Top 6 bits) --AAAAAA = $FC00 |
|||
DC.B $00 ;14 unused register -------- |
|||
DC.B $02 ;15 auto increment (After each Read/Write) NNNNNNNN |
|||
DC.B $01 ;16 scroll size (Horiz & Vert size of ScrollA & B) --VV--HH = 64x32 tiles |
|||
DC.B $00 ;17 window H position (D=Direction C=Cells) D--CCCCC |
|||
DC.B $00 ;18 window V position (D=Direction C=Cells) D--CCCCC |
|||
DC.B $FF ;19 DMA length count low LLLLLLLL |
|||
DC.B $FF ;20 DMA length count high HHHHHHHH |
|||
DC.B $00 ;21 DMA source address low LLLLLLLL |
|||
DC.B $00 ;22 DMA source address mid MMMMMMMM |
|||
DC.B $80 ;23 DMA source address high (C=CMD) CCHHHHHH |
|||
VDPSettingsEnd: |
|||
even</lang> |
|||
=={{header|ABAP}}== |
=={{header|ABAP}}== |