Jump to content
IGNORED

more asm help requested


eflake

Recommended Posts

I'll admit I don't have the best grasp on it or how it works, but i shudder thinking about going back to atari basic.

 

I have data

 

    .local gfx
xscr    .byte "A!!!a##########FFFF################a!!!A"
    .byte "#+ ++++++++++++++++++++++++++++++++++ +#"
    .byte "++++++++++++++++++++++++++++++++++++++++"
    .byte "++++++++++++++++++++++++++++++++++++++++"

 

trying to figure the best way to do a poke textaddress+y*40+x to display byte by byte to the screen.

 

I tried this, not sure how to get it to the next 40-byte row of data.

 

c0    ldy #0  ;start on first page
yLOOP   LDA  gfx.xscr,Y  ;get a byte
 

        STA  (sm_ptr),y 
    iny
    cpy #40
    bne yLOOP

    inx  ;<<<  ???
    cpx #2
    bne yLOOP
    jmp *

 

Link to comment
Share on other sites

It all depends on what you are trying to accomplish. If you need a routine which would calculate the screen address out of x,y, then the formula you quoted "y*40+x" (plus screen address) is what you need. Notice that "y*40 = (y*32)+(y*8)", and multiplying by power of two (such as *8 and *32) may be done with multiple ASL/ROL instructions.

 

Or use the table where you will keep the addresses of screen rows.

 

If you want straight copy to the screen, then after the first loop you have to add 40 to the screen pointer, and zero Y.

Edited by drac030
Link to comment
Share on other sites

you can use the appropriate procedure from the operating system for this. an additional advantage is that you do not have to worry about different graphics or text modes and how many bytes the line takes in a given mode, the procedure will determine it itself.

 

 

rowcrs equ $54    ;Row of cursor, 1 byte        y
colcrs equ $55    ;Column of cursor, 2 bytes    x

ADRESS equ $64    ; ZP
CONVRT equ $F5AC  ; XLOS


do it:

 

lda #X-cords
sta colcrs
lda #Y-cords
sta rowcrs
jsr CONVRT

ldy #0
@ lda your_data,y
sta (ADRESS),y
iny
cpy len
bne @-

inc rowcrs ; next row

 

:D

 

you're welcome

 

  • Like 1
Link to comment
Share on other sites

If all you want to do is write to the screen, this is a more simple solution using CIOV calls and does

not need a call into the OS which would not work on all versions of the OS.

Ignore the line numbers, it's a partial listing using MAC/65. Should be easy to convert into whatever 

assembler you are using.

 

Hopefully this will give you an idea how to Open and Close channels and send data to a device,

in this case the screen.

0100  CIOV =  $E456

0130     JSR CHAN2   ; CLOSE CH2
0140     JSR CHANNEL ; OPEN SCREEN
0150     LDA #MESS1&255
0160     LDY #MESS1/256
0170     JSR MESSAGE
0180     LDA #MESS2&255
0190     LDY #MESS2/256
0200     JSR MESSAGE
0201     LDA #MESS3&255
0202     LDY #MESS3/256
0203     JSR MESSAGE
0304     LDA #MESS4&255
0205     LDY #MESS4/256
0206     JSR MESSAGE
0207     JSR CHAN2
0210       RTS


1520 CHAN2 LDA #CLOSE ; CLOSE CH 2
1530     LDX #$20
1540     STA $0342,X
1550     JSR CIOV
1560     RTS 


1570 CHANNEL LDX #$20 ; OPEN CH 2
1580     LDA #OPEN   ; TO SCREEN
1590     STA $0342,X ; FOR MESSAGES
1600     LDA #NAME&255
1610     STA $0344,X
1620     LDA #NAME/256
1630     STA $0345,X
1640     LDA #3
1650     STA $0348,X
1660     LDA #0
1670     STA $0349,X
1680     LDA #12     ;R/W
1690     STA $034A,X
1700     LDA #0
1710     STA $034B,X
1720     JSR CIOV
1730     RTS 


1740 NAME .BYTE "E:",$9B


