Karoshi MSX Community

Desarrollo MSX => Rutinas - Snipets => Mensaje iniciado por: ARTRAG en 08 de Septiembre de 2008, 02:34:06 pm



Título: Vertical full page fine text scroller
Publicado por: ARTRAG en 08 de Septiembre de 2008, 02:34:06 pm
Hi
does anyone have a nice and compact code for
full screen fine text scroller for msx1?
 ;D





Título: Re: Vertical full page fine text scroller
Publicado por: jltursan en 08 de Septiembre de 2008, 05:03:03 pm
Full screen?, like the one in MSX Unleashed?. Nope; but I remember that DVik explained somewhere a bit his own trick to achieve this...


Título: Re: Vertical full page fine text scroller
Publicado por: ARTRAG en 08 de Septiembre de 2008, 06:23:11 pm
ok
time to do that by myself


Título: Re: Vertical full page fine text scroller
Publicado por: ARTRAG en 08 de Septiembre de 2008, 11:32:42 pm
The text is encoded in the section "text:"

Note:
Chars from A to Z are mapped twice, in the odd numbers from 0 to 51 and in the even numbers in the same range.
To make the effect work, each text line of the the message has to be repeated in two adjacent lines,
first encoded in the even chars, than in the odd chars.
Look at the sample line to have a clearer view of how it works.

PS
Tile set courtesy of C-BIOS  ;)

Código:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; It expects screen 1 or screen 2 "hybrid" mode
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

sloftscroll:

            xor    a                      ; Tile colors
            out    (99h),a
            ld     a,64+20h
            out    (99h),a
            ld      bc,0x98
            ld      a,0xf1

1:          out    (0x98),a
            djnz    1b
1:          out    (0x98),a
            djnz    1b

                                         ; D = text line counter
            ld      de,0                 ; E = pixel counter

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; outer loop
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2:
             exx
             ld         e,08h
             call _checkkbd
             bit 0,l
             exx
             ret z                       ; exit if user press space
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; inner loop
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

1:          halt

            call   one_pixel

            ld     a,e
            inc    a
            and    7
            ld     e,a

            dec    a
            jr     nz,1b                 ; move the text of 8 pixels

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

            call   one_line

            inc    d

            ld     a,-24+(end_text-text)/32+1
            cp     d
            jr     nz,2b

            ret                          ; no more text to scroll

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

one_pixel:  xor    a
            out    (99h),a
            ld     a,64
            out    (99h),a

            ld     h,0
            ld     l,e

            ld     bc,ASCII
            add    hl,bc

            ld     bc,16*26*256+98h
            otir
            otir

            ret

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

one_line:   xor    a
            out    (99h),a
            ld     a,64+18h
            out    (99h),a

            ld      h,0
            ld      l,d

            rept    5
             add     hl,hl
            endm

            ld      bc,text
            add     hl,bc

            ld      bc,3*256*256+98h
            otir
            otir
            otir

            ret

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

text:
            rept 24
            rept 32
             db    255
            endm
            endm

            rept 6
             db    00,02,04,06,08,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,0xff,0xff,0xff,0xff,0xff,0xff
             db    01,03,05,07,09,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,0xff,0xff,0xff,0xff,0xff,0xff

             db    0xff,0xff,0xff,0xff,0xff,0xff,18,50,48,46,44,42,40,38,36,34,32,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50
             db    0xff,0xff,0xff,0xff,0xff,0xff,19,51,49,47,45,43,41,39,37,35,33,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51
            endm

            rept 24
            rept 32
             db    255
            endm
            endm
end_text:


ASCII:
;A
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x70,0x88,0x88,0xF8,0x88,0x88,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0xE0,0x90,0xE0,0x90,0x88,0xF0,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x70,0x88,0x80,0x80,0x88,0x70,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0xF0,0x48,0x48,0x48,0x48,0xF0,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0xF8,0x80,0xE0,0x80,0x80,0xF8,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0xF8,0x80,0x80,0xE0,0x80,0x80,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x70,0x88,0x80,0xB8,0x88,0x70,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x88,0x88,0xF8,0x88,0x88,0x88,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x70,0x20,0x20,0x20,0x20,0x70,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x38,0x08,0x08,0x08,0x88,0x70,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x88,0x90,0xA0,0xE0,0x90,0x88,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x80,0x80,0x80,0x80,0x80,0xF8,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0xD8,0xA8,0xA8,0x88,0x88,0x88,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0xC8,0xA8,0xA8,0x98,0x98,0x88,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x70,0x88,0x88,0x88,0x88,0x70,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0xF0,0x88,0x88,0xF0,0x80,0x80,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x70,0x88,0x88,0xA8,0x90,0x68,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0xF0,0x88,0x88,0xF0,0xA0,0x98,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x70,0x80,0x70,0x08,0x08,0xF0,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0xF8,0x20,0x20,0x20,0x20,0x20,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x88,0x88,0x88,0x88,0x88,0x78,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x88,0x88,0x88,0x50,0x50,0x20,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x88,0x88,0xA8,0xA8,0xA8,0xD8,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x88,0x50,0x20,0x50,0x88,0x88,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x88,0x88,0x70,0x20,0x20,0x20,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0xF8,0x10,0x20,0x40,0x80,0xF8,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00



