#program asmsprnex
  10 RUN AT 3
  20 SAVE "asmsprnex.bas"
  30 BANK NEW %o: REM code bank
  40 BANK NEW %s: REM sprite bank
  50 LOAD "c:/demos/nextbasic/basicsprites/dksprite.spr" BANK %s
  60 .asm
  70 ;  bank %o,,1           ;Code in bank %o, clear the bank
  80 ;  org $c000            ; assemble to run at $c000
  90 ;start
 100 ;
 110 ;;Load sprite data
 120 ;  nextreg $54,%s*2     ;Bring in sprite pages @ $8000 
 130 ;  nextreg $55,%s*2+1   ; we don't need both pages, but...
 140 ;  xor a                ;A=0 (index of 1st sprite pattern)
 150 ;  ld bc,$303b          ;Sprite pattern index port
 160 ;  out (c),a            ;  start with pattern 0
 170 ;  ld hl,$8000          ;Point to sprite pattern data 
 180 ;  ld b,0               ;256 byte (16x16) pattern data
 190 ;  ld c,$5b             ;Sprite pattern load port
 195 ;; Above could be 'ld bc,$005b'
 200 ;  otir                 ;Write pattern data to FPGA
 210 ;
 220 ;;Show sprite
 230 ;  nreg $15,%01000001   ;Enable sprites
 240 ;  nreg $34,0           ;Select sprite 0
 250 ;  nreg $35,156         ;X=156
 260 ;  nreg $36,112         ;Y=112
 270 ;  nreg $37,0           ;Sprite attributes
 280 ;  nreg $38,%10000000   ;Sprite visible, pattern 0
 290 ;  jr $
 300 ;  
 310 ;  ds 128
 320 ;stack
 330 ;
 340 ;;NEX generation
 350 ;  bank %s              ;Force SAVENEX to include bank %s
 351 ;                       ; in the NEX file
 352 ;;Write the NEX file, emitting all the banks and
 353 ;; configuring the startup PC, SP and entry bank
 360 ;  savenex "asmspr.nex",start,stack,,%o
