Jump to content
IGNORED

Programming platforms


ac.tomo

Recommended Posts

You will notice there's an absence of an unconditional branch instruction i.e. BRA LOOP

 

This can be simulated with a simple macro, it wastes 2 cycles, but it does the job.

see this simple example:- it clears the overflow flag then tests if its clear and branches.

 

The main reason for using this instead of a JMP is it makes the code relocatable

 

20       .MACRO BRA 
30       CLV 
40       BVC %1
50       .ENDM 


60       *=  $0600
70       LDA $CC
80       STA $CB
90        BRA  ZZ
0100 DAT  .BYTE 10,10,20,30,40
0110 ZZ  LDA #22
0120     STA $CC
0130     RTS 

  • Like 1
Link to comment
Share on other sites

thanks for that. Please can someone remind me of the syntax to obtain the hi and lo bytes of a given address, ie:

 

                    org $2000

 

delay_ptr      = $cb

 

                    lda delay hi-byte

                    sta delay_ptr+1

                    lda delay lo-byte

                    sta delay_ptr+0

 

delay            .byte 'zzzzzzzz'

 

I'd like to know the proper syntax for this method, I don't wish to use any macro's or non (normal) assembler mnemonics, thankyou.

Edited by ac.tomo
Link to comment
Share on other sites

Well, the last couple of days I've been working on a small demo I wanted to show intermediate programmers, it's not a difficult routine (moving coloured bars up and down the screen). I have actually done this routine years ago (in a demo called EGO demo), excuse the use of the word EGO, I didn't know it was such a vain word at the time (!!). Anyway, this time, the routine has been coded a little bit different, it's more complex, but it is far better, but for some unknown reason(s) it's not working as it should! I've tried to debug it and although I have found a couple of bugs it still isn't working. In fact, I've experimented by putting different slices of code in particular areas of the routine to iron out the problems, but the MADS assembler is NOT doing quite what it should. For example;    "loop     jmp loop"      wasn't even working as it should!

Anyway, as I just can't seem to find what the problem is I've uploaded it for other programmers to see if they can find what is wrong. I am new to MADS (and in fact ASSEMBLERS in general) (so that could be a contributing problem lol).

 

The program is broken down into 5 parts:

 

initiation and main loop.

 

jsr routines:

jsr move_bars                        according to given positions and flag directions (also set delays before moving on each position)

jsr zero_mem                         zero the memory before:

jsr put_bars                           poking the bars into the given area of memory to fly

jsr fly_mem                           actually put the memory into the colr register and $d4oa (wsync) (fly the memory)

 

The assembly listing has loads of comments for ease of understanding, and the 'labels' are easily named. PLEASE.... Someone show me where I'm going wrong.

 

EDT: I haven't actually finished putting the correct data into the prog. yet, but that can wait for now...

 

bars.asm

Edited by ac.tomo
Link to comment
Share on other sites

Have you got your "#50"'s confused with 80, i.e. they should be $50?

the giveaway could be line 101:

cpy #50            ;size of fly_mem

After the 'cont' label you are using the ytab values for each bar to index into the delay areas, but these are only 50 in size whereas your initial ypos values go up to 80.

So even then, the size of fly_mem is 96 and the max value you want as a ypos offset is 80 as you'll add 16 (well 0-15) to it.

some recommendations:

1) where you are repeating constant values such as '50' then define that as a constant and use that instead, i.e. one place can then change all. e.g.

fly_mem_size = 96
bar_size = 16
max_ypos = (fly_mem_size - bar_size)

2) place labels on their own line, this makes the mnemonics line up better and easier to read (my personal preference, even in MADS, is to end the label with a colon)

mov_dwn inc ypos,x        ;inc current y pos.
    lda ypos,x        ;once #50 reached

->

mov_dwn:
    inc ypos,x        ;inc current y pos.
    lda ypos,x        ;once #50 reached

3) most assemblers will have a 'repeat' feature, so where you want to 'fill' a buffer with a value use that. e.g.

fly_mem_size = 96
...
fly_mem:
:fly_mem_size .byte "0"

 

Edited by Wrathchild
with have -> will have
Link to comment
Share on other sites

Just something I do to try reduce those sort of errors is the following 

 

             *=  $0600
             LDY #0
LOOP     LDA ($CB),Y
            STA ($CE),Y
            CPY #MEMEND-MEM ; use labels to define the size
            BNE LOOP
RTS
MEM      .BYTE 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
            .BYTE 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
MEMEND

Link to comment
Share on other sites

Right, many thanx for your input all, a couple of those CMPared values were wrong and there's no problem with MADS, but the biggest and main problem that I've discovered is that my program doesn't work with Altirra. I loaded it into the atari800win emulator and it works perfectly fine. Anyone know the reason for this?

Anyhow, I've uploaded a perfectly fine working copy of this demo especially aimed at intermediate programmers for their interest. Remember though, it wont work on Altirra, only atari800win em.

bars.xex bars.asm

Link to comment
Share on other sites

