Using $a000 ram for programs

Basic and Machine Language

Moderator: Moderators

Post Reply
spudgunjake
Vic 20 Newbie
Posts: 2
Joined: Tue Jun 21, 2016 2:30 am
Location: UK (HULL)
Occupation: IT

Using $a000 ram for programs

Post by spudgunjake »

I would like to use as much as possible memory of the Vic20, Im using Xvic to emulate the Vic20, I have most of the machine code working, but cant seems to get to use the $a000 area, here's my simple code. of cause Emulator is set to use all blocks 1-5.

What am I doing wrong, I can simply do, poke 40960,81, and it puts 81 at location 40960, when when I compile my code and run it, and check $a000 it shows all '0's

Please help.

thanks john

Code: Select all

// text

.const SYS = $9e
		
.const VBLACK 	=	0
.const VWHITE 	=	1
.const VRED		=	2
.const VCYAN	=	3
.const VMAGENTA	=	4
.const VGREEN	=	5
.const VBLUE	=	6
.const VYELLOW	=	7

.const Border_Screen_Colours		=	$900F	// 36879 Border and Screen colour..
.const Chr_Screen_Pointer		=	$9005	// 36869
.const Multi_Colour_Mode		=	$08	// %00001000
.const AuX_Colour_Volume		=	$900E	// 36878

 
//#define VIC_UNEXPANED
//#define VIC_EXPANED3k
#define VIC_EXPANED8k



#if VIC_UNEXPANED
    .print " "
    .print "***** Vic 20 Unexpanded Configuation *****"
    
	.const Vic_Basic_startup 	=  $1001	// 4097 Basic startup 
	.const Vic_Screen_Memory	=  $1E00	// 7680 start of Screen Memory
	.const Vic_Colour_Memory	=  $9600	// 38400 start of Colour Memory
	.const MY_CODE		=  $100E	// 4110 My Code.
	.const CHARMEM		=  $1400	// My Graphics.

	
#endif 

#if VIC_EXPANED3k

    .print " "
    .print "***** Vic 20 Expanded 3k Configuation *****"
    
	.const Vic_Basic_startup 	=  $0401	// 1025 Basic startup
	.const Vic_Screen_Memory	=  $1E00	// 7680 start of Screen Memory
	.const Vic_Colour_Memory	=  $9600	// 38400 start of Colour Memory		
	.const MY_CODE		=  $040E	// 1038 My Code.
	.const CHARMEM		=  $1400	// 5120 My Graphics.

#endif 

#if VIC_EXPANED8k

    .print " "
    .print "***** Vic 20 Expanded 8k and above Configuation *****"

	.const Vic_Basic_startup	= $1201	// 4609 Basic startup  
	.const Vic_Screen_Memory	= $1000	// 4096 start of Screen Memory	
	.const Vic_Colour_Memory	= $9400	// 37888 start of Colour Memory
	.const MY_CODE		= $A000	//$4000	// $4000-6000- $120E	// 4622 My Code.
	.const CHARMEM		= $1400	// 5120 My Graphics. 
#endif 
			
 * = Vic_Basic_startup "Basic startup.."		// Basic BasicUpstart(MY_CODE)
 
 :BasicVic20startup2(MY_CODE)

*= MY_CODE	"MY Main Code.."

		lda #$0
		sta Vic_Screen_Memory
					
		lda #%00000111		// Yellow 7 bits 00
		ora #%00001000		// Turn on Multi Colour Mode
		sta Vic_Colour_Memory
					
		lda #%00110100		// S-Cyan CHR Bits 00  B-Magenta 3 Bits 01 
		sta Border_Screen_Colours	// 36879screen cyan +  border cyan 	
	
		lda #%00001111			// should be black Bits 00
		sta AuX_Colour_Volume	// 36879 AUX Colour and Volume	

		lda #%11001101
		sta Chr_Screen_Pointer	
	
here:		rts
		.text "the end"
	
//VBLACK_0-VWHITE_1-VRED_2-VCYAN_3-VMAGENTA_4-VGREEN_5-VBLUE_6-VYELLOW_7

	   		
*=CHARMEM "MY CHRSET"
	.import binary "full.bin" // taken from Frak c64 3af0
END_OF_CHARMEM:
	
	
.macro BasicVic20startup2(MAIN) 			// Simple Macro defining start of Basic run routine.			
{
        		.word 	END_OF_BASIC	// END_OF BASIC, Next Line link, here end of Basic program.
            	.byte	$0A,00     		// The line number 10 for the SYS statement.
            	.byte	SYS         	// SYS token $9e.                    
            	.text	MY_CODE		// Where is code as string. use .Text
            	.byte	$00           	// End of Basic line
END_OF_BASIC:   	.byte	$00,$00        	// End of Basic program

	.print ""
	.print "Basic startup	 		" + Vic_Basic_startup 
	.print "END_OF_BASIC			" + END_OF_BASIC 	
	.print "start of Screen Memory 	" + Vic_Screen_Memory
	.print "End of Screen Memory 		" + (Vic_Screen_Memory+506)
	.print "start of My Code 		" + MY_CODE		
	.print "start of Colour Memory	" + Vic_Colour_Memory
	
	.print "start of Define Graphics 	" + CHARMEM	
	.print "END OF CHARMEM		" + END_OF_CHARMEM	


}
(mod: code put into code tags)
User avatar
Mike
Herr VC
Posts: 4816
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Using $a000 ram for programs

Post by Mike »

Hi, John,

first of all: Welcome to Denial! :)

What stands out in your example is the (most probably conceptual mis-)use of multiple ORG statements "*=".

I presume you meant the assembler to produce an executable, which takes those segments and then copies them into place - well at first there's nothing at that code abstraction layer (even including macros) and also still not the KERNAL/OS that's available to support that feat. If anything, the assembler will just produce an over-length executable, which contains all those segments - with a lot of 0's in-between.

That executable will however scribble happily over the I/O area at $9000..$9FFF while it's being loaded, causing a crash before anything is written to $A000 and beyond.

What you can do is, either provide all data in separate files, and then load them each into place with the KERNAL load function - or use a tool like Exomizer, which can take such files that reside in disjunct memory areas, compresses them and produces a single file as result.

Greetings,

Michael

P.S. please put the code into code-tags so it doesn't span several pages to scroll down...
spudgunjake
Vic 20 Newbie
Posts: 2
Joined: Tue Jun 21, 2016 2:30 am
Location: UK (HULL)
Occupation: IT

Re: Using $a000 ram for programs

Post by spudgunjake »

I'll take you advice on board

many thanks for the reply.
Post Reply