PPS
Add your favourite "_checkkbd" to test the keyboard (I test spacebar) or just skip that segment of code if you do not need to stop the scroll at used demand.


Título: Re: Vertical full page fine text scroller
Publicado por: jltursan en 09 de Septiembre de 2008, 12:18:01 pm
Wow, you're fast! :)

I missed that you were talking about vertical, not horizontal scroller :P. I'll take a peek at the code later, I'm curious to see how you've implemented it.


....haven't tested yet; but anyway, are these lines correct?:

Código:
ld     bc,16*26*256+98h

ld     bc,3*256*256+98h


Título: Re: Vertical full page fine text scroller
Publicado por: ARTRAG en 09 de Septiembre de 2008, 12:45:08 pm
Totally!

Note the multiple otir just after the lines you pointed!

If your assembler does not like them,just add an " & 0xFFFF " to the calculation, in order to put the constants into the DW range

Let me know when you test it!
I eager to have your comments :)

PS
I improved the snippet a bit.
Now it is much better (less register used, less bytes wasted)


Título: Re: Vertical full page fine text scroller
Publicado por: jltursan en 09 de Septiembre de 2008, 11:20:50 pm
hehe, indeed, "& $FFFF" does the trick :)

Here's a quick & dirty ROM file I've compiled to see how it runs: Vertical smooth scroll demo (http://www.fileshost.com/en/file/59990/vscroll-rom.html)


Título: Re: Vertical full page fine text scroller
Publicado por: ARTRAG en 09 de Septiembre de 2008, 11:36:17 pm
I changed the code!
Now it is better (and without a bug in the line count ;)


Título: Re: Vertical full page fine text scroller
Publicado por: Jon_Cortazar en 10 de Septiembre de 2008, 06:33:25 am
Nice one ARTRAG. The only drawback is that you need to do it using a simple bank, but anyway, you can always show a history text on screen 1 and then go back to screen 2 (/me does not like hybrid modes). Good work ;)


Título: Re: Vertical full page fine text scroller
Publicado por: ARTRAG en 10 de Septiembre de 2008, 09:14:50 am
Sure. BTW this was just a quick solution to the vertical fine scroll problem.

About screen 2, I'm not sure there is enough bandwidth to scroll in a frame 3*26 tiles.
(or better, it is pointless: for the sole patterns -no colours-, you need to scroll 3*2*X*8 bytes per frame. When X = say 32 you have 1,5KB that is the full VDP bandwidth!! In this way you cannot update colours and you get the same result you could have in screen 1 at with 1/3 of the CPU cost).

If you really want full screen 2 (because you want tiles with a colour per line) other possibilities exist.

But it is a lot of work.

If you stay with 32 tiles in total you can pre rotate them, so it is just matter of changing the PNT (32*8 = 256).

This has a serious problem: actually only 16 different "models" are available, as you need at least two tiles per letter!!

No language has so few symbols in its alphabet ...

To override this limit you do need some mixed strategy, eg. 14 pre-rotated models (that imply 2*14*8 = 224tiles) plus
16 dynamically defined tiles (that imply 16*2 = 32 tiles ) for a total of 16+14 = 30 tiles ....

But updating the PNT becomes a hell....



Título: Re: Vertical full page fine text scroller
Publicado por: mohai en 15 de Septiembre de 2008, 04:30:04 pm
Nice text scroll !!! It reminds me to the history scroll in Maze of Gallious

Maybe it is possible to save patterns if you make 2-pixels steps instead 1-pixel.

I think it could be possible to add some fixed colours and do fade effect (as in Trojka).


Título: Re: Vertical full page fine text scroller
Publicado por: ARTRAG en 15 de Septiembre de 2008, 05:28:18 pm
Citar
I think it could be possible to add some fixed colours and do fade effect (as in Trojka).

Sure! It is very very simple, as the color definitions does not move!

Nice idea, i'll work on it (although MSX1 fades are quite bad and more or less are a transition toward blue)


Título: Re: Vertical full page fine text scroller
Publicado por: pitpan en 16 de Septiembre de 2008, 07:31:25 am
For text, MSX1 fading is possible. Check Griel's Quest menu. For graphics, it is much harder to achieve :(


Título: Re: Vertical full page fine text scroller
Publicado por: ARTRAG en 16 de Septiembre de 2008, 10:33:11 am
hi robsy!
can you tell here the exact sequence of colours you use to ha fades?
(too lazy to try myself)


Título: Re: Vertical full page fine text scroller
Publicado por: pitpan en 16 de Septiembre de 2008, 12:48:08 pm
db 0F0h,0E0h,70h,50h,40h,00h

Or, for human readers, white, gray, cyan, light blue, dark blue, black (transparent).

And I used a 5-6 frame delay for each transition.

There is a different colour cycle used by Crappysoft's Pyramid Quest that enables a red-coloured gamma for the fadding. Works ok too.