Huh? I haven't looked at the assembly code yet, but here it runs exactly the same on atari800 4.2.0, and Altirra 3.90. What do you mean by "it wont work"? What does it not do that you are expecting?

 

Edit: the only thing I see "wrong" is that the upper and lower border "wiggle" by one scan line, which is probably due to you syncing to VCOUNT.

Edited by ivop
Link to comment
Share on other sites

1 hour ago, ivop said:

Huh? I haven't looked at the assembly code yet, but here it runs exactly the same on atari800 4.2.0, and Altirra 3.90. What do you mean by "it wont work"? What does it not do that you are expecting?

 

Edit: the only thing I see "wrong" is that the upper and lower border "wiggle" by one scan line, which is probably due to you syncing to VCOUNT.

On my Altirra it puts the coloured bars up on the screen but does not move them, whereas on atari800win there's no problem at all. I do have 2 copies of Altirra on my laptop, 1 inside the eclipse environment (the 1 that calls up when you compile and run your assembly programs) and another on my desktop (of which I use for BASIC programming). Could this be a problem?

 

EDT: I just loaded my demo onto my other copy of Altirra and it works fine. Obviously I need to replace Altirra (in eclipse) with my other, anyone foresee any problems?

EDT OOPS: I just tried changing the Altirra and I've balls it up completely, I renamed the old (orig eclipse altirra) to put the other altirra in, but it didnt work. So, I put the original back and it doesn't work at all now, perhaps I've got the filename wrong, any input please.

EDT (again): I've managed to put the old Altirra back but still have the problem that this program doesnt work on it.

Edited by ac.tomo
Link to comment
Share on other sites

1 hour ago, ivop said:

Perhaps you should download a fresh zip from http://www.virtualdub.org/altirra.html

 

Unzip it in a newly created directory. Then point your development environment to that binary.

 

Edit: and you need to setup the new Altirra instance with the right OS ROM files.

Seems a bit too technical for me! When you say 'point the environment to' the binary, do you mean to change the existing Altirra file to a 'shortcut' to the newly downloaded one? Concerning the OS files, I've always thought that they come with Altirra?

Link to comment
Share on other sites

4 minutes ago, ac.tomo said:

Seems a bit too technical for me! When you say 'point the environment to' the binary, do you mean to change the existing Altirra file to a 'shortcut' to the newly downloaded one?

Sorry, I should have been more specific. I assume you start Altirra from within Eclipse. Somewhere in the settings it should have a path to which Altirra binary it uses. Do you use WUDSN?

 

I also assumed you know how to unzip a file to a specific directory.

                   

4 minutes ago, ac.tomo said:

Concerning the OS files, I've always thought that they come with Altirra?

Phaeron (the author) has gone to great lengths to reimplement both the OS and BASIC, but they are not 100% the same as the original ROMs. But in your case, I doubt this has anything to do with it. It should work with a standard Altirra 3.90 install, and select 800XL, 64kB.

 

Link to comment
Share on other sites

8 minutes ago, ivop said:

Yes, I do. Perhaps @JAC! or WUDSN users can help you better. But I expect there's a path somewhere that points to the Altirra.exe binary.

I've just had a good look, I can find the path to my program, but not to Altirra or anything else.

 

EDT: I did find 'Altirra' as it's default emu., but couldn't change it.

Edited by ac.tomo
Link to comment
Share on other sites

43 minutes ago, JAC! said:

Menu: Windows/Preferences and then here.

prefs.thumb.png.3900c259b73c3b1d3af2a2a57cba9ebe.png
 

 

 

Thankyou for that JAC!, I'll have a look at that now shortly, but in the meantime here's the coloured_bar routine without the $d40a glitch, I just STA $d40a in between lines 37 and 38.

 

bars.xex

Edited by ac.tomo
Link to comment
Share on other sites

Thankyou for that info to change the path for Altirra, there's something weird going on here: I followed your steps so that WUDSN opens my other (1st) Altirra64 which is in a completely different folder and it works fine (other than prompting me to cancel the script or something(!!)), BUT when I put (my 1st) Altirra64 (the 1 I just said works) file into the original WUDSN/Altirra folder - it doesn't work. It loads, but doesn't work properly (as mentioned earlier (not moving the bars)). Does anyone understand what's going on here???

Edited by ac.tomo
Link to comment
Share on other sites

2 minutes ago, ivop said:

If I understand you correctly, you are moving around binaries? Or full installation directories of Altirra? You probably can't move just the binary.

I'm thinking that. In the original WUDSN Altirra folder there are a couple of other files that I think are also loaded, but because they aint in my other (2nd) folder it cant find anything else, and so isnt loading anything else. This seems to say that 1 or more of those accompanying files are faulty. That's the only conclusion I can think of.

Link to comment
Share on other sites

I had a little tinker around and somehow I now have a working copy of Altirra within WUDSN. Thanks all for your help, hope you enjoy the little demo. It's well explained and can be changed to what you like; you can have more or less bars, larger or smaller bars, different background, different speeds and position delays, mixed bar directions, and with a little addition to the routine you can achieve other little effects. Have fun.

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...