We're on Discord! Please join our server now if you don't want to miss anything! (More info) | Join the UCC4 contest! (More info)

* WalrusIRC & Discord main room

If you have a forum account, have more than 4 posts and are not part of a restricted usergroup, then you can chat in our main Discord server room directly from here and continue using the forums at the same time. Or you can join our server directly and access many more discussion rooms!

Author Topic: _iPhoenix_ tries to do Assembly things.  (Read 742 times)

0 Members and 1 Guest are viewing this topic.

Offline mazhat

  • Full User
  • Join Date: Mar 2017
  • Location:
  • Posts: 189
  • Post Rating Ratio: +8/-0
  • Edelweiss. Edelweiss.
    • /u/Mazhat
    • Mazhat
    • @Mazhat
    • MOS
  • Gender: Male
Re: _iPhoenix_ tries to do Assembly things.
« on: July 10, 2018, 04:11:04 am »
I am glad you are pursuing Assembly!
I finished only one program, but I just don't know about
all the hacks, and tricks of the hardware to be even close to decent.
It's a real challenge for smarty pants, such as yourself.

I looked through my old files and found it,
also I know that the beginning isn't optimised,
but I didn't really feel like doing it lol.

Code: [Select]
;Low Quality Bootleg Sprite Routine
;Created By Matt C./ Mazhat
;
.NOLIST
#define   EQU   .equ
#define   equ   .equ
#define   END   .end
#define   end   .end
#include "ti83plus.inc"
#include "mirage.inc"
.LIST
     .org $9d93 ;Origin (set back two to account for AsmPrgm)
.db $BB,$6D ;Compiled AsmPrgm token
ret ;So TIOS wont run the program
.db 1 ;Identifier as MirageOS program
.db %00000000,%00000000 ;15x15 button
.db %00000000,%00000000
.db %00000000,%00000000
.db %00000000,%00000000
.db %00000000,%00000000
.db %00000000,%00000000
.db %00000000,%00000000
.db %00000000,%00000000
.db %00000000,%00000000
.db %00000000,%00000000
.db %00000000,%00000000
.db %00000000,%00000000
.db %00000000,%00000000
.db %00000000,%00000000
.db %00000000,%00000000
.db "Made by Matt C",0 ;Zero terminated description

;Program code starts here

;Reset the variables and such
ld a, 0
ld (posY), a ;Set posY
ld a, 0
ld (posX), a ;Set posX
ld a, $00
ld (animCounter), a

animation:
;
;Yes, I know this part is REALLY bad,
;BUT BOY AM I DONE WITH THIS PROGRAM.
call drawSprite
ld a, 0
ld (posX), a
call drawSprite
ld a, 1
ld (posX), a
call drawSprite
ld a, 2
ld (posX), a
call drawSprite
ld a, 3
ld (posX), a
call drawSprite
ld a, 4
ld (posX), a
call drawSprite
ld a, 5
ld (posX), a
call drawSprite
ld a, 6
ld (posX), a
call drawSprite
ld a, 7
ld (posX), a
call drawSprite

ld a, 0
ld (posY), a
call drawSprite
ld a, 1
ld (posY), a
call drawSprite
ld a, 2
ld (posY), a
call drawSprite
ld a, 3
ld (posY), a
call drawSprite
ld a, 4
ld (posY), a
call drawSprite
ld a, 5
ld (posY), a
call drawSprite
ld a, 6
ld (posY), a
call drawSprite
ld a, 7
ld (posY), a
call drawSprite


call drawSprite
ld a, 7
ld (posX), a
call drawSprite
ld a, 6
ld (posX), a
call drawSprite
ld a, 5
ld (posX), a
call drawSprite
ld a, 4
ld (posX), a
call drawSprite
ld a, 3
ld (posX), a
call drawSprite
ld a, 2
ld (posX), a
call drawSprite
ld a, 1
ld (posX), a
call drawSprite
ld a, 0
ld (posX), a
call drawSprite

ld a, 7
ld (posY), a
call drawSprite
ld a, 6
ld (posY), a
call drawSprite
ld a, 5
ld (posY), a
call drawSprite
ld a, 4
ld (posY), a
call drawSprite
ld a, 3
ld (posY), a
call drawSprite
ld a, 2
ld (posY), a
call drawSprite
ld a, 1
ld (posY), a
call drawSprite
ld a, 0
ld (posY), a
call drawSprite

ld a, (animCounter) ;Put counter into a
inc a ;increase a
ld (animCounter), a ;therefore increase counter
cp 5 ;animate five times
jp nz, animation

ld hl, textHello
b_call(_HomeUp) ;(CurCol) = 0, (CurRow) = 0.
b_call(_putS) ;Display String in HL

ret
animCounter:
.db $00
textHello:
.db "MADE IN ASM",0
DrawSprite:
ld ix, sprite ;Put sprite address into ix
;ld hl, plotsscreen ;First part of buffer
ld hl, 0 ;empty out the hl register
ld de, (posY) ;Get the Y position

