Join us on Discord!
You can help CodeWalrus stay online by donating here.

FastClr routine : a very fast way to clear screen !!!

Started by unregistered, June 11, 2016, 09:08:29 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Dream of Omnimaga

  • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

unregistered

Better method, again  ;D

Yesterday I discussed with PT_ another method :

its aim is to clear while create coding !!

"Push de" is coded $d5
with "ld de,$d5d5d5",  a "push de" will create 3 "push de" !!..That's the trick :)

In 8bpp mode, whe have to clear 76800 bytes , using PUSHs we need 76800/3=25600 PUSHs
As a PUSH creates 3 PUSHs, we just need to clear/create 1/4 of 25600 = 6400 PUSHs :)
Then we will go inside this huge group of 19200 bytes $d5 to complete the 3/4 remaining to clear !!
Of course, we will write at the very end "ld sp,hl \ ei \ ret" to be able to quit the routine ;)

Here's the routine:
        ld      bc,$c9fbf9      ; pour écrire "ld sp,hl \ ei \ ret"
        ld      de,$d5d5d5      ; $d5=code de "push de"
        or      a               ; en PUSHant $d5d5d5, on crée du code
        sbc     hl, hl          ; (des PUSHs qui créent des PUSHs !!)
        di
        add     hl, sp          ; mémorise SP dans HL
        ld      sp,$D52C03
        push    bc
        ld      b,52
PushLp: .fill 123,$d5           ; 6400 = 52*123+4
        djnz    PushLp          ; là, on "PUSH DE" 6400 fois ( = 1/4 de l'effaçage écran)
        push    de              ; pour ensuite aller dedans!! (car c'est aussi du code!)
        push    de              ; (afin de de poursuivre l'effaçage des 3/4 restants de l'écran)
        push    de
        push    de
        jp      $d52C00-(6400*3)

length = 153 bytes only !

16+16+4+8+4+4+16+10+8+(123*10+13)*52-5+10+10+10+10+17+19200*10+4+4+21= 256803 states !!!

The constraint is we must clear using byte $d5
But that may not be a problem as , in 8bpp mode, we can modify the palette ;)

Snektron

  • Calculators owned: TI-84+
Legends say if you spam more than DJ Omnimaga, you will become a walrus...


Dream of Omnimaga

At this rate, you'll have a clear screen routine that it so fast that it will take a negative amount of time to execute, causing time travel of some sort... O.O
  • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

tr1p1ea

I like the idea of using the instruction byte as the cleared index, very clever :).

c4ooo

This is amazing  O.O
wont all the pushes cause a stack overflow?

MateoConLechuga

#21
 :-X
Quote from: c4ooo on July 05, 2016, 06:22:57 AM
This is amazing  O.O
wont all the pushes cause a stack overflow?
This is literally a modified example from asm in 28 days. If you read the section, it will describe more of what it is doing :)

Of course, I do like the code creation and then executing aspect. Although it would be difficult to implement correctly, it is pretty neat.

c4ooo

Quote from: MateoConLechuga on July 10, 2016, 12:51:41 AM
:-X
Quote from: c4ooo on July 05, 2016, 06:22:57 AM
This is amazing  O.O
wont all the pushes cause a stack overflow?
This is literally a modified example from asm in 28 days. If you read the section, it will describe more of what it is doing :)

Of course, I do like the code creation and then executing aspect. Although it would be difficult to implement correctly, it is pretty neat.
Ohh you mean page 10? http://tutorials.eeems.ca/ASMin28Days/lesson/day10.htm
TBH i never fully read that guide, merely skimmed over the pages that i needed :P

Powered by EzPortal