Work in Progress

General

Through out this manual I’ll be referring to the platform as PC-6 which includes these models:

  • Al-Warka PC-6001
  • Al-Warka PC-6002
  • NEC PC-6001 Mk2
  • NEC PC-6001 Mk2 SR
  • NEC PC-6601
  • NEC PC-6601 SR
  • NEC Mr PC

On the BASIC front, this manual is biased towards N60m-BASIC, N66-BASIC, and N66SR-BASIC. These are the interpreters used in Mode 5 and Mode 6 on PC-6.

Color Palette

The PC-6 and for Mode 5 (text and screen 3) and Mode 6 (text and screen 2), full 16-color screen modes use this palette:

colorpalette

COLOR RGB R,G,B
1 0xFF101410 16,20,16
2 0xFFAD00FF 173,0,255
3 0xFFFFAE00 255,174,0
4 0xFFFF00AD 255,0,173
5 0xFF00FFAD 0,255,173
6 0xFF00AEFF 0,174,255
7 0xFFADFF00 173,255,0
8 0xFFADAEAD 173,174,173
9 0xFF101410 16,20,16
10 0xFF0000FF 0,0,255
11 0xFFFF0000 255,0,0
12 0xFFFF00FF 255,0,255
13 0xFF00FF00 0,255,0
14 0xFF00FFFF 0,255,255
15 0xFFFFFF00 255,255,0
16 0xFFFFFFFF 255,255,255

Mode 5 Screen 4 uses this 4 color palette:

colorpalette_m5s4

Mode 6 Screen 3 uses this 4 color palette:

colorpalette_m6s3


MODE 5

Memory Map

SCREEN/PAGE memory addresses

8 pixels block per byte-pair.

Size of each buffer is: 1 byte * 40 * 200 = 8000 byte or 0x1f40 byte

PAGE mode PAGE 1 (text) PAGE 2 (graphics) PAGE 3 (graphics) PAGE 4 (graphics)
3 Pages ?? 0x4000 + 0x6000 0x0000 + 0x2000  
4 Pages ?? 0x8000 + 0xa000 0x4000 + 0x6000 0x0000 + 0x2000

SCREEN 3 Colors

Screen 3 is actually 160x200 mapped to 320x200 so each pixel is a horizontal 2 pixels.

Each 4 horizontal-pixel (or 8 pixels) are stored in 2 bytes, one in page address and one in page address + 0x2000:

ADR = &H2000
ATR = &H4000

The color of the 4 horizontal-pixels is determined by the combination of both ADR and ATR bytes for those pixels. ATR is the high byte and ADR is the low byte:

  P0 P1 P2 P3
ATR 0 0 0 0 0 0 0 0
ADR 0 0 0 0 0 0 0 0

MODE 6

Memory Map

SCREEN 2 (320x200)

Divided into two segments in memory, 1 byte maps directly to 2 pixel colors, 16 colors palette.

  • Right rect/segment is a 64x200 mapped to memory: 0x0000 to 0x18ff
    • 1 horizontal line size = 32 bytes
  • Left rect/segment is a 256x200 mapped to memory: 0x1a00 to 0x7dff
    • 1 horizontal line size = 128 bytes

mode6screen2_rects_gif

Bytes are arranged in groups of 4 pixels, two top and two bottom so the layout is linear in blocks of 4 pixels (2 bytes) otherwise doing single-pixel operations correctly is a bit tricky and requires some number juggling:

MEMORY Low 4-bit High 4-bit
Byte 0 Pixel 0 Pixel 1
Byte 1 Pixel 2 Pixel 3

SCREEN 3 (640x200)

Divided into two segments in memory, 1 byte maps directly to 4 pixel colors, 4 colors palette.

  • Right rect/segment is a 64x200 mapped to memory: 0x0000 to 0x18ff
    • 1 horizontal line size = 32 bytes
  • Left rect/segment is a 256x200 mapped to memory: 0x1a00 to 0x7dff
    • 1 horizontal line size = 128 bytes