;Check for Vertical Clipping (UP)
ld a, (posY)
ld c, $08 ;Else set the counter to 8
or a ;cp 0
jp m, clipUp ;If y-pos is negative

add hl, de ;mutliply Y by 12
add hl, de
add hl, de
add hl, hl
add hl, hl
ld bc, plotsscreen
add hl, bc
;Check for Vertical Clipping (down)
ld a, (posY) ;Get the Y Position
cp 56
jp p, clipDown ;If the sprite goes off screen
ld c, $08 ;Else set the counter to 8

;Finding the byte on the buffer where the sprite is
ld a, (posX) ;X-Position
ld de, 0 ;Empty de
bufByte:
cp 8 ;Check if less than 8
jp m, addOffsetX ;If Negative Return value (Return back)
sub 8 ;Take away 8 from 'a' register
inc de ;X Offset increase
jp bufByte ;Else repeat
addOffsetX:
add hl, de ;Add the x-offset to hl
shiftRight: ;We are bitshifting the sprite according to x, really
ld a, (posX) ;First lets see if it goes over the right side of the screen
or a ;Check if it goes over the screen
jp m, spriteLoop ;Skip if it does (If negative)

ld b, (ix) ;put sprite into b
ld a, (posX) ;put x-pos into a

ld de, 0 ;x-offset: set to zero
jp mod ;Get how many bitshifts we need (put into 'a' register)
;(For Previous Line: If it doesn't straddle on two bytes, skips to spriteLoop)
sr1:
;ld (LSD), a ;Get the amount we bitshifted by and put it into c for later use by shiftLeft
srl b ;Bitshift sprite right
dec a ;Decrease counter
or a ;cp 0
jp nz, sr1 ;If we're not done the shifting
ld (hl), b ;load sprite image into screen when finished shifting
shiftLeft: ;The byte we need to shift left (The second byte)
ld a, (posX) ;First lets see if it goes over the right side of the screen
cp 88 ;Check if it goes over the screen
jp p, spriteLoop ;Skip if it does


ld b, (ix) ;Put the sprite into b
inc hl ;X-Offset byte on buffer + 1
ld a, 8 ;Let's get the bytes we need to shift left using the number we used to shift right
sub e ;Get the left shift value (It will be negative)
;ld e, (LSD)
;sub e ;8-(# that we shifted right by) = How many left shifts we need for this byte
sl1:
sla b ;Bitshift sprite left
dec a ;Dec counter
or a ;cp 0
jp nz, sl1
ld (hl), b ;load sprite image into screen
dec hl
jp spriteLoop
drawToBuffer:
ld (hl), b ;load sprite image into screen
spriteLoop:
;ld (hl), b ;load sprite image into screen

dec c ;dec counter
ld a, c ;load counter into a

inc ix ;next sprite byte
ld de, 12
add hl, de ;next 'y' position on screen

cp $01 ;loop x8
jp p, shiftRight ;Drain the grain in the counter
b_call(_grBufCpy)
b_call(_grBufClr)
ret
clipDown:
sub 64 ;Take away 64 from Y-POS (register a)
NEG ;NEGATE IT
ld c, a ;Put that number into the counter for drawing sprites
jp shiftRight
clipUp:
ld de, plotsscreen ;Get the plotSScreen
add hl, de ;Put plotSScreen into hl
NEG ;Negate 'a' to get a positive value
CLUP:
dec a ;Counter: The amount of bytes that need to be skipped

dec c ;Remainer bytes to draw
inc ix ;Skip the byte

or a
jp nz, CLUP ;Keep skipping until we have the bytes we need to draw

jp shiftRight
mod:
ld e, a ;Get the amount we bitshifted by and put it into ** for later use by shiftLeft
cp 8 ;Check if The number is already a mutliple of eight (no need for bitshift)
jp z, drawToBuffer ;If zero just draw it without bit shifting anything
or a ;Due to technicality, 0 is not a multiple of 8
jp z, drawToBuffer ;So just do the same thing
cp 8
jp m, sr1 ;If Negative Return value (Return back)
sub 8 ;Take away 8 from 'a' register
jp mod ;Else repeat
;LSD:;leftShiftData:
.db $00
sprite:
.db %01111110
.db %10000001
.db %10100101
.db %10000001
.db %10100101
.db %10011001
.db %10000001
.db %01111110
posX:
.db 0
posY:
.db 0

end
« Last Edit: July 10, 2018, 04:17:41 am by mazhat »
  • Calculators owned: TI-83Plus, TI-84Plus
  • Consoles, mobile devices and vintage computers owned: Samsung TAB A (Cheap), DSI, Rasperry PI 3
The Mogami River.

 


You can also use the following HTML or bulletin board code to share it on your page or forum signature!


Also do not forget to check our affiliates below.
Planet Casio TI-Planet Calc.news BroniesQC BosaikNet Velocity Games