Jump to content
IGNORED

How to do a splash screen while loading an executable


Recommended Posts

Help!

I want a title screen while my BGP picture viewer is loading. If you save a file with the k function of dos2.5 you can optionaly set an init and a run address.

So my code starts with

 

Initad

Splash screen setup code..

Set display list and colour registers

Set system timer to zero

Rts

 

Runad

Wait until high byte 19 of timer has changed to get long enoug display time in case of emulator fast load

Main program code

.....

Endad

 

Then load and save the code in dos 2.5 with k d:xxxx.xex,initad,endad,initad,runad

 

If i load the xex in the emulator it works fine but on real iron the splash screen starts only after the whole loading is done.

Then i saved both parts out seperately and joined the two files into one which then worked on real atari.

 

But now suddenly with the current version, although i have not changed anything in the splash screen code the screen colours turn on only half way through loading as if critic prevents the colours to be set in vbi.. But i have set the hardware col registers in the splash routine, not just the shadows.

 

Does anybody know how to best handle this? You see this in a lot of programs so it cant be that hard...

Link to comment
Share on other sites

When disk IO is going on a bunch of stuff in Stage 2 VBlank will almost always get skipped - part of that is the storing of Display List pointer from the shadow to real register in Antic as well as the colour registers to GTIA.

 

To fix is fairly simple. Straight after storing to all of the shadow registers just have a short wait like:

 

wait lda $14 ; low byte of RTCLOCK

cmp $14

beq wait

 

You need to do that during loading for any shadow reg changes. The alternative is to store to the hardware regs as well. You'd generally do that e.g. if you were cycling a colour register continuously during the load.

 

For your delay - waiting for the 2nd byte of Rtclock to change will have variable delay. To ensure consistency, it's a good idea to set the low byte to 00.

 

Since you have that wait loop early on, you could just change it to:

 

lda #0

sta $14

wait1 lda $14

beq wait1

  • Like 1
Link to comment
Share on other sites

In any case I always write into the hardware registers and shadows so i'm independent of vbi execution and CRITIC status.

 

If I change the DL Antic register in midscreen, there will be a disturbed frame so i wait for vcount=0 before writing out the new DL address.

I have tried with a waiting loop after the write but even with a wait of 50 jiffies my atari still doesnt react immediately. Maybe CRITIC is still on during the wait? But even if it is on the hardware writes should be visible.

 

writing zeroes into 19 and 20 at splash screen start and then checking 19 for nonzero in the main program always gives me 256 jiffies minimum waiting time. Thats 5.1 seconds for PAL.

If the loading should take longer then the splash screen will end when loading has finished.

 

I will post the exact source code tonight, maybe this will make things easier.

Link to comment
Share on other sites

Yep, writing some hardware regs at any old time can result in unwanted effects, DList pointers is an especial example.

 

The technique you describe for wait 5 second min sounds fine, of course it could potentially be slightly shorter in NTSC.

 

CRITIC should be cleared when SIO operations aren't in progress. When a loader passes control to an INIT section that should be the case.

Note of course, an in progress IRQ or masked IRQ via SEI will have the same effect as setting CRITIC.

 

Yes - that first bit of code I did was a bit wrong, was only 30 minutes out of bed at the time.

Edited by Rybags
Link to comment
Share on other sites

Ok, I got it working now! I dont know what I did wrong yesterday...

 

But if I save in DOS2.5 with k - d:filname.xex,initad,endad,initad,runad

it only works in altirra. If I load it on a real atari the splash screen starts at the end of the whole loading.

 

I have to put two files:

 

1st one: k - file1.xex,initad,runad,initad,initad

 

2nd one: k - file2.xex,runad,endad,runad,runad

 

then I join the two files into one using a short basic routine.

Only then the splash screen comes up while loading.

 

Why is that? Am I using the initad parameter wrong?

If the initad adress gets executed during loading then it should work, shouldn't it?

 

 

here's the source... sorry, the editor deletes tabs and blanks

 

INITAD

;

. ;##############################

. ; SPLASH SCREEN WHILE LOADING

. ;##############################

;

; Show Splash screen

wait00 lda vcount ; wait until vblank

. bne wait00 ; before meddling with screen

;

. lda #00

;

. ; reset system timer

. sta RTCLOK+2

. sta RTCLOK+1

. sta RTCLOK

;

. ; mute I/O

. sta SOUNDR

;

. ; set colors

. sta COLOR2 ; shadow

. sta COLPF2 ; hardware

. sta COLOR4 ; shadow

. sta COLBAK ; hardware

;

. lda #$0B ; white chars

. sta COLOR1 ; shadow

