Skip to content
Robert Kennedy edited this page May 8, 2016 · 5 revisions

Overview

Easy2D is used to manage 2D graphics for games made in the Easy68K Assembly language. This includes multiple subroutines to load .bmp files into memory, and display images using double buffering. Image assets are stored in memory beginning at address $2500.
Note - Easy2D must receive 24bit bmp files in order to work properly any other bit or file type will break everything.

How to Use

To include Easy2D in your project you simply need to copy the Easy2D.X68 file to your project directory and include the file in your source code at the end of the variable declarations section of source.
INCLUDE 'Easy2D.X68'

initializeEasy2D

  • Description: Initializes Easy 2D, sets global 2d graphics properties, and enables double buffering.
  • Parameters: D0.W - Image scale (Default: 1), D1.L - Alpha mask (Default: $00FF00FF)
  • Return: None

loadImage

  • Description: Loads a .bmp image from file into memory and extracts header information.
  • Parameters: A1 - Null terminated string of the filename.
  • Return: A1 - Memory address of the loaded image.

displayImage

  • Description: Displays an image to the screen at the given x,y location.
  • Parameters: A1 - Pointer to image in memory, D4.W - x location, D5.W - y location.
  • Return: None

Example Code

    ORG    $1000
START:                  ; first instruction of program

; Initalize Easy2D
    MOVE.W  #8,D0            ; Set scale to 8x
    JSR     initializeEasy2D ; Use default image mask of $00FF00FF

; Load sonic.bmp image from file into memory
    LEA     sonic_filename,A1    ; Put filename string in A1
    JSR     loadImage            ; Load image into memory
    MOVE.L  A1,sonic_image       ; Store returned address of image data

; Load sonicRun.bmp image from file into memory
    LEA     sonicRun_filename,A1 ; Put filename string in A1 
    JSR     loadImage            ; Load image into memory
    MOVE.L  A1,sonicRun_Image    ; Store returned addres of image data

; Set image properties and draw to buffer
    MOVE.L  sonic_image,A1  ; Point to sonic image
    MOVE.W  #0,D4           ; Set x origin
    MOVE.W  #0,D5           ; Set y origin
    JSR     displayImage    ; draws image to the back buffer

    MOVE.L  sonicRun_image,A1 ; Point to sonicRun image
    MOVE.W  #28,D4            ; Set x origin
    MOVE.W  #0,D5             ; Set y origin
    JSR     displayImage      ; draws image to the back buffer
    
; Display back buffer containing images
    MOVE.B  #94,D0
    TRAP    #15


    SIMHALT             ; halt simulator

sonic_filename      DC.B    'sonic.bmp',0    ; Test image filename
sonic_image         DS.L    1                ; Sonic image data pointer
sonicRun_filename   DC.B    'sonicRun.bmp',0 ; Test image2 filename
sonicRun_image      DS.L    1                ; SonicRun image data pointer

    INCLUDE 'Easy2D.X68'    ; Include image handling library

    END    START        ; last line of source
Clone this wiki locally