Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > why not 39 column mode ?
2006-10-30 11:24
Oswald

Registered: Apr 2002
Posts: 5027
why not 39 column mode ?

if hiding 1 row is enough for doing vertical scrolling why do we have 38 column mode for horizontal scrollin, why not 39 ?

(and besides anyone can give me a simple random generator ? register readouts doesnt count)
2006-10-30 11:30
algorithm

Registered: May 2002
Posts: 702
Probably how the hardware was designed. Any way on having 39 rows? closing the top border and opening the bottom etc etc has been done etc
2006-10-30 11:56
JackAsser

Registered: Jun 2002
Posts: 1990
Quote: if hiding 1 row is enough for doing vertical scrolling why do we have 38 column mode for horizontal scrollin, why not 39 ?

(and besides anyone can give me a simple random generator ? register readouts doesnt count)


39 column mode: I've asked myself the very same question... :D

Random numbers:
getrnd:
        lda seed
        beq doEor
        asl
        beq noEor ;if the input was $80, skip the EOR
        bcc noEor
doEor:  eor #$1d
noEor:  sta seed
        rts

;0<=x<=15 (initial seed value)
initrnd:
        ldx seedv,x
        sta seed
        rts

;Seed values you may use.
seedv:
    .byte $1d,$2b,$2d,$4d,$5f,$63,$65,$69
    .byte $71,$87,$8d,$a9,$c3,$cf,$e7,$f5

seed:
    .byte $00


Based on the 16 different values of the seed this will give you a series of 256 numbers where each number is picked only once, then it repeats.

2006-10-30 12:30
Oswald

Registered: Apr 2002
Posts: 5027
jack, wow awe routine! thx a lot ! :)
2006-10-30 12:37
JackAsser

Registered: Jun 2002
Posts: 1990
@ozzie: Don't thank me, it was someone with a big mathematical beard who figured it out. There was some site about it, however I've forgotten the URL. On that site was the full explanation + details how to extend to 16 bits, 32 bits etc..
2006-10-30 12:42
Oswald

Registered: Apr 2002
Posts: 5027
jack, guess the routine goes through 256 possibilities then start over ?
2006-10-30 12:50
JackAsser

Registered: Jun 2002
Posts: 1990
Yes, exactly.
2006-10-30 12:56
Devia

Registered: Oct 2004
Posts: 401
So in essence you're just using 39 bytes to represent a fixed set of 256 values?
2006-10-30 12:58
JackAsser

Registered: Jun 2002
Posts: 1990
@devia: uhm, yes. But in even fewer bytes:

ldx #$00
txa
inx
bne *-1


Got my point? :D

Anyways, iopop just reminded me that it was WhiteFlame who explained this method.
2006-10-30 13:03
MRT
Account closed

Registered: Sep 2005
Posts: 149
about 39 column mode... ;-)

I guess you can't have 39 column mode, because of the length of a clockcycle...

One cc takes as long as the width of one character. To enable 39 column mode (to draw the borders in place) you would have the VIC interrupt inside of one cc (half cc timing) to turn on and off the border...

I guess that wouldn't go well with the timing of the 6510.
:)

Or am I just stoned again? :-D
2006-10-30 13:32
Devia

Registered: Oct 2004
Posts: 401
@JackAsser: Which was exactly my point. How do you apply this routine in real-world applications where you need a series of 8bit random numbers that is longer than 256 and where you do not wish to repeat the series? By randomizing the seed or what?
2006-10-30 13:54
enthusi

Registered: May 2004
Posts: 675
Its probably 'safe' to feed the seed with rasterposition or some other less random value - I guess.
On the other hand this asl/eor-method annoys the crap out of me when it comes to shuffles in mp3/cd-players. I'm pretty certain they use something alike, and the resulting sequence (rather than random series) is all BUT well well distributed.
2006-10-30 14:02
WVL

Registered: Mar 2002
Posts: 886
Quote: about 39 column mode... ;-)

I guess you can't have 39 column mode, because of the length of a clockcycle...

One cc takes as long as the width of one character. To enable 39 column mode (to draw the borders in place) you would have the VIC interrupt inside of one cc (half cc timing) to turn on and off the border...

I guess that wouldn't go well with the timing of the 6510.
:)

Or am I just stoned again? :-D


I guess you're stoned again ;) because you could simply don't expand the borders on either left or right side.. And why does the VIC care about clock-cycles anyway? it has a higher frequency than the cpu, how else can it draw nice pixels? :)
2006-10-30 14:38
Oswald