mode6screen3_rects_gif


N66/SR BASIC

N66/SR BASIC Commands

ABS AND ASC ATN ATTR$ AUTO BEEP BGM
BLOAD BSAVE CDBL CHAIN CHR$ CIRCLE CLEAR CLOAD
CLOSE CLS CMD COLOR COM COMMON CONSOLE CONT
CSAVE CSNG CSRLIN CVD CVS DATA DATE$ DEF
DEFDBL DEFINT DEFSNG DEFSTR DELETE DIM DSKF DSKI$
DSKO$ END EOF EQV ERASE ERL ERR ERROR
EXEC EXP FIELD FILES FIX FN FOR FPOS
FRE GET GOSUB GOTO GRP$ HEX$ IF IMP
INKEY$ INPUT INSTR INT KANJI KEY KILL LCOPY
LEFT$ LEN LET LFILES LFO LINE LIST LLIST
LOAD LOCATE LOF LOG LPOS LPRINT LSE LSET
MAP MENU MERGE MID$ MKD$ MKI$ MOD MON
MOTOR NAME NEW NEXT NOT OCT$ OFF ON
OPEN OR OUT PAINT PALET PEEK PEN PLAY
POINT POKE POS PRESET PRINT PSET PUT READ
REM RENUM RESTORE RESUME RETURN RIGHT$ ROLL RSET
RUN SAVE SCREEN SEARCH SET SIN SOUND SPC
SQR SRQ STEP STICK STOP STR$ STRIG STRING$
SWAP TAB TALK TAN TERM THEN TIME TO
TROFF TRON USING USR VARPTR VIEW WAIT WEND
WHILE WIDTH WINDOW XOR        

N66/SR BASIC Reference (WIP)


System Commands

ABS

Returns absolute value of given number.

PRINT ABS(-5)
 5

AND

Perform a logical AND operation between two values that can be evaluated as true/false.

IF A>5 AND B<3 THEN PRINT "THERE"

ASC

Returns the ASCII code of a given character (or first char of string).

PRINT ASC("A")
 65

AUTO

Automatically inserts line numbers whenever you press enter until stopped.

AUTO 10,5
10 PRINT
15 PRINT
20 BEEP

BEEP

Produces a BEEP sound using sound chip

BLOAD

Loads binary file from disk to memory.

Params:

  • offset: 16-bit address where to load the data starting from
BLOAD "stuff.dat",&h455F

BSAVE

Save binary file from memory to disk.

Params:

  • offset: 16-bit address where to start saving data
  • length: 16-bit length of data to save to disk
BSAVE "stuff.dat",&hA200,200

CHR$

Converts a given number to the corresponding ASCII character.

Usage:

CHR$(number) -> ascii code, number between 0 and 255

Examples:

PRINT CHR$(55) will print 7

IF INKEY$=CHR$(27) THEN END will end execution when Escape key is pressed

CIRCLE

CLEAR

CLOAD

CLOSE

CLS

Clears current write page. Works in text mode or graphics mode.

Write page can be set to be different from visible page. See SCREEN for more information.

COLOR

COMMON

CONSOLE

CONT

CSAVE

CSRLIN

CVD

CVS

DATA

DATE$

DEF

DEFDBL

DEFINT

DEFSNG

DEFSTR

DELETE

DIM

DSKF

DSKI$

DSKO$

END

Ends execution immediately

Usage:

END -> ends execution

Examples:

END

EOF

EQV

ERASE

ERL

ERR

ERROR

EXEC

Executes machine code at given hexadecimal memory address.

Usage:

EXEC(number) -> number is a 16-bit memory address in range: &h0000 to &hffff

Examples:

EXEC &H8000 to execute machine code starting at memory address 0x8000

EXP

FIELD

FILES

FIX

FN

FOR

FPOS

FRE(arg)

Returns amount of unused available memory in bytes.

Usage:

FRE(“”) -> Available string space. (300 on mode 6 startup)