1750 MESSAGE LDX #$20 ; WRITE
1760     STA $0344,X ; MESSAGES
1770     TYA         ; TO SCREEN
1780     STA $0345,X
1790     LDA #PUTREC
1800     STA $0342,X
1810     LDA #120
1820     STA $0348,X
1830     LDA #0
1840     STA $0349,X
1850     JSR CIOV
1860     JSR DELAY
1870     RTS 
1930 MESS1 .BYTE "A!!!a##########FFFF################a!!!A",$9B
1940 MESS2 .BYTE "#+ ++++++++++++++++++++++++++++++++++ +#",$9B
1940 MESS3 .BYTE "++++++++++++++++++++++++++++++++++++++++",$9B
1940 MESS4 .BYTE "++++++++++++++++++++++++++++++++++++++++",$9B

 

Edited by TGB1718
Link to comment
Share on other sites

32 minutes ago, zbyti said:

@TGB1718 poor soul... You can't deliver better solution than @xxl - remember that!

Will it run on a U1MB machine?  There's already direct jumps into OS vectors (which Atari said was shit coding practice back in 1979).  Might as well throw in some undocumented opcodes too!

Link to comment
Share on other sites

2 minutes ago, Stephen said:

There's already direct jumps into OS vectors (which Atari said was shit coding practice back in 1979).

Worst coding practice ever, one of the first things I was taught "Thou Shalt Never, NEVER, Make Direct Calls Into The OS !!!!"

Always use the supplied vectors, they are safe.

  • Like 1
Link to comment
Share on other sites

Better use SAVMSC (88,89 ($58,$59)) instead of ADRESS (which is a temporary value btw).

 

SAVMSC points to the upper left corner of the screen, i.e. the first byte of screen memory.

 

For split screens (graphics mode with text window below), you can use TXTMSC (660,661 ($294,$295)), which points to the upper left corner of the text window.

 

Link to comment
Share on other sites

And if you want to use CIO put, set ROWCRS (84/$54) and COLCRS (85,86/$55,$56) before calling CIOV to put a byte to the screen at the specified position. COLCRS is 16-bit, because it can range from 0-319 in graphics 8. Just set the MSB to 0 and let the LSB go from 0-39.

 

Edited by ivop
Link to comment
Share on other sites

35 minutes ago, ivop said:

Better use SAVMSC (88,89 ($58,$59)) instead of ADRESS (which is a temporary value btw).

 

Beat me to it, this is a better solution if CIOV is not wanted, however please remember

If you use CIOV what you put in the message bytes is what will appear on the screen,

writing directly to the screen will not produce what is in the string, have a look at the

attached screen shot, you would have to decode the screen characters into what you 

want to see.

 

 

0100 CONSOL = $D01F
0110     *=  $2000
0120 SOURCE = $CB
0130 DEST =  $CE
0140 SCREEN = $58
0150 START LDA SCREEN
0160     STA DEST
0170     LDA SCREEN+1
0180     STA DEST+1
0190     LDA #MESSAGE&255
0200     STA SOURCE
0210     LDA #MESSAGE/256
0220     STA SOURCE+1
0230     LDX #3
0240 LOOP LDY #39
0250 L1  LDA (SOURCE),Y
0260     STA (DEST),Y
0270     DEY 
0280     BPL L1
0290     JSR ADD40
0300     DEX 
0310     BPL LOOP
0320 WAIT LDA #$FF
0330     STA CONSOL
0340 LOOPW LDA CONSOL
0350     CMP #6
0360     BNE LOOPW
0370     RTS 
0380 ADD40 CLC 
0390     LDA SOURCE
0400     ADC #40
0410     STA SOURCE
0420     LDA #0
0430     ADC SOURCE+1
0440     STA SOURCE+1
0450     CLC 
0460     LDA DEST
0470     ADC #40
0480     STA DEST
0490     LDA #0
0500     ADC DEST+1
0510     STA DEST+1
0520     RTS 
0530 MESSAGE .BYTE "A!!!A##########FFFF################A!!!A"
0540     .BYTE "#+ ++++++++++++++++++++++++++++++++++ +#"
0550     .BYTE "++++++++++++++++++++++++++++++++++++++++"
0560     .BYTE "++++++++++++++++++++++++++++++++++++++++"

 