Registered: Apr 2002
Posts: 5027
ok so back to topic guys, anyone has a good guess why is it NOT 39 column mode ? :)
2006-10-30 14:41
MRT
Account closed

Registered: Sep 2005
Posts: 149
Quote: I guess you're stoned again ;) because you could simply don't expand the borders on either left or right side.. And why does the VIC care about clock-cycles anyway? it has a higher frequency than the cpu, how else can it draw nice pixels? :)

About the stoned... you could be right ;-D

But about the rest... :)

If you don't split a CC halfways, the screen won't be centered anymore... You have one border smaller than the other one.

And the VIC must care, coz the CPU must be halted. And I don't think that would go well in the middle of a CC.
2006-10-30 14:46
Devia

Registered: Oct 2004
Posts: 401
The border is already one and a half char wider on the left side as it is?!
2006-10-30 15:09
Oswald

Registered: Apr 2002
Posts: 5027
Quote: The border is already one and a half char wider on the left side as it is?!

2006-10-30 15:17
MRT
Account closed

Registered: Sep 2005
Posts: 149
Quote: The border is already one and a half char wider on the left side as it is?!

oi?
2006-10-30 18:30
H.O
Account closed

Registered: Oct 2002
Posts: 70
Ok. I'll admit to not having coded much for the c64 in 20 years, and it's been over a year since I last wrote a single line of 6510 code.

But, isnt the 38 (rather then 39) columns based on the idea that you dont know whether the user wants to scroll things in from the left or the right?

Or am I missing something here?
2006-10-30 18:45
cadaver

Registered: Feb 2002
Posts: 1154
But same could be said that you don't know whether the user wants to scroll in things from the top or the bottom, still it works fine as it is :)
2006-10-30 23:04
Devia

Registered: Oct 2004
Posts: 401
@MRT & Oswald: Have you been in emu-land for too long? You have 6 chars on the left and about 4½ chars on the right (404 pixels in total from left to right).

When setting 38 column mode, the border ends 7 pixels further in on the left side and it starts 9 pixels before on the right. So if we had a 39 column mode we probably wouldn't be able to open the side border >8-O
2006-10-31 01:23
Style

Registered: Jun 2004
Posts: 498
funny! I was about to post the same question myself!

Ive been playing with VSP, and what Ive found doesnt mesh well with my understanding of the c64 at all.

Firstly, there appears to be 26 badlines? since the screen is 25 chars deep, and a badline reads the char points for a char line, youd expect there to be 25 right? VSP the screen one char to the right and you can see 26 distinct lines of text (altho the top is cut from the top line and the bottom has been cut from the bottom line). 26 distinct lines of text = 26 bad lines. Odd. Actually, I was testing this with Vice, maybe it works differently on a real c64?

Its freakin me out man!



2006-10-31 06:39
Oswald

Registered: Apr 2002
Posts: 5027
thats not 26 distinct lines, thats 25 shifted lines.

start with 2 lines:

line_1
line_2

shift:

 line_
1line_
2



wee its 3 lines ! but its still only 2 badlines :)
2006-10-31 06:50
Style

Registered: Jun 2004
Posts: 498
I shifted it 1 char. I got a line of 40 distinct chars at the bottom, including $07f0-$07ff before it wrapped.

2006-10-31 07:24
Marauder/GSS
Account closed

Registered: Jul 2006
Posts: 224
Quote: funny! I was about to post the same question myself!

Ive been playing with VSP, and what Ive found doesnt mesh well with my understanding of the c64 at all.

Firstly, there appears to be 26 badlines? since the screen is 25 chars deep, and a badline reads the char points for a char line, youd expect there to be 25 right? VSP the screen one char to the right and you can see 26 distinct lines of text (altho the top is cut from the top line and the bottom has been cut from the bottom line). 26 distinct lines of text = 26 bad lines. Odd. Actually, I was testing this with Vice, maybe it works differently on a real c64?

Its freakin me out man!





