Author Topic: I just got done reading!  (Read 4882 times)

0 Members and 1 Guest are viewing this topic.

Offline juha.kivekas

  • LV0 Newcomer (Next: 5)
  • Posts: 4
  • Rating: +2/-0
    • View Profile
I just got done reading!
« on: March 31, 2013, 12:28:32 pm »
I just got done reading the TI-83plus assembly guide for absolute begginners, so im currently working on something thats propably way too hard and ambitious for me. I think im going to flip this place around for all the info i need to make my very first puzzleish game. i've done it before in other languages so that should help me a little.
Im going to share something from my past projects that quite perfectly merged with calculator programming due to the forced lo-fi graphics. Last summer i implemented some dithering algorithms on BMP files in java. I altered the program so it printed the file as ASM source code, so that i could then wiev them on my calc.
About Dithering: http://en.wikipedia.org/wiki/Dithering#Digital_photography_and_image_processing
Original BMP image:

The picture drawn on my TI-84+, and me in my fur hat:


Juha Kivekas, from frozen finland

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: I just got done reading!
« Reply #1 on: March 31, 2013, 12:32:58 pm »
Wow, that looks pretty nice o.o I have very little knowledge in dithering stuff, but you will definitely find people here with assembly knowledge! So, what are you working on?

Also, welcome to Omni, here are some
!peanuts

Offline juha.kivekas

  • LV0 Newcomer (Next: 5)
  • Posts: 4
  • Rating: +2/-0
    • View Profile
Re: I just got done reading!
« Reply #2 on: March 31, 2013, 12:45:36 pm »
Well im working on emtying the plotsscreen first, because my picture keeps staying in the background when other programs draw sprites. The sprites thenagain are to be panels of my lights out puzzle game. Lights out is a classic handheld game. Here its made as a SVG with embedded javascript:
www.guttula.com/LightsOut.svg
Might not work, so wikipedia:
http://en.wikipedia.org/wiki/Lights_Out_(game)

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: I just got done reading!
« Reply #3 on: March 31, 2013, 01:26:21 pm »
hmm, one way  to clear plotSScreen uses the fact that it is 768 bytes, so you can do:
Code: [Select]
     ld hl,plotSScreen
     ld bc,768
Loop:
       ld (hl),0
       inc hl
       dec bc
;test if bc=0
       ld a,b
       or c
       jr nz,Loop
     ret
That is a routine that has a lot of optimising that can be done to it, but it might be easier to follow than some of the following.
Spoiler For Spoiler:
Code: [Select]
;alter the above code, saving 2300 t-states
     ld hl,plotSScreen
     ld bc,300h    ;300h = 768. So C=0, B=3
     ld a,c
Loop:
       ld (hl),a     ;1 byte, 7 cycles, compared to 'ld (hl),0' which is 2 bytes, 10 cycles
       inc hl
       dec bc
;test if bc=0
       ld a,b
       or c
       jr nz,Loop
     ret
Code: [Select]
;alter the above code to replace everything after 'inc hl'
;saves 7675 t-states, so 9975 t-states saved in all so far. Also a few bytes smaller.
     ld hl,plotSScreen
     ld bc,300h    ;300h = 768. So C=0, B=3
     ld a,c
Loop:
     ld (hl),a
     cpi            ;not using it for its inteaded use. Still, increments HL, decrements BC, checks if BC is 0
     jp pe,Loop
     ret
;25378 t-states, 14 bytes
Here is a different approach:
Code: [Select]
     ld hl,plotSScreen
     ld bc,3    ;768 = 300h, but here we load 3 into C, 0 in B
     sub a      ;set A=0, more optimised than 'ld a,0'
Loop:
       ld (hl),a
       inc hl
       djnz Loop
       dec c
       jr nz,Loop
     ret
;15 bytes, 19789 t-states
And probably the best method for speed and size:
Spoiler For Spoiler:
Code: [Select]
     ld hl,plotSScreen
     ld (hl),0
     ld de,plotSScreen+1
     ld bc,767
     ldir
     ret
;13 bytes, 16152 t-states

Offline juha.kivekas

  • LV0 Newcomer (Next: 5)
  • Posts: 4
  • Rating: +2/-0
    • View Profile
Re: I just got done reading!
« Reply #4 on: March 31, 2013, 01:54:37 pm »
First i was looking for a function to B_CALL but decided to build my own. Well, i made up something quite close to the ones you suggested:
Code: [Select]
EmptyBuffer:
LD BC,768
LD A,0
LD HL, plotsscreen
BufferLoop:
LD (HL),A
INC HL
DEC BC
CP C
JR NZ, BufferLoop
CP B
JR NZ, BufferLoop
B_CALL _GrBufCpy
ret
Thanks!

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: I just got done reading!
« Reply #5 on: March 31, 2013, 02:11:05 pm »
Aha, nice! The way you used A for two purposes is clever. You can also use 'xor a' or 'sub a' as a clever way of setting A=0. It saves a byte, among other things.

Offline Stefan Bauwens

  • Creator of Myst 89 - סטיבן
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1799
  • Rating: +162/-24
  • 68k programmer
    • View Profile
    • Portfolio
Re: I just got done reading!
« Reply #6 on: March 31, 2013, 02:16:32 pm »
Hi there. Welcome here. :D
I'm not "acquainted" with dithering-stuff.(I mean, I know what it is, but I don't know much of the logic behind it).

I wish you luck with all your programs. I personally am not (yet?) an assembly coder, but I'm sure you'll find enough here that do.
!peanuts


Very proud Ticalc.org POTY winner (2011 68k) with Myst 89!
Very proud TI-Planet.org DBZ winner(2013)

Interview with me

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: I just got done reading!
« Reply #7 on: March 31, 2013, 06:23:27 pm »
Heya and welcome here :D. Nice to see a new assembly programmer around :D

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: I just got done reading!
« Reply #8 on: March 31, 2013, 09:24:28 pm »
Welcome to omnimaga!
Have fun losing the game with your stay!
!peanuts

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline chickendude

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 817
  • Rating: +90/-1
  • Pro-Riot Squad
    • View Profile
Re: I just got done reading!
« Reply #9 on: March 31, 2013, 11:41:19 pm »
What about:
Code: [Select]
clearGbuf:
ld b,64 ;7t - clear 64 rows
ld (saveSP),sp ;20t - save the SP with SMC
ld hl,0 ;10t - we're going to push hl, so it will push two 0's wherever the stack is pointing (the gbuf)
ld sp,plotSScreen+767 :10t - remember, the stack works backwards, so start at the end of gbuf
clearLoop:
push hl ;11t - 2 each push clears 2 bytes
push hl ;11t - 4
push hl ;11t - 6
push hl ;11t - 8
push hl ;11t - 10
push hl ;11t - 12 erase one row
djnz clearLoop ;13/8t - repeat 63 times
saveSP = $+1
ld sp,$0000 ;10t - restore sp (the $0000 will get overwritten with SMC)
ret
...just over 5000 t-states :P
The bcall btw is _GrBufClr.

EDIT: But the most common method is by far the ldir one. The bcall is fine, too, but if you need a bit more speed the ldir routine is pretty small and much quicker than the bcall.
« Last Edit: March 31, 2013, 11:45:53 pm by chickendude »

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: I just got done reading!
« Reply #10 on: April 01, 2013, 06:15:05 am »
That is always an awesome way to do it XD

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: I just got done reading!
« Reply #11 on: April 01, 2013, 09:32:03 pm »
Welcome to Omnimaga juha.kivekas. Nice use of dithering there. ^^