[TI Asm] Vertical-Scroll Intro

Got questions? Got answers? Go here for both.

Moderator: MaxCoderz Staff

Post Reply
User avatar
nepmarauder
Regular Member
Posts: 119
Joined: Thu 14 Apr, 2005 7:02 pm
Location: Ann Arbor, MI
Contact:

[TI Asm] Vertical-Scroll Intro

Post by nepmarauder »

Hello,

I am working on my game A Life of Crime, and I want to make a scrolling intro picture, kinda like "Part II" of Ben's Pixel Madness 2 (the part with the moving cloud-like objects and the mountain; if you have seen it you know what I am talkin about).

I would like my picture to be two screens tall, now how can I do this. Do I have to use tiles?

Or could I draw a pic on Paint that is 96*128, use CalcGS or iStudio to convert to hex. Then make the pic display at row 0, then display at 255, then at 254, etc. to make it scroll.

I'm not sure, and I don't want to do a ton of work for nothin!

Thanks
Image
IT'S GREAT TO BE A MICHIGAN WOLVERINE!
User avatar
Jim e
Calc King
Posts: 2457
Joined: Sun 26 Dec, 2004 5:27 am
Location: SXIOPO = Infinite lives for both players
Contact:

Post by Jim e »

That's quite simple!
Convert the data just like you said so it's 12 bytes wide and 128 rows high.

Now you just ldir. Heres some example code.

Code: Select all

    ld hl,INTROPIC
    ld b,64
introloop:
    push bc
    push hl
    ld de,gbuf
    ld bc,768
    ldir                  ;copy this part to screen
    call ionfastcopy      ;update lcd
    pop hl
    ld de,12
    add hl,de             ;move down 1 row
    pop bc
    djnz introloop        ;loop
That code will scroll from the top to the bottom.

Simple, no? :)
Image
User avatar
nepmarauder
Regular Member
Posts: 119
Joined: Thu 14 Apr, 2005 7:02 pm
Location: Ann Arbor, MI
Contact:

Post by nepmarauder »

Thanks Jime.

I figured that I would have to somehow keep select the correct portion of code and display. I just did not know how to do that.

Now I know. Thanks.
Image
IT'S GREAT TO BE A MICHIGAN WOLVERINE!
User avatar
nepmarauder
Regular Member
Posts: 119
Joined: Thu 14 Apr, 2005 7:02 pm
Location: Ann Arbor, MI
Contact:

Post by nepmarauder »

Hey,

I have another question regarding this post. This time my screen picture is 96 x 280. I need to be able to select the viewable portion of the picture using a variable. How might I go about this?
Image
IT'S GREAT TO BE A MICHIGAN WOLVERINE!
User avatar
Jim e
Calc King
Posts: 2457
Joined: Sun 26 Dec, 2004 5:27 am
Location: SXIOPO = Infinite lives for both players
Contact:

Post by Jim e »

Im assuming you mean you want to display at a given row.

Code: Select all

;a - the row you wish to start on
;bc - location of the picture to display.
displaypic:
    ld l,a
    ld h,0
    add hl,hl        ;x2
    add hl,hl        ;x4
    ld e,l
    ld d,h
    add hl,hl        ;x8
    add hl,de        ;x12
    add hl,bc        ;add pic loc
    ld de,gbuf
    ld bc,768
    ldir
    call ionfastcopy      ;update lcd if you want
    ret
Image
User avatar
Dwedit
Maxcoderz Staff
Posts: 579
Joined: Wed 15 Dec, 2004 6:06 am
Location: Chicago!
Contact:

Post by Dwedit »

To draw a portion of a 96*X image, use the row * 12 as the offset to the start position.

Example:

Code: Select all

draw_image:
	;a = Y position to take the source from
	;Step 1: Transfer A to HL, and multiply by 12
	ld l,a
	ld h,0
	;*4
	add hl,hl
	add hl,hl
	ld c,l
	ld b,h
	;*8
	add hl,hl
	;+*4 = *12
	add hl,bc
	;Step 2: Add the base
	ld bc,my_picture
	add hl,bc
	;Step 3: Copy to the graph screen
	ld bc,768
	ld de,plotsscreen
	ldir
	;Step 4: Copy to LCD
	call ionfastcopy
	ret
You need to make sure the row number is in bounds, drawing from out of bounds looks like ugly garbage. So if your image is 192 pixels high, don't draw from row 129 or higher.
You can still play around with this, if you want to cut off 8 pixels off the top and bottom for a widescreen effect, you can change the size (subtract 16*12), and change the destination copy address (add 8*12 to plotsscreen)

Edit: Wow, posted nearly the same exact code, despite starting the post before there was a visible reply.
You know your hexadecimal output routine is broken when it displays the character 'G'.
User avatar
Jim e
Calc King
Posts: 2457
Joined: Sun 26 Dec, 2004 5:27 am
Location: SXIOPO = Infinite lives for both players
Contact:

Post by Jim e »

Well sure, they are suppose to do the same thing, code shouldn't be that dissimilar.
Image
User avatar
nepmarauder
Regular Member
Posts: 119
Joined: Thu 14 Apr, 2005 7:02 pm
Location: Ann Arbor, MI
Contact:

Post by nepmarauder »

Thanks. Jim e and Dwedit, you guys continue to amaze me, and make me look uneducated in the programming word. :) Once again, thanks for the help.
Image
IT'S GREAT TO BE A MICHIGAN WOLVERINE!
User avatar
tr1p1ea
Maxcoderz Staff
Posts: 4141
Joined: Thu 16 Dec, 2004 10:06 pm
Location: I cant seem to get out of this cryogenic chamber!
Contact:

Post by tr1p1ea »

For some reason ive always done it like:

Code: Select all

  ld l,a
  ld h,0
  ld c,l
  ld b,h
  add hl,hl        ; x 2
  add hl,bc        ; x 3
  add hl,hl        ; x 6
  add hl,hl        ; x 12
There is of course no difference speed/size wise, just thought id mention it :).
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."
Image
Image
User avatar
nepmarauder
Regular Member
Posts: 119
Joined: Thu 14 Apr, 2005 7:02 pm
Location: Ann Arbor, MI
Contact:

Post by nepmarauder »

I like that method. Nice, short, to the point. Thanks.
Image
IT'S GREAT TO BE A MICHIGAN WOLVERINE!
Post Reply