Author Topic: Another C64 loading/depacking screen . . .  (Read 3668 times)

0 Members and 1 Guest are viewing this topic.

Offline DrewPee

  • I Toast Therefore I am
  • Pentium
  • *****
  • Posts: 563
  • Karma: 25
  • Eat Cheese - It's good for you!
    • View Profile
    • Retro Computer Museum
Another C64 loading/depacking screen . . .
« on: September 13, 2006 »
I noticed that somebody (a while ago now) had written something in Blitz that looked like a C64 loading/depacking screen . . .

so i decided to try and write one using FreeBasic and tinyptc, and i think ive done it - see what you think.

I guess it aint much use to anybody but at least i have the hang of tinyptc now!!! Thanks to all you other coders on here!

DrewPee
DrewPee
aka Falcon of The Lost Boyz (Amiga)
Ex-Amiga Coder and Graphic Designer
Administrator of > www.retrocomputermuseum.co.uk

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: Another C64 loading/depacking screen . . .
« Reply #1 on: September 13, 2006 »
Nice work mate :)
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline MrP

  • Atari ST
  • ***
  • Posts: 176
  • Karma: 18
    • View Profile
Re: Another C64 loading/depacking screen . . .
« Reply #2 on: September 14, 2006 »
Not looked at this yet as im in work, but its good to see your getting the hang of tinyptc, keep up the good work

Offline DrewPee

  • I Toast Therefore I am
  • Pentium
  • *****
  • Posts: 563
  • Karma: 25
  • Eat Cheese - It's good for you!
    • View Profile
    • Retro Computer Museum
Re: Another C64 loading/depacking screen . . .
« Reply #3 on: September 14, 2006 »
Thanks guys - it took a while to stick in but I think I have it now!

DrewPee
DrewPee
aka Falcon of The Lost Boyz (Amiga)
Ex-Amiga Coder and Graphic Designer
Administrator of > www.retrocomputermuseum.co.uk

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
Re: Another C64 loading/depacking screen . . .
« Reply #4 on: September 14, 2006 »
big thumbs up mate for taking the dive into tiny ptc as i know it can be a bit daunting at first good stuff  :)
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17412
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Another C64 loading/depacking screen . . .
« Reply #5 on: September 14, 2006 »
The trick with tinyptc is to remember that it soesn't matter how the colours get into the screen array. Actually I was a bit confused about the way you'd coded it, it seemed to run slowly, I remember the loading bars being a little bit faster so I took the liberty of optimising the code a little, though your cool technique stays intact :)

Code: [Select]
'
' C64 DEPACK SCREEN BY DREWPEE, SOME OPTIMISATIONS BY SHOCKWAVE.
'

option explicit
#define PTC_WIN
#Include Once "tinyptc.bi"
Const XRES=640
Const YRES=480
Dim Shared ScreenBuffer(XRES*YRES)
If(ptc_open("C64 unpacking by DrewPee",xres,yres)=0) Then
End -1
End If

dim as uinteger y,blk,rgbb,XW
dim as ubyte ranr,rang,ranb
DIM SHARED PP AS INTEGER PTR
do
    ranr=(INT(RND(1)*255)+1)
    rang=(INT(RND(1)*255)+1)
    ranb=(INT(RND(1)*255)+1)
    rgbb=rgb(ranr,rang,ranb)
    XW=xres   
    for y=0 to yres-1
        blk=rnd*(100)
        if blk>90 then
                ranr=(INT(RND(1)*255)+1)
                rang=(INT(RND(1)*255)+1)
                ranb=(INT(RND(1)*255)+1)
                rgbb=rgb(ranr,rang,ranb)
        end if
    if y<yres then
    PP = @ScreenBuffer(Y*XRES)
    asm
        mov eax,dword ptr[rgbb]
        mov ecx, [XW]
        mov edi, [PP]
        cld
        rep stosd
    end asm   
    end if
    next y
    ptc_update @screenbuffer(0)
LOOP UNTIL INKEY$<>""
ptc_close
end

Please note that it is not the asm that has made a huge difference here, it's the way your code was structured. I've broken it down for you;

GENERATE BLOCK SIZE AND COLOUR
NOTE THAT THIS IS WHERE YOUR OUTER LOOP STARTS!
do
    blk=(INT(RND(1)*20)+1)
    ranr=(INT(RND(1)*255)+1)
    rang=(INT(RND(1)*255)+1)
    ranb=(INT(RND(1)*255)+1)

DRAW **ONLY** THE BLOCK YOU CALCULATED ABOVE   

    for y=top to top+blk
         for x=0 to xres-1
            feedpixels(x,y,rgb(ranr,rang,ranb))
         next x
    next y

MOVE THE BLOCK OFFSET AND BOUNDS CHECK;       
    top=top+blk
    if top-blk>=564 then top=0
UPDATE THE SCREEN AFTER ONLY DRAWING ONE BLOCK!!!!!!!       
    ptc_update @screenbuffer(0)
LOOP UNTIL INKEY$<>""


In fact if you'd put the command Erase ScreenBuffer after the ptc update your problem would become clearer as you'd see that you only drew one raster block per update.
If that was the effect that you intended to do though I sincerely apologise for my meddling and I'll stfu :)
Shockwave ^ Codigos
Challenge Trophies Won:

Offline DrewPee

  • I Toast Therefore I am
  • Pentium
  • *****
  • Posts: 563
  • Karma: 25
  • Eat Cheese - It's good for you!
    • View Profile
    • Retro Computer Museum
Re: Another C64 loading/depacking screen . . .
« Reply #6 on: September 14, 2006 »
Thanks for the optimisations Shockwave - the effect did need to be faster I guess.
I just need to do something with it now!!!!

Drew
DrewPee
aka Falcon of The Lost Boyz (Amiga)
Ex-Amiga Coder and Graphic Designer
Administrator of > www.retrocomputermuseum.co.uk

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17412
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Another C64 loading/depacking screen . . .
« Reply #7 on: September 14, 2006 »
Yes indeed :) A demo would be nice mate.
Shockwave ^ Codigos
Challenge Trophies Won: