General Instructions
County Quiz is a geographical trivia game that tests your knowledge of the English counties. You are presented with a map of England and you have to name the shaded county with the help of the county's coat of arms, shown on the left.
The computer will ask you type in your name then greet you before asking 20 questions. The game incorporates an interactive spell checker so when typing the county name you only need enter the first three (or sometimes four or five) letters. For you every correct answer you will be rewarded with a St George's flag.
There is a short introductory graphics demo, INTRO, to this game which I hope you enjoy. This sets up PAGE to &4300 before CHAINing CQASSEM. This is the assembly code for decompressing MAP (map of England), plotting the coats of arms double height, changing the palette, matching typed in characters to county names, and retrieving the fill points for a county. CQASSEM sets up font flags in page three for half-size numbers and letters.
CQGAME is the main game written in BASIC, which CALLs the machine code routines as required. Have fun!
Technical Notes
CQASSEM Assembly Routines
CLRS | Sets the palette for county number in &72, an index numbred 0-39 into nybble CIDX1 (Colour InDeX 1). There are 20 bytes or 40 nybbles for the 40 counties. Each nybble is an index numbered 0-8 into CIDX2 (Colour InDeX 2), which holds the four actual colours for the nine palettes used. CIDX2 has nine entries of two bytes (four nybbles) each - four actual colour numbers are held in four nybbles. OSWORD 12 is used to change the palette to save lots of VDU 19s |
COUNTY | This is called from Basic A% (A register) set to the county whose fill point on the map, colours, name and coat of arms is required | LOGO | Sets up the memory locations to print the logo, stored at &3E00, at &5D00 |
MAP | *LOADs the black and white image onto the bottom of the Mode 5 screen and decompresses it. The map is stored in two sections - north (expands to 20 columns by 17 character rows), and south (expands to 31 columns by 15 character rows). EXPAND is called for each section. The leftover garbage down the righthand side of the screen is blanked out (See lines 400 to 480) |
EXPAND | Requires X/Y to be set to te address of the compacted data (X=lo byte, Y=hi byte), A=number of character rows in decompacted picture &70/71 the address of the top left of the expanded image, &72=number of bytes in one row of compacted data (i.e. number of bytes in decompacted image divided by two). Each byte of data is split into high and low nybble. Nybbles are converted into the corresponding pixel codes for the Mode 5 screen by duplicating the low nybble in the high nybble position, 0 - &00, 1 -> &11, 2 -> &22 etc. PUT writes the code to the screen after ANDING with with 245 and 250 alternately. This gives a yellow/white dithered effect |
FNDNM |
Places the name of county number in &72 into the text buffer. County names are stored at CNAMES as |
SPRITE | prints the coat of arms, whose number is held in A and must be 0-39 corresponding to county numbers 0-39. Each coat of arms comprises 8 columns by 4 character rows, plus 4 columns by 1 character row at the bottom. The top section is printed at &5D00, the bottom part at &5D00 + 8*&140 = &6700 (not 4*&140, remember it is double height on the screen) |
SPRITE2 | prints number of character rows in &71 times the number of columns in &72 double height at address in &74/75. Note that the code is 'self-altering' so the address held in LDA &1100,X (at SDATA) can vary |
SRCH | Locates the start of the flood-fill data for fill county in &72 and stores the address in &80/81 and the number of fill points in &82 ready for use by procedure PROCfill in program CQGAME. The data is stored at FLLPNTS as the number of fill points, N, followed by N pairs of coordinates. For compactness the X points are stored divided by eight and Y points divided by four so they can fit into one byte each |
TYPN | Attempts to match the typed-in string, stored in text buffer BF, to the county names by comparing the first Y-1 characters. Usually only three letters are checked (Y=4) but in the case of HEREfordshire and HERTfordshire Y=5, and similarly Y=6 for NORFolk, NORTHAmptonshire, and NORTHUmberland, i.e. the sixth letter of Northumberland distinguishes it from Northamptonshire. If matched successfully, the full county name, else a CR (null string), is placed in BF |
CQGAME Procedures
bl | Blanks out county name, question etc. |
britan(L%) | Plays RULE BRITANNIA from the DATA starting at line L% - lines 790-810 contains data for the nice harmony, line 820 is a bit more interesting! |
demo | Cycles through the counties displaying their coats of arms on the screen. Use this to refresh your memory of which county is which! |
fill(C%) | Fills a county in colour C%, given the start of the fill points in &80/81 and number of fill points in &82 (see SRCH in CQASSEM commentary) |
flag(X%,Y%,D%) | Print flag D% at (X%,Y%). The screen address is worked out as &5800+X%*&10+Y%*&140 and then the flag data is peeked from &3F40 or &3F50 depending on the flag required |
flood(X%,Y%,D%) | Recursively flood-fills the area at (X%,Y%) searching right and up (D%=4) or down (D%=-4) until a boundary is reached |
question | Chooses a county at random and asks the player for its name |
logo | Prints the introductory messages, plays RULE BRITANNIA, CALLs the logo printing routine and invites the player to type in their name |
score | Prints flags at bottom of screen, firstly by seeing how many multiples of five there are in the S%, the score, and printing that number of flags with '5' on them, then printing the remainder as St George's flags |
txt(X%,Y%,A$,D%) | Prints text A$ at (X%,Y%). If D% is set to 1, a shadow effect is created with white letters offset from red ones; if D%=0 letters are printed in red |
CQGAME Functions
chs(A%) | Chooses at random one of the messages from DATA line A%. Each line contains the number of messages to choose from followed by the messages themselves |
enter(H%,V%,M%) | Filters input from the keyboard so that only letters A-Z are allowed on the screen in the shadowed text, up to a maximum of M% characters. Returns the inputted string characters. Returns the inputted string when either RETURN is pressed or M% number of characters have been typed. |
CQGAME Major Variables
E% | Current county number, 0-39 |
S% | Score |
n$ | Player's name |