; Arcadia 2001 - sprite02.asm
; By Adam Trionfo - ballyalley @ hotmail.com
;
; Version 1.0 - April 23, 2002
;
; Signetics 2650 source-code for the Arcadia 2001 console.
;
; This program displays a sprite (happy face) on the screen.
;
; This file assembles well under VACS v1.24 (by W.H. Taphoorn)
; The simplest command works:
;      asm sprite02.asm
; The output will be in Hex format- you need to convert the
; Hex format file to a plain binary file (I use Win-Hex).
; Next pad with 00h or FFh for a 2048 byte file that will
; run cleanly under the Arcadia emulator.

; Equates - Name the 2650 condition codes

z     equ  0
eq    equ  z
p     equ  1
gt    equ  p
n     equ  2
lt    equ  n
un    equ  3

      org         0000H        ; Start of Arcadia ROM

programentry:
      eorz  r0                 ; Zero-out register 0
      bctr,un     programstart ; Branch to start of program
      retc,un                  ; Called on VSYNC or VBLANK?
                               ; As suggested by Paul Robson

programstart:
      ppsu        00100000b    ; Set Interrupt Inhibit bit
                               ; The Tech doc that Paul
                               ; wrote infers that Inter-
                               ; rupts aren't used

; Setup registers for Fill
      lodi,r0     00h          ; Zero-out registers 0
      lodi,r1     0FFh         ;
      lodi,r2     0FFh         ; 
; Fill the User Defined Characters and Sprites
fillchar:
      loda,r0     sprite1,r1+  ; get one byte of sprite data
      comi,r1     64D          ; Moved 64 bytes of data?
      bctr,eq     filldone     ; Exit loop when done
      stra,r0     1980h,r2+    ; Move byte to User Defined
                               ; memory area
      bctr,un     fillchar     ; Loop until done
filldone:

; Display User Defined Characters and Sprites 
      lodi,r0     38h          ; Redefined Sprite 1
      lodi,r1     0FFh          ; Index for Screen Display
displaychars:
      stra,r0     1800h,r1+    ; Display the sprite
      addi,r0     01h          ; Increment reg 0 by 1
      comi,r1     08d          ; Compare to decimal 8
      bcfr,eq     displaychars ; Break out of loop after
                               ; eight iterations
     
; Set Background Color to blue
      lodi,r0     00000110b    ; Put Blue (06h) into reg 0
      stra,r0     19F9h        ; Bits 0-2 of 19F9h control
                               ; background color

loopforever:
      bctr,un     loopforever  ; Loop forever

; Sprite Data
sprite1: ; (Ship)
      db          18h,18h,24h,24h
      db          42h,42h,81h,0FFh
sprite2: ; (UFO)
      db          00h,00h,7Eh,0D5h
      db          0ABh,7Eh,00h,00h 
sprite3: ; (Arrow)
      db          10h,38h,54h,10h
      db          10h,10h,10h,28h
sprite4: ; (Bomb)
      db          28h,10h,38h,7Ch
      db          7Ch,7Ch,38h,10h
char1:   ; (Happy face)
      db          7Eh,81h,0A5h,81h
      db          0A5h,99h,81h,7Eh
char2:   ; (Sad Face)
      db          7Eh,81h,0A5h,81h
      db          99h,0A5h,81h,7Eh
char3:   ; (Cross-Hair)
      db          00h,0C6h,82h,10h
      db          28h,10h,82h,0C6h
char4:   ; (Explosion)
      db          11h,40h,14h,2Ah
      db          14h,40h,11h,00h

      end ; End of assembly