yes, 26 lines are possible... (c; I used it in the intro of "MRD's After Party Demo" MRD's After Party Demo
but not sure if it works with 39 columns!?
2006-10-31 07:33
MagerValp

Registered: Dec 2001
Posts: 1059
I'm just guessing here, but I think it's because they didn't want the screen to be off center. When shrinking to 24 lines, you lose 4 lines at the top, and 4 at the bottom, keeping the screen centered. To get the same effect with 39 columns, they'd have to remove 4 pixels on each side. This would be really hard to do, as that would change the vic timing by half a CPU cycle. They could have shrunk it by 8 pixels on either the left or the right side, but that would leave the screen off center. Thus they went with 8 pixels on each side, leaving the screen centered.
2006-10-31 07:43
Oswald

Registered: Apr 2002
Posts: 5027
yes everyone knows 26 lines is possible, but u only have 25 badlines for that 26.

style, read the vic article. you still only have 25 badlines, only one of them longer and wrapping around, you only delay the start of the badline horizontally, and the last line wraps around.

mager, nice theory I think you're close to the truth. (1/8th cpu cycle is no prob for the vic, as half cpu cycle is not a problem again, the reason must be rather silicon space saving)
2006-10-31 08:04
Style

Registered: Jun 2004
Posts: 498
I dont think you understand what Im saying.

There are 26 lines. Each one of them has 40 distinct (ie different) characters on it, except for the first because of the BA line and the fact Ive shifted it 1 char to the right.

Line 1: $0400 - $0427
Line 2: $0428 - $044f
...
Line 25: $07c1 - $07e9
Line 26: $07ea - $07ff, $0400 - $041a

26 different lines. 26 bad lines.

Edit: I guess having 26 bad lines isnt all that much of a surprise - I mean, you can cause 200 to occur if you really want.
2006-10-31 08:41
Oswald

Registered: Apr 2002
Posts: 5027
"A Bad Line Condition is given at any arbitrary clock cycle, if at the negative edge of ø0 at the beginning of the cycle RASTER [bigger or equal] $30 and RASTER [smaller or equal] $f7 and the lower three bits of RASTER are equal to YSCROLL and if the DEN bit was set during an arbitrary cycle of raster line $30."

$f7-$30 = $c7 = 0-199 rasterlines

200/8 = 25 possibla badlines at max.

"But as the accesses started in the middle of a line, less than 40 accesses took place so VC has been incremented by a total of less than 40 in this raster line and no longer is a multiple of 40 as it normally always is at the end of a raster line. Because of the working of VC (see section 3.7.2.), this "misalignment" is continued for all following lines"

you have only 25 misaligned badlines.
2006-10-31 09:12
Style

Registered: Jun 2004
Posts: 498
If that were the case, the last line would have a single character on it.

Think about it.

2006-10-31 09:54
Oswald

Registered: Apr 2002
Posts: 5027
well in a way you have 26 badlines, but the truth is that the bad lines are misaligned, and there's _the_same_amount_of_data_ fetched by the vic as usual, so u have nothing extra, just a misalignment.
2006-10-31 10:01
JackAsser

Registered: Jun 2002
Posts: 1990
@Style: Screenshot...
2006-10-31 10:46
Style

Registered: Jun 2004
Posts: 498
never mind, i think its a Vice glitch - Ive mucked around with the code a bit, and now it shows a solid black area on the bottom (26th) row instead of chars....

Anyhoo, on with the show.

2006-10-31 11:28
JackAsser

Registered: Jun 2002
Posts: 1990
@Style: Well you CAN get 26 char lines, but only with 25 bad lines. The 26th line is just a duplicate of the 25th, i.e. no new badline.
2006-10-31 11:47
Devia

Registered: Oct 2004
Posts: 401
An example of 26 text lines: Broken Ass!

..any other examples?
2006-10-31 11:48
Devia

Registered: Oct 2004
Posts: 401
wow! 13337! ;-)
2006-10-31 13:06
JackAsser

Registered: Jun 2002
Posts: 1990
The scroller in my part of Panta Rhei also uses the 26th char row... just because I could. ;) But as I said before, it's no new badline condition.
2006-10-31 13:15
MRT
Account closed

Registered: Sep 2005
Posts: 149
Quote: I'm just guessing here, but I think it's because they didn't want the screen to be off center. When shrinking to 24 lines, you lose 4 lines at the top, and 4 at the bottom, keeping the screen centered. To get the same effect with 39 columns, they'd have to remove 4 pixels on each side. This would be really hard to do, as that would change the vic timing by half a CPU cycle. They could have shrunk it by 8 pixels on either the left or the right side, but that would leave the screen off center. Thus they went with 8 pixels on each side, leaving the screen centered.


Ehr... This is exactly what I was trying to say... :)
2006-10-31 13:21
Devia

Registered: Oct 2004
Posts: 401
why would adding 4 pixels on each side be any more difficult than adding 7 on one side and 9 on the other?
2006-10-31 13:22
MRT
Account closed

Registered: Sep 2005
Posts: 149
Quote: The scroller in my part of Panta Rhei also uses the 26th char row... just because I could. ;) But as I said before, it's no new badline condition.

actually...
It is a new badline condition, just no fetch of new memory ;-)
2006-10-31 13:28
Oswald

