Horizontal HIRES and Text scrolling code needed.

Here you can ask questions or provide insights about how to use efficiently 6502 assembly code on the Oric.
User avatar
peacer
Flight Lieutenant
Posts: 349
Joined: Wed Jun 09, 2010 9:23 pm
Location: Turkey
Contact:

Re: Horizontal HIRES and Text scrolling code needed.

Post by peacer » Wed Jun 26, 2013 12:15 pm

So according to wiki, I need to use Zero Page Indirect Indexed with Y: (zp),y instead of Zero Page Indexed with X: zp,x. I will think of that.

About adding number to 2 byte memory , what could be fastest and shortest code?

To simplify the question , what could be easiest machine code counterpart of "DOKE N,DEEK(N)+40" ?

User avatar
Chema
Game master
Posts: 2030
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: Horizontal HIRES and Text scrolling code needed.

Post by Chema » Wed Jun 26, 2013 1:33 pm

Using the same idea, simply:

Code: Select all

  
   lda N
   clc
   adc #40
   sta N
   bcc nocarry1
   inc N+1
nocarry1
  ...
Which means, instead of loading the contents of N+1,adding 0 plus the carry and storing the result, check if carry is clear and, if not so, increment the contents of N+1, or else branch over the instruction. This works because the high byte of 40 is zero, of course.

User avatar
peacer
Flight Lieutenant
Posts: 349
Joined: Wed Jun 09, 2010 9:23 pm
Location: Turkey
Contact:

Re: Horizontal HIRES and Text scrolling code needed.

Post by peacer » Wed Jun 26, 2013 3:47 pm

Thanks :)

But You said "This works because the high byte of 40 is zero" . Actually we are increasing it #28 not #40 as 40 is decimal for character number per line. Does it matter?

Or maybe I misunderstood and #40 means 40 in decimal, not hexadecimal?

I think I am thinking in BASIC not machine code :) Is it true such as : #40 --> decimal and #$40 hexadecimal?

You know, In basic #40 describes hexadecimal value.

User avatar
Chema
Game master
Posts: 2030
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: Horizontal HIRES and Text scrolling code needed.

Post by Chema » Wed Jun 26, 2013 5:53 pm

Yep, lda #40 loads 40 in decimal, not hex, into the accumulator in immediate addressing mode. That is what the # means, inmediate addressing. $ is used to denote hexadecimal numbers.

User avatar
peacer
Flight Lieutenant
Posts: 349
Joined: Wed Jun 09, 2010 9:23 pm
Location: Turkey
Contact:

Re: Horizontal HIRES and Text scrolling code needed.

Post by peacer » Wed Jun 26, 2013 8:00 pm

:) I learn new things everyday

User avatar
peacer
Flight Lieutenant
Posts: 349
Joined: Wed Jun 09, 2010 9:23 pm
Location: Turkey
Contact:

Re: Horizontal HIRES and Text scrolling code needed.

Post by peacer » Thu Jun 27, 2013 11:46 pm

How can we control 6th bit after shifting the byte to the left.

BIT command is supposed to check 6th and 7th bits but I couln't visualise usage in my mind.

I plan to use it this way :

1- Clear Carry
2- Read last byte of the scrolling line and transfer it to Accumulator.
3- ASL the accumulator.
4- With using BIT command check if 6th bit is set or not.
5- If 6th bit is on after ASL, set carry as 1 and accumulator is corrected with AND 63 to clear 6th bit again.
6- Write accumulator to the same byte.
7- Pass to the byte left to the first one and do the steps 2 and 3
8- Increase accumulator with carry so bit is transferred from the byte on the right
9 -Clear carry again and do the steps 4,5,6 until reaching to the first byte on the line.
10-Go to next line and do the same things again for required times.
11-Draw last bit of every line for continuation of scrolling and do the scroll again.

This is the plan :)
I think I can handle all the steps but I couldn't imagine how BIT command operates. BIT has zero page absolute operands. So

- Write Accumulator on a zero page location
- BIT command on that location
- Using BVC (Branch on Overflow) so whether decide to run step 5 or not.

Do you think this worksheet is ok?

User avatar
Dbug
Site Admin
Posts: 2358
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: Horizontal HIRES and Text scrolling code needed.

Post by Dbug » Thu Jun 27, 2013 11:52 pm

In the assembly 2002 demo, the scroller at the top is done this way:

Code: Select all

	ldx #0
ScrollerDisplayLoopMessageY
	; Get pixel from character
	clc
	lda ScrollerCharBuffer,x
	rol
	cmp #192
	and #$3F
	ora #64
	sta ScrollerCharBuffer,x

	; And then scroll the whole scanline
	ldy #38
ScrollerDisplayLoopMessageX
	lda (tmp6),y
	rol
	cmp #192
	and #%00111111
	ora #%01000000
	sta (tmp6),y

	dey
	bne ScrollerDisplayLoopMessageX
Full source code is there: http://miniserve.defence-force.org/svn/ ... scroller.s

User avatar
peacer
Flight Lieutenant
Posts: 349
Joined: Wed Jun 09, 2010 9:23 pm
Location: Turkey
Contact:

Re: Horizontal HIRES and Text scrolling code needed.

Post by peacer » Fri Jun 28, 2013 12:22 am

:) need to understand the code. Thanks.

User avatar
Chema
Game master
Posts: 2030
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: Horizontal HIRES and Text scrolling code needed.

Post by Chema » Fri Jun 28, 2013 11:18 am

It is a simple and brilliant idea.

The problem is due to the six-bit per byte display on the Oric. The contents of the screen are represented by only the 6 lower bits of the byte, while the 7th bit (numbering them as 76543210) must be 0 (to indicate not inverse mode) and the 6th must be 1 (to indicate that this is not an attribute).

Therefore we should make sure to keep bits 6 and 7 unmodified and also make sure that, when rotating, it is the 5th bit which we are shifting into the carry, so it ends up in the lowest bit of the next scan. A rotate left operation won't work, as it will shift bit 7 into the carry, not bit 5.

How can we do this, then? Let's see:

At every loop you get the byte and rotate it to the left (shifting the value in the carry into the lowest bit). Then you compare the result with the number 192, which is 11000000 in binary. This will set the carry only if the value of the 5th bit was 1 before the rotation. Notice that every screen byte already has the 6th bit set, to indicate it is not an attribute.

So, a byte such as 01010000 (which represents a pattern of screen pixels 010000), after the rotation will become 10100000, less than 192 and after the comparison the carry will be clear. On the other hand a byte such as 01100000 (a pattern of 100000), will become after the rotation 11000000, so the carry will be set after the comparison.

This way you shift the correct pixel value (contained if the carry) onto the next screen scan. The only thing left is fixing the value after the rotation so its 7th bit is set to 0 and its 6th bit is set to 1 (no inverse and no attribute). Therefore the and operation with the mask 00111111 and the ora operation with the value 01000000.

Code: Select all

Original screen value |  Carry before the rotation | After rotation to the left | Carry after comparison | After fixing by AND/ORA
01010000                        0                                 10100000                         0                       01100000
01100000                        0                                 11000000                         1                       01000000
Mmmm... re-reading this I am not sure if I made myself clear, but it is quite simple once you get the general idea.

User avatar
peacer
Flight Lieutenant
Posts: 349
Joined: Wed Jun 09, 2010 9:23 pm
Location: Turkey
Contact:

Re: Horizontal HIRES and Text scrolling code needed.

Post by peacer » Fri Jun 28, 2013 6:42 pm

Trying to comprehend :) Thanks.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest