Jump to content



2

Code example for loading and displaying an image


6 replies to this topic

#1 Justin Payne OFFLINE  

Justin Payne

    Space Invader

  • 24 posts
  • Location:Kent, Washington, USA

Posted Thu Sep 15, 2011 7:09 PM

Does anyone have a simple code in assembly that loads an image into video memory?

Thanks,

#2 JAC! OFFLINE  

JAC!

    Moonsweeper

  • 472 posts
  • Always looking for GFX and MSX for my demos
  • Location:Lebach, Germany

Posted Fri Sep 16, 2011 4:34 AM

Hi,
As opposed to BASIC, you would not load it to the video memory. Instead you normally setup a display list and include the picture data as binary into the executable directly. See attached ZIP file.

;
;	>>> Simple picture display in assembler <<<
;
;	2011-09-16 by JAC! 


	org $2000

start	mwa #dl $230		;Set DL points
	mva #$34 708		;Set 3 colors
	mva #$38 709
	mva #$0e 710
	jmp *

dl	.local
dc	= $0e			;Antic mode E/graphics 15
	
	.byte $70,$70,$70	;3*8=24 blank lines in PAL

	.byte $40+dc		;LMS instruction for upper half
	.word picture
:95	.byte dc		;1+95=96 lines, 40 bytes each

	.byte $40+dc		;LMS instruction for upper half
	.word picture+$f00	;Will be at 4k boundary
:95	.byte dc		;1+95=96 lines, 40 bytes each

	.byte $41		;Restart with vertical blank
	.word dl

	.endl

	;Picture has $1e00 bytes, $f00 for the upper half, $f00 for the lower half
	;In order to prevent ANTIC from cross a 4k boundary, we chose the base address
	;in a way that the upper half is in the first 4k, and the lower half in 2nd 4k.
 
	org $2100
picture	ins "SpaceHarrier.pic"

DisplayPicture.png

Attached Files


Edited by JAC!, Fri Sep 16, 2011 4:40 AM.


#3 MaPa OFFLINE  

MaPa

    Dragonstomper

  • 564 posts
  • Location:Czech Republic

Posted Fri Sep 16, 2011 4:36 AM

DELETED

Edited by MaPa, Fri Sep 16, 2011 4:37 AM.


#4 Justin Payne OFFLINE  

Justin Payne

    Space Invader

  • 24 posts
  • Location:Kent, Washington, USA

Posted Sun Sep 18, 2011 10:14 AM

WOW!! It was THAT simple?!? Thank you very much!!!

#5 JAC! OFFLINE  

JAC!

    Moonsweeper

  • 472 posts
  • Always looking for GFX and MSX for my demos
  • Location:Lebach, Germany

Posted Sun Sep 18, 2011 10:44 AM

It's assembly, it is "simple" by definition, and sometimes this makes it hard :). Real coder's .. you know..
Posted Image

#6 Justin Payne OFFLINE  

Justin Payne

    Space Invader

  • 24 posts
  • Location:Kent, Washington, USA

Posted Fri Sep 23, 2011 10:33 PM

Well, even simple it helped. I found so many things about display lists, which I completely got, and lots of stuff with P/M graphics, but nothing about just loading an image into video memory.

#7 JAC! OFFLINE  

JAC!

    Moonsweeper

  • 472 posts
  • Always looking for GFX and MSX for my demos
  • Location:Lebach, Germany

Posted Fri Sep 23, 2011 11:29 PM

So you mean from disk file? Like you'd do it in TurboBasic?
GRAPHICS 15
OPEN #1,4,0,"D:PICTURE.PIC"
BGET #1,DPEEK(88),7680
CLOSE #1

In which assembler syntax do you need the reply?

Edited by JAC!, Fri Sep 23, 2011 11:30 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users