Registered: Apr 2002
Posts: 5027
actually you should read the vic article
2006-10-31 13:37
Devia

Registered: Oct 2004
Posts: 401
I'm a bit confused now... how many ways of displaying 26 text lines are there?
In Broken Ass, Wizz did it by setting YSCROLL to 0 before the first line, then somewhere on the middle he set YSCROLL to 7 and switched screen mem. (If he recalls correctly)
What other other methods would accomplish the same thing?
2006-10-31 13:59
Style

Registered: Jun 2004
Posts: 498
Quote: actually...
It is a new badline condition, just no fetch of new memory ;-)


Im not so sure - because the VSP distorts the counters, 1000 is never reached and it reads the sprite def pointers and loops back to $0400.

I had it doing that before, but now Ive changed it and cant remember how I was doing it :D
2006-11-01 11:14
Ninja

Registered: Jan 2002
Posts: 407
Funny, lots of topics coming up here for which I planned to write articles about somewhen (somewhen being the problem here ;)).

The shortest pseudo-number generator I know of is like this:

seed = *+1
              lda #$64 ; must be non-zero
              asl
              bcc *+4
              eor #$cf
              sta seed


Works pretty much as the method of JackAsser. Will give you every 8-bit-value once in some order, except 0. Works good enough for demos in most cases.
2006-11-01 12:52
Oswald

Registered: Apr 2002
Posts: 5027
well, afterall I had fallen back to reading rom and eoring it with d012, what jack has posted was too predictable in a way for me. thx for the nice routines nevertheless.
2006-11-02 08:17
ChristopherJam

Registered: Aug 2004
Posts: 1381
This one's a little slower, but it's got a muuch longer cycle:
getRandom
	sty saveY+1
	ldy randomIndex
	dey
	bne stillPositive
	ldy#16
stillPositive
	sty randomIndex
	lda randomTab,y    ; r(t-17)
	adc randomTab+5,y  ; r(t-5)
	sta randomTab,y
	sta randomTab+17,y
saveY
	ldy#0
	rts

randomIndex
	brk
randomTab
	.byt "qwerasdf67896yhn1"
	.byt "qwerasdf67896yhn1"

The algorithm is basically random(t)=random(t-5)+random(t-17). I've doubled over the seed table to avoid doing modulo array indexing or maintaining two indices. I've left the clc out to save cycles :)

If you use it to get coordinates to pass to a plotter you get nice snow; there's very little correlation between pairs of numbers.
2006-11-02 08:31
Oswald

Registered: Apr 2002
Posts: 5027
I had to change the 'seed' to other than 0, but now it works like a charm! thanx! :)
2006-11-04 09:19
yago

Registered: May 2002
Posts: 332
Quote: if hiding 1 row is enough for doing vertical scrolling why do we have 38 column mode for horizontal scrollin, why not 39 ?

(and besides anyone can give me a simple random generator ? register readouts doesnt count)


POKE53270,0
POKE53270,7
POKE53270,8
POKE53270,15

Then you shall see, why you need 38 columns, not 39.
2006-11-04 13:43
Oswald

Registered: Apr 2002
Posts: 5027
I still dont see it.
2006-11-05 07:15
Stryyker

Registered: Dec 2001
Posts: 465
Because of the implementation the last poke gives an empty text character to the left. Perhaps it made it easier chip to design.
2006-11-05 10:58
Oswald

Registered: Apr 2002
Posts: 5027
I can make an empty row using d011 we still doesnt have 23 row mode.
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Steel/SCS&TRC/G★P
zscs
Hagar/The Supply Team
Guests online: 120
Top Demos
1 Next Level  (9.8)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.7)
5 Edge of Disgrace  (9.6)
6 Comaland 100%  (9.6)
7 Uncensored  (9.6)
8 No Bounds  (9.6)
9 Wonderland XIV  (9.6)
10 Bromance  (9.5)
Top onefile Demos
1 Layers  (9.7)
2 It's More Fun to Com..  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 TRSAC, Gabber & Pebe..  (9.5)
7 Rainbow Connection  (9.5)
8 Dawnfall V1.1  (9.5)
9 Quadrants  (9.5)
10 Daah, Those Acid Pil..  (9.5)
Top Groups
1 Oxyron  (9.3)
2 Booze Design  (9.3)
3 Censor Design  (9.3)
4 Crest  (9.3)
5 Performers  (9.3)
Top Logo Graphicians
1 Sander  (9.9)
2 Facet  (9.6)
3 Mermaid  (9.4)
4 Pal  (9.4)
5 Shine  (9.3)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.087 sec.