. sta COLPF1 ; hardware

;

. ; set Display List

. LDA #<loaddl

. sta sdlstl ; shadow

. sta dlistl ; hardware

. lda #>loaddl

. sta sdlstl+1 ; shadow

. sta dlistl+1 ; hardware

;

. RTS

;

loaddl ; splash screen display list

. .byte 112,112,112,112,112,112,112

. .byte 66

. .word loadscr

. .byte 2,2,2,2,2

. .byte 65

. .word loaddl

loadscr ; splash screen text

. .sbyte " "

. .byte 81,82,82,82,82,82

. .byte 82,82,82,82,82,82,82,82,82,82

. .byte 82,82,82,82,82,82,82,82,82,82

. .byte 82,82,82,82,82,69

. .sbyte " "

. .sbyte " ",124," Bugbiter APAC 239i ",124," "

. .sbyte " ",124," 256 colour Photo Viewer ",124," "

. .sbyte " ",124," ",124," "

. .sbyte " ",124," © 2014 Martin Kaspar ",124," "

. .sbyte " "

. .byte 90,82,82,82,82,82

. .byte 82,82,82,82,82,82,82,82,82,82

. .byte 82,82,82,82,82,82,82,82,82,82

. .byte 82,82,82,82,82,67

. .sbyte " "

;

. ; MAIN PROGRAM

Runad

.

.

Link to comment
Share on other sites

hmm,

 

I am no programmer, but from what I have seen so far, most XEX files use (should use?) only one run adress. The processing of two XEX files with Init should be similar to this:

 

File 1: start-adress - end-adress

init adress

File 2: start adress - end-adress (appended to the first file, e.g. with DOS copy function and /A)

if required another Init adress

run adress (of course this run-adress can be placed anywhere, right at the start, in the middle or at the very end of the program)

 

Again, I am no programmer, so I usally use routines I found in hacked programs by various programmers or routines someone did for me. These small routines only display some text in Gr. 0, 1 or 2 and they use page 4, page 6 or $2000-205x (think I did not keep the Gr. 1 title-routine, only Gr. 0 and Gr. 2). I always append programs to these routines with Superpacker on the PC or Superpacker on the A8, then I make tests, if the programs still work alright. If the appended programs do not work, I choose another title-routine or I simply add a black/blank screen routine or switch the screen off.

 

You can find my little routines here (as said before, none of them have been programmed by me; some routines were made by Fandal for me, some were made by HiasSoft for me, the basic-off routine is from Bill Wilkinson & Compute and some routines were taken from hacked programs). Take a disk / sector-editor to edit the title they should display in Gr. 0 or Gr.2 while loading; this is not nescessary for the black-screen or screen-off switch of course; the POKE65 routine switches off SIO-noise, etc.

 

-Andreas Koch.

 

small_pgm_routines.zip

Link to comment
Share on other sites

Hello,

 

A binary file depends a lot on the used DOS. Generally, it start immediately if you write something in the run vector (or something like that...) You binary file should be like this one:

 

<splash screen routine finished with RTS>

<the run vector with the splash screen start address>

<the big code file>

<the run vector with the big code start address>

 

If the second block is missing, your splash screen will be loaded but not executed.

Edited by pfeuh
Link to comment
Share on other sites

Sure.

 

this is the file that was made in one go in dos2.5 with k

k expects 4 parameters: startad,endad,initad,runad. These were given as splash,end,splash,main

The splash screen only comes up after the loading is done on real Atari. In altirra it's working ok.

FULL.XEX

 

 

this is the file that was made out of two separate files.

1st file: splash,main,splash,splash

2nd file: main,end,main,main.

Its working fine, the splash screen comes up immediately.

I guess giving initad AND startad the same address is wrong, but its working, so what the hell..

BGPVWR16.XEX

Link to comment
Share on other sites

You can reproduce the stalled splash screen for FULL.XEX in Altirra by booting from DOS and disabling Disk Drive -> SIO Patch. That makes the loading process long enough to notice that the splash screen isn't coming up during loading.

 

The reason is clear if you look at the file structure. Here is the output of Hias's ataricom utility on both executables:

$ ataricom.exe FULL.XEX
ataricom V0.30-101002 (c) 2008-2010 by Matthias Reichl <hias@horus.com>
block    1: 4380-5da6 (bytes:  6695, offset:      6)
block    2: 02e2-02e3 (bytes:     2, offset:   6705)
      INIT: 4380
block    3: 02e0-02e1 (bytes:     2, offset:   6711)
       RUN: 44b6
