Author Topic: Perfect Grayscale - Tutorial  (Read 20698 times)

0 Members and 1 Guest are viewing this topic.

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: Perfect Grayscale - Tutorial
« Reply #15 on: March 10, 2011, 07:38:34 pm »
well with programming its either you have quicker programs but longer code or slower but easier to code programs but slower (little ironic in a way huh?). but i mean assembly definitely gives you more flexibility and if you are good with it and almost productive as a person in say c good for you! i on the other hand have to program in c i dabble in assembly but i dont have the patience. so i respect that and that sort of work and dedication.

Generally speaking. Of course, some people (like me) are freaks of nature and can't understand high level computer languages like C.* I'm not nearly as fast as thePenguin at ASM though. I don't think I've ever written 1000 lines in four hours in any language.

I've actually had to slow down more programs than I've had to speed up, though. Not sure if too many languages other than Hex and ASM have the problem :p
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

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: Perfect Grayscale - Tutorial
« Reply #16 on: March 11, 2011, 02:55:43 am »
Lol yeah in Axe sometimes I felt the stuff I tried just ran way too fast for my needs. I worried that if I ever made a RPG that it would be filled with pauses. X.x

Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: Perfect Grayscale - Tutorial
« Reply #17 on: March 13, 2011, 12:09:15 pm »
I don't think I've ever written 1000 lines in four hours in any language.
I think I've only ever wrote more than 1000 lines of code once, on Exodus (and to get that I had to add the lines of Exodus with the lines from its level editor).   ::)

I never had the time to read this until now, but it's an incredible tutorial.  Thanks, Brian! ;D

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Perfect Grayscale - Tutorial
« Reply #18 on: March 13, 2011, 12:19:39 pm »
I don't think I've ever written 1000 lines in four hours in any language.
I think I've only ever wrote more than 1000 lines of code once, on Exodus (and to get that I had to add the lines of Exodus with the lines from its level editor).   ::)

Back when I had time to kill I made >2000-line programs in a single sitting, deleted them immediately, and recoded them again. If only I had that kind of time right now :P




Offline ZippyDee

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 729
  • Rating: +83/-8
  • Why not zoidberg?
    • View Profile
Re: Perfect Grayscale - Tutorial
« Reply #19 on: March 24, 2011, 07:27:29 am »
I don't think I've ever written 1000 lines in four hours in any language.
I think I've only ever wrote more than 1000 lines of code once, on Exodus (and to get that I had to add the lines of Exodus with the lines from its level editor).   ::)

Back when I had time to kill I made >2000-line programs in a single sitting, deleted them immediately, and recoded them again. If only I had that kind of time right now :P

....................That's just insane. I have a BASIC program I wrote a few years ago that's 5k+ bytes, but I'm not sure how many lines. It was a calculator version of the game Sim Cinema, a surprisingly awesome game that only ever came out for Mac...even worse, for OS9X so the newer Macs can't even run it :\
There's something about Tuesday...


Pushpins 'n' stuff...


Offline ralphdspam

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 841
  • Rating: +38/-1
  • My name is actually Matt.
    • View Profile
Re: Perfect Grayscale - Tutorial
« Reply #20 on: May 17, 2011, 10:42:58 pm »
Can someone help me port this to an Axiom?  When I added a couple of commands, it started displaying glitch lines.  

I think it is because the index registers take too many clock cycles.  :\
Code: [Select]
intReturn:
ex af, af'
exx
ei
ret
initInterrupt: ;double label just for good measure

goodInterrupt:
ld a, $40
out ($30), a ;10922 Hz
ld a, 2
out ($31), a
ld a, 178 ;<- this is the number you change for delay
out ($32), a

ld hl, plotsscreen ;use axe buffers
ld ix, appbackupscreen ;\
call grayCopy
jr intReturn



;###################################
grayCopy:
DWAIT
ld a, 7
out ($10), a ;row major


ld a, (grayCarry)
rra
ld a, (grayMask) ;9 bit cycle
push af

ld e, $80
outerGray:
DWAIT
ld a, $20 ;always start on left
out ($10), a

DWAIT
ld a, e
cp $C0 ;quit at row 64
jr nz, notDoneYet

pop af
ld (grayMask), a
ld a, 0
rla
ld (grayCarry), a
DWAIT
ld a, 5 ;back to column major for
out ($10), a ;good measure
ret
notDoneYet:
out ($10), a

ld b, 12

grayLoop:
pop af
rra
push af
ld d, a
and (hl) ;get dark byte
ld c, a
inc hl
ld a, d
cpl
and (ix) ;get light byte
inc ix  ;;=========When I changed this, it started glitching up.
;and (hl)
;inc hl

or c

ld c, a
DWAIT
ld a, c
out ($11), a
djnz grayLoop

pop af
rla
push af

inc e
jr outerGray



grayCarry:
.db 1
grayMask: ;9 bit cycle
.db %01101101
« Last Edit: May 17, 2011, 10:48:06 pm by ralphdspam »
ld a, 0
ld a, a