FRE(number) -> Available unused memory in bytes.

Example:

PRINT "Available string memory = " ; FRE("") ; " characters"
PRINT "Unused memory = " ; FRE(0) ; " bytes"

GET

GOSUB

GOTO

GRP$

HEX$

IF

IMP

INKEY$

INPUT

INT

KANJI

KEY

KILL

LCOPY

LEFT$

LEN

LET

LFILES

LINE

LIST

LLIST

LOAD

LOCATE

LOF

LOG

LPOS

LPRINT

LSE

LSET

MENU

MERGE

MID$

MKD$

MKI$

MOD

MON

MOTOR

NAME

NEW

NEXT

NOT

OCT$

OFF

ON

OPEN

OR

OUT

PAINT

PALET a, b

Allows modifying the color palette in MODE 6 SCREEN 3. For this mode, the palette is assigned to color entries: 13, 14, 15, 16

colorpalette_m6s3

PALET a, b
  • a: palette entry to change, can be: 13, 14, 15, 16
  • b: color of choice for entry A, can be any color from: 1 to 16

Example: change color 1 to red:

PALET 13,11

PEEK

PEN

PLAY

POINT

POKE

POS

PRESET

PRINT

PSET

PUT

READ

REM

RENUM

RESTORE

RESUME

RETURN

ROLL

RSET

RUN

SAVE

SCREEN

As a statement: used to set display mode, visible page, and write page

Usage:

SCREEN display_mode, visible_page, write_page

display_mode:

  • N66: 1,2->text, 3->320x200x15, 4->320x200x4
  • N66 SR: 1->text, 2->320x200x15, 3->640x200x4

visible_page and write_page:

  • N66: between 1 and number of PAGES set
  • N66 SR: PAGE 1 or 2

Examples:

SCREEN 3,2,2 sets graphics mode 3, visible and write pages to 2nd

SCREEN 4,3,2 sets graphics mode 4, visible page to 3rd, write page to 2nd

As a function: used to read the ascii character at specific text coordinates.

Usage:

SCREEN(x, y) -> returns ascii code of character at text coordinates x, y in text mode, always returns zero in graphics modes

Examples:

PRINT SCREEN(2,5) returns ascii code at text location 2, 5

SIN

SOUND

SPC

SQR

STEP

STICK

STOP

STR$

STRIG

STRING$

SWAP

TAB

TALK

TAN

THEN

TIME

TO

TROFF

TRON

USING

USR

WAIT

WHILE

WIDTH

XOR


Unknown Commands

BGM

BGM takes a number as argument, could be 0 or 1.

Based on how BGM is implemented in SmileBasic it might be meant to store music notation strings to replay them anytime?

Example:

BGM 0

Not Available Commands

If you attempt to use these commands you’ll get an “?NA Error” (Not Available Error).

According to the some of the same commands in MSX BASIC, these commands point to an empty location in memory allowing diversion to custom code.

ATTR$()

Not Implemented

This was meant to return disk drive attributes.

CDBL

Not Implemented

Casts an integer or single precision number to double precision.

CINT

Not Implemented

Casts a single or double precision number to integer.

CSNG

Not Implemented

Casts an integer or double precision number to single precision.

CHAIN

Not Implemented

CMD

Not Implemented

COM

Not Implemented

INSTR

Not Implemented

LFO

Not Implemented

MAP

Not Implemented

Not Implemented

SET

Not Implemented

SRQ

Not Implemented

TERM

Not Implemented

VARPTR

Not Implemented

VIEW

Not Implemented

WINDOW

Not Implemented

WEND

Not Implemented


ATN

Return inverse tangent of x (ATAN)

COMMON

DEFDBL

DEFINT

DEFSNG

DEF FN

DEF

DSKF

DSKI$

DSKO$

EQV

ERASE

FIX

GRP$

IMP

LOF

LSE

MID$

MKD$

MKI$

PALET

RSET

SPC(

STRING$

TAB(

USR

WAIT