$ ataricom.exe BGPVWR16.XEX
ataricom V0.30-101002 (c) 2008-2010 by Matthias Reichl <hias@horus.com>
block    1: 4380-44b6 (bytes:   311, offset:      6)
block    2: 02e2-02e3 (bytes:     2, offset:    321)
      INIT: 4380
block    3: 02e0-02e1 (bytes:     2, offset:    327)
       RUN: 4380
block    4: 44b6-5da6 (bytes:  6385, offset:    335)
block    5: 02e2-02e3 (bytes:     2, offset:   6724)
      INIT: 44b6
block    6: 02e0-02e1 (bytes:     2, offset:   6730)
       RUN: 44b6

EDIT: Editor threw out the rest of my message.

 

You can see that FULL.XEX is missing an INIT after the splash screen code is loaded while BGPBWR16.XEX does have it.

 

I think what you're missing is the fact that the file is processed as a stream. The INIT segment must appear in the middle of the file if you want it to take place before the next segment is loaded. The way you were saving the file before just put the INIT address at the end of the file.

Edited by Xuel
Link to comment
Share on other sites

oh, yeah, so altirra just loaded too fast for me to notice the splash screen started at the end. I forgot that possibility.

 

Ok, I see Full.xex has INIT set to 4380 where splash starts and RUN to 44b6 where the main program starts. That's how I intended it to be.

 

But can someone please explain me why the INIT address doesnt work? I read that DOS jumps to INIT during loading and to RUN at the end.

Thats the way it should work. What is it I don't understand?

Link to comment
Share on other sites

The loader works kind of like this:

 

1) Load a segment.

2) Is INITAD set? If so, JSR to INITAD.

3) Is this the end of the file? If so, JSR to RUNAD. Done.

4) Goto 1.

 

So, you are right that INIT gets called during loading, but only if there are more segments after it.

 

Also note that setting INITAD or RUNAD is done via the same process as any other segment. It's just a two-byte segment pointing to INITAD or RUNAD.

 

Also note that if there is no RUNAD, many loaders just JSR to the start of the first segment.

Link to comment
Share on other sites

Thanks for explaining that! So I might just leave the INIT vector and just set RUN for each segment.

 

But what's the point of separate initialisation and run Vectors if they run right after each other?

You could as well jump to the main code from the initialisation code.

 

I am using Jac!'s WUDSN IDE which I just love. I don't think I'll ever go back to MAC/65.

 

Do you know if there is an easier way to produce a multi segment exe, perhaps right out of the assembler? My Basic merging solution kinda sucks.

Link to comment
Share on other sites

Do you know if there is an easier way to produce a multi segment exe, perhaps right out of the assembler? My Basic merging solution kinda sucks.

 

 

Errmm,

 

I always use Superpacker for this purpose, you can combine multiple XEX/EXE files into one COMpound file with it and you can also add Init and Run adresses as you wish/require. Superpacker is available for the A8 by Bewesoft and for the PC by TeBe, even if you do not want to pack a file, you can use it to append/merge/link files together into one standalone file (thus, no need for a Basic merging program). Superpacker on the A8 is limited to approx. 30kbytes, Superpacker on the PC seems to be limited to your PC RAM (some gigabytes ?), at least I have not found an A8 file yet that was too big for the PC version of Superpacker.

 

Here is the PC version: http://madteam.atari8.info/uzytki/sp.7z

(this is the latest version 4.1) and attached you will find the A8 version (sorry, comes without manual).

-Andreas Koch.

 

PACKER1.ATR

Edited by CharlieChaplin
Link to comment
Share on other sites

You're right that RUNAD isn't strictly necessary. It's just a convenience in that you could set it as the very first segment and it won't be called until the last segment has finished loading whereas INIT is called after every segment.

 

More precise pseudo code would be as follows:

 

1) Set RUNAD to point to RTS

2) Set INITAD to point to RTS

3) Load next segment

4) Call INITAD

5) Is this the end of the file? If not, goto 2.

6) Call RUNAD

 

You can easily make multi-segment executables in MADS or XASM as follows:

 

 

   org INIT
   ...init code...
   rts
   ini INIT
   org RUN
   ...main code...
   rts
   run RUN

 

The "ini ADDR" and "run ADDR" keywords are just shorthand for the following:

 

 

   org INITAD
   dta a(ADDR)

 

or:

 

 

   org RUNAD
   dta a(ADDR)
Link to comment
Share on other sites

That's cool! I really would like to have my source make the complete file by itself.

 

As I'm an old MAC/65 Guy I use ATASM in Wudsn because it uses the same syntax. Du you know if or how this can be done with ATASM? I don't knmow if thwere's an INI od dta pseudo opcode there...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...