Offline Hot_Dog

  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3006
  • Rating: +445/-10
    • View Profile
Re: Perfect Grayscale - Tutorial
« Reply #21 on: August 29, 2011, 10:05:28 pm »
This is an excellent tutorial, and it certainly helped me make MY grayscale flickerless :D

Offline Spenceboy98

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 547
  • Rating: +59/-2
    • View Profile
Re: Perfect Grayscale - Tutorial
« Reply #22 on: March 19, 2012, 08:32:23 pm »
Okay, so this makes grayscale flickerless? I don't know how to use this tutorial. How?
I like milk.

Offline Darl181

  • «Yo buddy, you still alive?»
  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3408
  • Rating: +305/-13
  • VGhlIEdhbWU=
    • View Profile
    • darl181.webuda.com
Re: Perfect Grayscale - Tutorial
« Reply #23 on: March 19, 2012, 08:43:56 pm »
This is for Asm coders, and would be next to impossible to implement properly with Axe, even as an axiom.

Tho afaict the general theory is this:
Basically to get rid of the flickering you write to the screen (in Axe that's what DispGraph does) at the same rate that the physical screen displays what's written to it.  It's around 60 times a second, but it varies from calc to calc.
You can kind of do this in Axe by putting a Pause 40 or something like that if there's nothing else but DispGraph^* in the loop, but don't expect it to be perfect ;)
« Last Edit: March 19, 2012, 08:46:47 pm by Darl181 »
Vy'o'us pleorsdti thl'e gjaemue

Offline leafy

  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1554
  • Rating: +475/-97
  • Seizon senryakuuuu!
    • View Profile
    • keff.me
Re: Perfect Grayscale - Tutorial
« Reply #24 on: March 19, 2012, 09:24:45 pm »
I found that using Pause 9 for 4-shade works well when your game is speedy.
In-progress: Graviter (...)

Offline parserp

  • Hero Extraordinaire
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1455
  • Rating: +88/-7
  • The King Has Returned
    • View Profile
Re: Perfect Grayscale - Tutorial
« Reply #25 on: March 20, 2012, 05:30:40 pm »
How would I use interrupts to make greyscale more flickerless in Axe?

Offline NanoWar

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 140
  • Rating: +18/-6
    • View Profile
Re: Perfect Grayscale - Tutorial
« Reply #26 on: March 24, 2012, 11:17:52 am »
What needs to be changed that it works on a TI83Plus? There's no fast mode and I'm not sure about the $83 ram page, could you explain that?

Offline Eiyeron

  • Urist McEiyolobster
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1430
  • Rating: +130/-10
  • (-_(//));
    • View Profile
    • Rétro-Actif : Rétro/Prog/Blog
Re: Perfect Grayscale - Tutorial
« Reply #27 on: March 24, 2012, 12:26:23 pm »
What does Dispgraph^*

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: Perfect Grayscale - Tutorial
« Reply #28 on: March 24, 2012, 01:46:55 pm »
What needs to be changed that it works on a TI83Plus? There's no fast mode and I'm not sure about the $83 ram page, could you explain that?
Yeah, I am still not sure why page 83 is needed (which isn't available on the 83+).

Offline thepenguin77

  • z80 Assembly Master
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1594
  • Rating: +823/-5
  • The game in my avatar is bit.ly/p0zPWu
    • View Profile
Re: Perfect Grayscale - Tutorial
« Reply #29 on: March 24, 2012, 08:47:17 pm »
What needs to be changed that it works on a TI83Plus? There's no fast mode and I'm not sure about the $83 ram page, could you explain that?

You'll have a great deal of trouble get perfect grayscale on an 83+BE in the true sense with this method because there are several things at work against you.
1. Without fast mode, you're going to have to make a very optimized routine, this is totally possible
2. You don't need the extra ram page, it just makes things much cleaner for my grayscale routine. Writing your own routine would allow you to use whatever ram you want, (probably two $300 byte buffers) but if you insist on using mine, you can clear out the first $600 bytes of ram through some hackery (though, TI-OS won't work in this state.)
3. Finally, probably the one that really strikes down this method, is the fact that the 83+ does not have crystal timers. The best you could do on it (if you plan to do things besides display pictures) is to use the regular interrupts which default run at 118Hz. For very specific cases, you could use every other interrupt for grayscale, but this will only work at a screen refresh of exactly 59Hz. Most likely, you're going to want to go with the interrupts running at 560Hz. Using this method, you'd have to use variable skips and delays to ensure the grayscale draws occur at the proper time. This is possible with enough thought, but it would be very difficult.
(4). Combining problems 1 and 3, anything that runs with perfect grayscale is going to run very slow. The step 3 delay design is going to burn a lot of t-states waiting for the proper time to go. Then, since it's only running in 6Mhz mode, you can get way less done when the actual program is running.

So, verdict. Possible - in theory. Difficulty - high. To give you an idea, this ranks up there with calc84's sound routines in ti-boy.
zStart v1.3.013 9-20-2013 
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112