eflake Posted October 22, 2020 Share Posted October 22, 2020 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 * Quote Link to comment Share on other sites More sharing options...
drac030 Posted October 22, 2020 Share Posted October 22, 2020 (edited) 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 October 22, 2020 by drac030 Quote Link to comment Share on other sites More sharing options...
xxl Posted October 22, 2020 Share Posted October 22, 2020 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 you're welcome 1 Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted October 22, 2020 Share Posted October 22, 2020 (edited) 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 October 22, 2020 by TGB1718 Quote Link to comment Share on other sites More sharing options...
zbyti Posted October 22, 2020 Share Posted October 22, 2020 @TGB1718 poor soul... You can't deliver better solution than @xxl - remember that! 1 Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted October 22, 2020 Share Posted October 22, 2020 17 minutes ago, zbyti said: You can't deliver better solution than @xxl - remember that! Don't be so sure 1 Quote Link to comment Share on other sites More sharing options...
+Stephen Posted October 22, 2020 Share Posted October 22, 2020 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! Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted October 22, 2020 Share Posted October 22, 2020 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. 1 Quote Link to comment Share on other sites More sharing options...
xxl Posted October 22, 2020 Share Posted October 22, 2020 43 minutes ago, TGB1718 said: not need a call into the OS which would not work on all versions of the OS True, it only works with the Operating Systems shipped with Atari XL / XE series. Quote Link to comment Share on other sites More sharing options...
ivop Posted October 22, 2020 Share Posted October 22, 2020 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. Quote Link to comment Share on other sites More sharing options...
ivop Posted October 22, 2020 Share Posted October 22, 2020 (edited) 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 October 22, 2020 by ivop Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted October 22, 2020 Share Posted October 22, 2020 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 "++++++++++++++++++++++++++++++++++++++++" Quote Link to comment Share on other sites More sharing options...
ivop Posted October 22, 2020 Share Posted October 22, 2020 Sure, you need to define your message as screen bytes For example (mads syntax): dta d'Hello World' Quote Link to comment Share on other sites More sharing options...
xxl Posted October 22, 2020 Share Posted October 22, 2020 (edited) 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 October 22, 2020 by xxl 1 Quote Link to comment Share on other sites More sharing options...
ivop Posted October 22, 2020 Share Posted October 22, 2020 14 minutes ago, xxl said: os_graphics equ $ef9c Jumping eight bytes in a routine that is normally called through a vector ($ef94 is open E:ditor in the XL OS) BTW for 128 or 256 bytes challenges, this is very helpful! Quote Link to comment Share on other sites More sharing options...
xxl Posted October 22, 2020 Share Posted October 22, 2020 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 Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted October 22, 2020 Share Posted October 22, 2020 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. Quote Link to comment Share on other sites More sharing options...
xxl Posted October 22, 2020 Share Posted October 22, 2020 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. 1 Quote Link to comment Share on other sites More sharing options...
zbyti Posted October 22, 2020 Share Posted October 22, 2020 Quote Link to comment Share on other sites More sharing options...
eflake Posted October 22, 2020 Author Share Posted October 22, 2020 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 Quote Link to comment Share on other sites More sharing options...
zbyti Posted October 22, 2020 Share Posted October 22, 2020 (edited) CONSOL is $2FC CH ? ach you mean $D01F... use $2FC I don't think I got the context. Edited October 22, 2020 by zbyti salto mortale Quote Link to comment Share on other sites More sharing options...
Wrathchild Posted October 22, 2020 Share Posted October 22, 2020 (edited) 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 October 22, 2020 by Wrathchild exists->exits 1 Quote Link to comment Share on other sites More sharing options...
zbyti Posted October 22, 2020 Share Posted October 22, 2020 (edited) @Wrathchild you are faster then light I just edited my post then you response :] Edited October 22, 2020 by zbyti Quote Link to comment Share on other sites More sharing options...
Wrathchild Posted October 22, 2020 Share Posted October 22, 2020 Console keys don't effect CH (764, $2FC) 1 Quote Link to comment Share on other sites More sharing options...
zbyti Posted October 22, 2020 Share Posted October 22, 2020 @Wrathchild thx, I'll remember :] I'm not going to use the OS so it's worth remembering Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.