CARTRIDGE (COMPLICATED) BASIC
CARTRIDGE (COMPLICATED) BASIC
THERE ARE SO MANY THINGS TO TALK ABOUT HERE I DON'T KNOW
WHERE TO BEGIN. LET'S START WITH THE SIMPLE THINGS FOR THE
BASIC PROGRAMMER (AVERAGE USER). TRY THIS BASIC STATEMENT.
SCREEN 6
IT DOESN'T WORK. MODE 6 ON THE SCREEN COMMAND IS NEW TO
BASIC BECAUSE IT SETS UP (OR SHOULD SET UP) THE 4 COLOR 640 X
200 COLOR GRAPHICS MODE. THIS MODE IS AVAILABLE ONLY ON
JUNIOR, THANKS TO THE DIFFERENT VIDEO CIRCUITRY. THE OLD PC
WILL ONLY DO BLACK AND WHITE AT THIS RESOLUTION, JUNIOR GIVES
YOU 4 COLORS.
BUT IF YOU TRY TO USE THIS NEW MODE CARTRIDGE BASIC WILL GIVE
YOU AN ILLEGAL FUNCTION CALL ERROR MESSAGE. IN FACT THE
SCREEN 5 COMMAND DOESN'T WORK EITHER. THIS COMMAND WOULD PUT
YOU INTO THE 16 COLOR 320 X 200 MEDIUM RESOLUTION MODE, IF IT
WORKED.
THE USUAL SOLUTION TO THESE PROBLEMS BEGINS BY LOOKING
IN THE BASIC MANUAL UNDER THE SCREEN COMMAND. THERE ARE NO
EXAMPLES THERE AS TO HOW TO USE THE SCREEN MODE 6 OR 5. THERE
ARE EXAMPLES OF ALL THE OTHER MODES BUT NONE FOR 6 OR 5.
THE SOLUTION IS FOUND ONLY UNDER THE CLEAR COMMAND
(PAGE 4-57). IN ORDER TO USE THE THESE NEW HIGHER RES. MODES
YOU MUST FIRST RESERVE THE MEMORY FOR THE VIDEO SCREEN. YOU
CAN DO THIS BY USING THE FOLLOWING COMMAND;
CLEAR,,,32768
NOW BOTH SCREEN 5 AND SCREEN 6 COMMANDS WORK FINE. YOU
JUST HAVE TO LEARN TO HUNT THROUGH THE MANUAL TO FIND THESE
THINGS.
THE SECOND TOPIC COMES FROM THE QUESTIONS WE HAVE BEEN
GETTING FROM PEOPLE USING LEGACY EXPANSIONS ON THEIR JUNIORS.
THE QUESTION IS 'WHY DOES LEGACY HAVE PROBLEMS WITH BASIC?'
THE ANSWER HAS TWO PARTS. FIRST, BASIC FORCES THE VIDEO
MEMORY BACK TO THE TOP OF THE 128K THAT JUNIOR IS "SUPPOSED"
TO HAVE AS A MAXIMUM. THE LEGACY SYSTEM MOVES THE VIDEO PAGE
DOWN INTO LOWER MEMORY TO CONSERVE SPACE. BASIC DEFEATS THIS
BY BYPASSING BIOS LEVEL CALLS AND CHANGING THE VIDEO BY BRUTE
FORCE. IT OUTPUTS THE VALUE 3FH TO THE PORT ADDRESS 03DFH TO
CHANGE THE VIDEO TO PAGE 7, RATHER THAN USE THE BIOS CALL TO
CHANGE THE PAGE. USING DEBUG YOU CAN SEE THE CODE AT
E800:80F9. FOR BEGINNERS, RUN THE PROGRAM DEBUG ON YOUR DOS
2.1 SUPPLEMENTAL DISK. MAKE SURE YOUR BASIC CARTRIDGE IS
INSTALLED FIRST. DEBUG WILL COME BACK WITH THE MINUS SIGN AS
A PROMPT. LIKE SO;
-
FROM THERE JUST TYPE THE FOLLOWING COMMAND:
-U E800:80F9
THIS WILL SHOW YOU THE ASSEMBLY LANGUAGE CODE OF THE BASIC
INTERPRETER. YOU SHOULD THEN SEE THE FOLLOWING:
E800:80F9 B03F MOV AL,3F
E800:80FB BADF03 MOV DX,03DF
E800:80FE EE OUT DX,AL
.
.
.
. AND SO ON
THOSE FIRST THREE LINES ARE THE CAUSE OF THE PROBLEMS. THEY
DO SIMILAR THINGS AT E800:8E27 AND AT E800:8E87. IF ONLY THEY
HAD USED BIOS EVERYTHING WOULD WORK FINE.
THE SECOND PROBLEM IS DUE TO BASICS' MEMORY ALLOCATION
SCHEME. WHEN BASIC BEGINS IT TELLS YOU HOW MANY BYTES IT HAS
FREE AND AVAILABLE FOR USE. NORMALLY YOU WOULD THINK THAT
BASIC WOULD USE THE VALUE OF MEMORY_SIZE (THE AMOUNT OF
MEMORY AVAILABLE, THIS IS STORED IN THE WORD AT ADDRESS
40:13) TO DETERMINE HOW MUCH MEMORY IT CAN USE. ACTUALLY,
BASIC DOES AN INTERRUPT 12H TO DETERMINE THE MEMORY SIZE.
THIS IS JUST A CONVENIENT, AND SAFE, WAY TO GET MEMORY_SIZE.
BUT THEN THEY GO AND ONLY USE THE LOW BYTE OF THE VALUE!
SEE THE CODE AT E800:264. THIS CAUSES PROBLEMS WHEN YOU ADD
MEMORY TO JUNIOR BEYOND THE 128K JUNIOR IS SUPPOSED TO HAVE.
WITH A 128K JUNIOR THE VALUE OF MEMORY_SIZE IS 0070H. IF YOU
NOW ADD 128K MORE TO MAKE A TOTAL OF 256K THEN MEMORY_SIZE
BECOMES 00F0H. THIS IS OK BECAUSE YOU HAVEN'T LET MEMORY_SIZE
CARRY INTO THE UPPER BYTE YET. BASICA WILL STILL THINK, AND
RIGHTFULLY SO, THAT THERE ARE 60130 BYTES FREE.
BUT, WHEN YOU ADD ANOTHER 64K BYTES TO JUNIOR MAKING A TOTAL
OF 384K THE TROUBLE BEGINS. THE NEW VALUE OF MEMORY_SIZE IS
0130H. NOW WHEN BASIC LOOKS AT MEMORY_SIZE'S LOW BYTE IT WILL
THINK IT HAS VERY LITTLE MEMORY TO WORK WITH, WHEN IN FACT IT
HAS MORE THAN IT DID WITH 256K INSTALLED. SINCE IT ONLY USES
THE VALUE 30H, BASIC WILL SAY IT ONLY HAS 18962 BYTES FREE.
TO RUN BASIC WITH LEGACY JUST BOOT YOUR STANDARD DOS 2.1
DISK RATHER THAN YOUR LEGACY DOS DISKETTE, AND HOPE THAT
MICROSOFT COMES OUT WITH A NEW CARTRIDGE BASIC THAT SOLVES
BOTH OF THESE PROBLEMS.
FOR PEOPLE WHO ARE WRITING PROGRAMS TO PUT INTO CARTRIDGES
YOU SHOULD NOTE WHAT APPEAR TO BE ERRORS IN THE TECHNICAL
REFERENCE MANUAL ON PAGES 2-110 AND 2-111. THE MOST IMPORTANT
THING IS THE JUMPS TO NAMED ROUTINES. THE MANUAL SAYS THEY
SHOULD BE WORD VALUES THAT POINT TO ROUTINES TO BE EXECUTED.
THE BASIC CARTRIDGE HAS SOMETHING VERY DIFFERENT. THEY ARE
ACTUALLY THREE BYTES LONG AND ARE JMP COMMANDS FOLLOWED BY A
TWO BYTE OFFSET. INSTEAD OF DOING AN INDIRECT JUMP OR CALL
TO A POINTER STORED HERE YOU WOULD DO AN IMMEDIATE JUMP OR
CALL TO THE CODE HERE. CARTRIDGE BASIC CONTAINS TWO NAMED
COMMANDS, BASIC AND BASICA, AND IS A GOOD EXAMPLE OF WHAT A
DOS COMMAND CARTRIDGE HEADER SHOULD LOOK LIKE.
THE SECOND DIFFERENCE IS THAT MY CARTRIDGE BASIC STARTS AT
E800:0 NOT E000:0 AS STATED ON PAGE 2-111 OF THE TRM.
Comments
Post a Comment