\ dbcosmac

needs core-ext
needs DataMgr
needs zstrings
needs struct
needs ids
needs dbframework

decimal

struct
    1 cells field rec.type
    1 field rec.namesize
    32 field rec.name
    1 field rec.namenullterm
    1 cells field rec.startaddr
    1 cells field rec.reserved
end-struct RecHdr:

32 constant sizeof-rec.name

\ header is temporary storage used
\ during program save/load.
RecHdr: header
: clear-header  ( -- )
    header
    [ sizeof RecHdr: ] literal   erase ;

\ Given the start and end addresses
\ of a program, calculate the record
\ size, which includes the rechdr.
: calc-recsize  ( start end -- size )
    swap -  1+   
    [ sizeof RecHdr: ] literal + ;

: dbname  ( -- zstring )
    z" elfprog-1802" drop ;

Database: db
    false              \ resDB? = false
    (id) pROg      \ type.
    (id) 1802      \ creator.
    dbname        \ zname
    db db-init     \ init the structure

\ Constants that get plugged into the
\ record header's rec.type field.

\ RECTYPE-PROG records contain
\ 1802 binary program data after
\ the record header.
1 constant RECTYPE-PROG