image.thumb.png.0282493649a5acb5a3786f09abf0cfcf.png

Link to comment
Share on other sites

so much fat code... and here is the version for those who care about a proper diet ;)


instruction GRAPHICS

os_graphics equ $ef9c

 

lda #mode
jsr os_graphics

 

 

instruction PLOT (for graphics mode)

os_plot equ $f1d8

rowcrs equ $54  ; y
colcrs equ $55  ; x
atachr equ $2fb ; color

 

lda #color
sta atachr
lda #x_cord
sta colcrs
lda #y_cord
sta rowcrs
jsr os_plot

 

 

instruction PRINT (for text mode)

os_print equ $f1a4

eg: ? CHR$(125) - del screen

 

lda #125
jsr os_print  ; put char

 

 

Bon appetit!

Edited by xxl
  • Haha 1
Link to comment
Share on other sites

hmmm I see it uses the same character for the whole line ... then you can use the DRAWTO instruction for text mode:

 

 

instruction DRAWTO x,y
os_drawto equ $f9c2

 

lda #x_cord
sta colcrs
lda #y_cord
sta rowcrs
jsr os_drawto

Link to comment
Share on other sites

46 minutes ago, xxl said:

so much fat code... and here is the version for those who care about a proper diet

At least my "FAT" code will work regardless of the OS installed and for the topic starter I think

it's much more informative as he's obviously new to assembler, without knowing how those routines 

in the OS work it will still be a bit of a mystery as to how it's working.

Link to comment
Share on other sites

so much hate for the original operating system in you. XLOS is like a hideous neighbor who is a shame to eat breakfast after the night, in fact she is not perfect, maybe she is ugly and lame, but is that a reason to cultivate anger? use and forget, don't be interested in how she works.

  • Haha 1
Link to comment
Share on other sites

I have no idea what you all are talking about but it's entertaining.  I'll start with the phat ways first, then perhaps slim it down.  I appreciate the input, and have a couple of more questions.

 

 

Looks like below is for an endless loop, kind of strange as my emulator (400/800) shows CONSOL being 7 after i poke it with 255 using atari basic. I recall that is for the beautiful yellow console keys.

 

WAIT LDA #$FF
    STA CONSOL
LOOPW LDA CONSOL
    CMP #6
    BNE LOOPW
    RTS 

 

Link to comment
Share on other sites

16 minutes ago, zbyti said:

Yes, this is indeed endless loop

Nonsense, the $FF into CONSOL resets the 'hardware' register.

The loop reads the register and exits when the value '6' is read, which is for the START key - as pressing is High to Low and so 'Select = 2^1 = 2' plus 'Option = 2^2 = 4' = 2+4 = 6

 

From Mapping the Atari:

 

53279 D01F CONSOL

     (W/R) Used to see if one of the three yellow console buttons has
     been pressed (not the RESET button!). To clear the register,
     POKE CONSOL with eight. POKEing any number from zero to
     eight will cause a click from the speaker. A FOR-NEXT loop that
     alternately POKEs CONSOL with eight and zero or just zero,
     since the OS put in an 8 every 1/60 second, will produce a buzz.
     Values PEEKed will range from zero to seven according to the
     following table:

     |Key        Value    0    1    2    3    4    5    6    7    |
     |                                                            |
     +------------------------------------------------------------+
     |                                                            |
     |OPTION              X    X    X    X                        |
     |SELECT              X    X              X    X              |
     |START               X         X         X         X         |
     |                                                            |
     +------------------------------------------------------------+
      Bits   2            0    0    0    0    1    1    1    1
             1            0    0    1    1    0    0    1    1
             0            0    1    0    1    0    1    0    1

 

 

Edited by Wrathchild
exists->exits
  • Like 1
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...