So, if say, I leave the title screen by pushing fire, I don't need those logo graphics or whatever hanging around in RAM anymore, but I don't know how to flush them out.
I thought about using an 'ifdef' or something so that the actual code for the other parts wouldn't be assembled until they were told to be, but again it's getting rid of the old stuff.
Is it just a simple case of overwriting in the same memory location that was specified in the 'org', or specifying a new block?
The code below is for my title screen (please excuse any noob inefficiency). When 's' is pushed it goes to the setup section of the next screen before its own loop, but it's really just a branch off to a section of an already included and compiled external .asm file (the "jp CHARSELECT_INITIALISE" part of the TITLE_PUSHSTART function). It doesn't actually load any new data at that point or getting rid of unneeded stuff, it just jumps there.
I'm just wondering if I'll maybe have to get in to stuff like disk loading etc.?
As always, many thanks for any wisdom imparted.
Code: Select all
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
					      ;; TITLE SCREEN ;;
					      ;;;;;;;;;;;;;;;;;;
	org &0700
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Custom variables for THIS SCREEN ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	X_POS		dw 0		; General purpose X-Position container
	Y_POS		dw 0		; General purpose Y-Position container
	L_XPOS		dw &34		; LEFT hand side of logo's X-Position container	
	L_YPOS		dw &C6		; LEFT hand side of logo's Y-Position container		
	R_XPOS		dw &57		; RIGHT hand side of logo's X-Position container	
	R_YPOS		dw &C6		; RIGHT hand side of logo's Y-Position container	
	LR		dw 0		; Draw decider (Decides which side of logo to draw)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;	
;; SET UP SCREEN & INITIALIASE STUFF ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
TITLE_INITIALISE:	
;	ld a,1				; Load Palette choice value (Not needed ATM)
;	ld (WHICHPALETTE),a		; Load value into variable memory location  (Not needed ATM)
	call SCREENSETUP		; Call the screen setup script
	ld a,4				; Tells text script what to print
	ld (WHICHTEXT),a
	call PRINT_CHARNAME		; Print text to the screen	; All static and just called once (no need to be in loop...I think?)
	call DRAWLEFT			; Draw Left side of Logo	;
	call DRAWRIGHT			; Draw Right side of Logo	;
	
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; TITLE SCREEN LOOP ;;
;;;;;;;;;;;;;;;;;;;;;;;
TITLE_MAINLOOP:				; TITLESCREEN MAIN LOOP START
	call TITLE_PUSHSTART
jr TITLE_MAINLOOP			; TITLESCREEN MAIN LOOP END
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; SET WHICH SIDE OF LOGO TO DRAW ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
DRAWLEFT:				; Draw Left hand side of logo
	ld a,1
	ld (LR),a			; Let draw routine what side it is drawing (1 = LEFT, 2 = RIGHT)
	ld de,(L_XPOS)			; Load left hand side's X Position into 'a'
	ld (X_POS),de			; Transfer from 'a' to general purpose X position variable
	ld de,(L_YPOS)			; Load left hand side's Y Position into 'a'	
	ld (Y_POS),de			; Transfer from 'a' to general purpose Y position variable
	jr DRAWTITLE			; Send to draw routine
DRAWRIGHT:				; Draw right hand side of logo
	ld a,2				; 	
	ld (LR),a			; 	
	ld de,(R_XPOS)			; 	
	ld (X_POS),de			; 	** REPEAT AS ABOVE **
	ld de,(R_YPOS)			; 	
	ld (Y_POS),de			; 
	jr DRAWTITLE			; 	
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; DRAW GRAPHICS CODE ;;
;;;;;;;;;;;;;;;;;;;;;;;;
DRAWTITLE:					; Main label to call for all drawing
	push de
		ld a,(X_POS)			; Load X-POSITION
		ld b,a
		ld a,(Y_POS)			; LOAD Y-POSITION
		ld c,a
		call GetScreenPos		; New plotting code
;		call SPRITEPOS_IN_PIXELS	; &BC1D Firmware (HA! Don't need you anymore, fucker!!!)
	pop de
	WHICHSIDE:				; What Graphics data to fetch and look at
		D_LEFT:				; Draw LEFT side of Logo
			ld a,(LR)
			cp 1
			jr nz, D_RIGHT	
			xor a
			ld de,TITLELEFT		
			jr WHICHSIDE_END
		D_RIGHT:			; Draw RIGHT side of Logo
			ld a,(LR)
			cp 2
			jr nz, WHICHSIDE_END
			xor a	
			ld de,TITLERIGHT	; What Graphics data to fetch and look at
	WHICHSIDE_END:
			ld a,174		; Height (LINES)	
			ld b,a
	TITLE_Spritenextline:
		push hl
			ld a,35			; Width (BYTES)
			ld c,a			; Bytes per line
		TITLE_Spritenextbyte:
				ld a,(de)				
				ld (hl),a	
	
				inc de
				inc hl
				dec c
				jr nz,TITLE_Spritenextbyte
		pop hl
		call GetNextLine		; Scr Next Line
		;call SCREEN_NEXTLINE		; Fuck you too!!!
	djnz TITLE_Spritenextline		
;RET
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; PUSH START TO GO TO CHARACTER SELECT SCREEN ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
TITLE_PUSHSTART:
		ld a,60			; ASCII code for 's'
		call READ_KEY	
		jr z, SKIPFIRE
		jp CHARSELECT_INITIALISE
	SKIPFIRE:
RET
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; SCREEN SETUP & PALETTE DEFINITION ;; 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
SCREENSETUP:
	
	ld a,0
	call MODE_0					; Screen mode 0
	call CLS					; Clear the screen
	ld b,16						; Colour Number
	ld bc,&0000					; Value of the border colour (&0000 = &0101 = blue)
        call SCREENBORDER				; &bc38 sets the border colour	
	call SET_PALETTE				; New universal way of setting palette
;	ld a, (WHICHPALETTE)				; Palette Select  (Not needed ATM)
;	ld b,a
;	TITLEPAL:					
;		cp 1				
;		jp nz, CHARSELECTPAL
;		call TITLESCREEN_PALETTE
;		jr PALETTE_DONE
;	CHARSELECTPAL:
;		cp 2
;		jp nz, GAMEPAL
;		call CHARSELECT_PALETTE
;		jr PALETTE_DONE
;	GAMEPAL:
;		cp 3
;		jp nz, TITLEPAL
;		call GAME_PALETTE
;	PALETTE_DONE
RET
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; EXTERNAL ASM FILES ;;
;;;;;;;;;;;;;;;;;;;;;;;;
ASM_DATAFILES: 		read "C:\Amstrad\ASM\GAME\ASM_DATAFILES.ASM"	; Variables/code for other screens etc.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; TITLE SCREEN GRAPHICS DATA ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
TITLELEFT: 		incbin "C:\Amstrad\Graphics\Titlescreen\Title Transp LEFT.RAW"
TITLERIGHT:		incbin "C:\Amstrad\Graphics\Titlescreen\Title Transp RIGHT.RAW"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;