; ;------------------------------------- ;Nasr WARP Ported by Alex Highsmith ;------------------------------------- ;For OS-82 ((it wasn't very hard)) =) ;------------------------------------- ;Send Errors and the like to moonbeem@ix.netcom.com ;*********************************************** ; NASR WARP - by Jingyang Xu * ; (br00416@bingsuns.cc.binghamton.edu) * ; Include this header if you wish to use * ; the subroutines please * ;*********************************************** ;******* ;*Usage* ;******* ; ;If you have a sprite that is x wide and y high then: ; ;a=smallest integer greater than or equal to x/8 ;b=a*8-x+1 ;c=y ; ;Define a sprite like this: ; ;Sprite: ; .db a,b,c <- 3 bytes ; .db %xxxxxxxx,%xxxxxxxx,%xxxxxxxx,... <- first line of sprite ; .db %xxxxxxxx,%xxxxxxxx,%xxxxxxxx,... <- 2nd line ; .db .... <- other lines like above ; ;Each of the x's is a 1 or a 0, depending on if you want the ;pixel on or off. If a sprite have a length that's not a ;multiple of 8, then just leave the unused bits of each line ;to be 0 (they can be anything you want, just fill them in) ;Example - the following sprite is a "hello" (the 0's have been ;changed to a "." to make the sprite stand out) ; ;Hello_Sprite: ; .db 3,6,5 ; .db %1.1.111., %1...1..., %111..... ; .db %1.1.1..., %1...1..., %1.1..... ; .db %111.111., %1...1..., %1.1..... ; .db %1.1.1..., %1...1..., %1.1..... ; .db %1.1.111., %111.111., %111..... ; ;Input - (x,y) coordinates from bottom left corner of screen ;are passed in b and c respectively, these define the upper ;left corner of the sprite. The address of the sprite must be ;in hl. ;So if you want to blit the sprite to 2,55 on the screen, ;you'd do this: ; ld b,2 ; ld c,55 ; ld hl,Hello_Sprite ; ld de,(PROGRAM_ADDR) ; add hl,de ; CALL_(NASRWARP) ;******* ;*Setup* ;******* ;You must define three (four for NASRWARP) variables in Text Memory: ; ;TempLine = TEXT_MEM ;TempLine is a storage buffer for the each line of the sprite ;before it is blitted to the screen. The number of bytes you ;allot to TempLine determines the maximum width of the sprite. ;In this setup, 8 bytes is allotted to TempLine, therefore the ;maximum width is 64 bytes. ; ;PicCoor = TEXT_MEM+8 ;Two byte space needed by the program to store on-screen ;coordinates ; ;offset = TEXT_MEM+10 ;One byte space to store c ; ;NASR_Status = TEXT_MEM+11 ;One byte space: load a zero in this prior to calling NASRWARP to have it ;erase your sprite, load anything else in to have it draw your sprite. ;BEGIN DEMO #include "ti-82.h" .org 0 .db "NASRWARP Demo",0 TempLine = TEXT_MEM PicCoor = $TEXT_MEM+8 offset = $TEXT_MEM+10 NASR_Status =TEXT_MEM+11 ld a,%10001100 ;Needed for FIND_PIXEL ($4116) out (2),a ld hl,$88B8 ld de,$88B9 ld bc,$2FF xor a ld (hl),a ldir ;clear the graph screen ld b,10 ld c,10 ld hl,Hello_Sprite ld de,(PROGRAM_ADDR) add hl,de CALL_(NASRWARP) ROM_CALL(_GETKEY) RET NASRWARP: push bc ex de,hl CALL $4166 ;; changed for OS-82 from ROM_CALL(FIND_PIXEL) ld bc,$88B8 ;; changed for OS-82 add hl,bc ld (PicCoor),hl ex de,hl ld b,$ff Patch: rla inc b jr nc,Patch ld a,(hl) ld c,a inc hl ld a,(hl) ld (offset),a ld a,b ld e,c cp (hl) jr c,DS1 inc e DS1: inc hl ld a,(hl) ld d,a inc hl YLoop: push bc push de ld b,8 ex de,hl ld hl,TempLine InitTempLineLoop: ld (hl),$ff inc hl djnz InitTempLineLoop ex de,hl ld a,(NASR_Status) cp 0 jr z,NASRErase NASRDraw: ld b,0 ld de,TempLine ldir jr NASRDrawFin NASRErase: ld b,c ld hl,TempLine LoadEmpty: ld (hl),0 inc hl djnz LoadEmpty NASRDrawFin: pop de pop bc push hl push bc push de ld d,b ld a,b cp 0 jr z,skipshift SpriLoop1: ld a,b ld HL,TempLine ld b,e scf SpriLoop2: rr (HL) inc HL djnz SpriLoop2 ld b,a djnz SpriLoop1 ld b,d skipshift: ld a,$ff ;fill accumulator inc b mask1: srl a ;make the mask djnz mask1 ;something like scf ;00001111 -> rl a ld hl,(PicCoor) ;implement the mask or (hl) ;this preserve the 0 bits ld hl,TempLine ;become xxxx1111 and (hl) ;when anded, become ld (hl),a ;xxxxyyyy ld b,d ;retrieve b ld a,(offset) dec a sub b jr nc,skip sub 248 skip: ld b,a inc b ld a,$ff mask2: sla a djnz mask2 scf rr a dec e ld hl,(PicCoor) ld d,0 add hl,de or (hl) ld hl,TempLine add hl,de and (hl) ld (hl),a inc e ld c,e ld hl,(PicCoor) ld de,12 ;;Changed for OS-82 from 16 to 12 push hl add hl,de ld (PicCoor),hl pop hl ld de,TempLine ex de,hl ld b,0 ldir pop de pop bc pop hl dec d JUMP_NZ(YLoop) pop bc ROM_CALL(_GRBUFCPY_V) ;; Added for OS-82 ret Hello_Sprite: .db 3,6,5 .db %10101110, %10001000, %11100000 .db %10101000, %10001000, %10100000 .db %11101110, %10001000, %10100000 .db %10101000, %10001000, %10100000 .db %10101110, %11101110, %11100000 .end