[cc65] MemBank128: Loading to Bank 1?

From: Joseph Rose <rose.joseph121yahoo.com>
Date: 2012-02-07 20:07:45
I am woking on a memory enhancement for the C128 called MemBank128.  It works like Hidden64 and gives the cc65 pogammer 118k+ RAM with which to play.  Right now, I'm in the process of loading files from disk.  The problem is that, whether I'm using the routine supplied with cc65 or my modified version, nothing seems to load.  I looked in the C128 reference, and it told me to use the SETBNK kenal routine.  I did so, but it didn't load.  I rearranged a few functions but to no avail.  I set both the name and load banks to 0.  The data to load is supposed to load at address 0x400 and I was seeing if it would load to the screen.  It didn't.  I even tried to supply a load address, but it didn't work.  I wrote the start address to the file, so that is not the problem.  The following are some of the code files in question:
 
    test.c
----------------
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#include <c128.h>
#include "membank128.h"
extern char *s1;//="Welcome to Mars!\n";
extern char s2 [32];
void main ()
{
 puts ("Loading application buffer data...");
 //cbm_load (8,"b128low",0);
 puts ("Loading Bank 1 data...");
 printf ("-%d-\n",bank1_cbm_load (8,"b128-b1",0x0400));
 //printf ("-%d-\n",cbm_load (8,"b128-b1",0x0400));
 puts ("Finished.  Press a key.");
cgetc();
 bgcolor (1);
 textcolor (2);
 bordercolor (3);
 clrscr();
 bank1_print (s1);
 putchar ('-');
cgetc();
 cbm_open (1,8,CBM_WRITE, "@:marsgreet,s");
 bank1_cbm_write (1,s1, strlen(s1));
 cbm_close (1);
 cbm_open (2,8,CBM_READ, "marsgreet,s");
 bank1_cbm_read (2, s2, 31);
 cbm_close (2);
 chline (39); putchar (13);
 bank1_print (s2);
}
----------------------
b1_cbm_load
----------------------
/*
 * Marc 'BlackJack' Rintsch, 06.03.2001
 *
 * unsigned int cbm_load(const char* name,
 *                       unsigned char device,
 *                       const unsigned char* data);
 */
#include <stdio.h>
#include <cbm.h>
#include "..\membank128.h"
/* loads file "name" from given device to given address or to the load address
 * of the file if "data" is 0
 */
unsigned int bank1_cbm_load(const char* name, unsigned char device, void* data)
{
 /* LFN is set to 0 but it's not needed for loading.
  * (BASIC V2 sets it to the value of the SA for LOAD) */
 static int i;
putchar ('1');
 cbm_k_setlfs(0, device, data == 0);
 cbm_k_setnam(name);
 cbm_k_setbnk (0, 0);
putchar ('2');
 //return (cbm_k_load(0, (unsigned int)data) - (unsigned int)data);
 //return (cbm_k_load(0, (unsigned int)data));
 i=(cbm_k_load(0, (unsigned int)data));
 //cbm_k_setbnk (0, 0);
putchar ('3');
putchar (13);
 return i;
}
------------------
c_setbnk.s
-----------------------
; SETBNK c128 kernal routine wrapper for cc65 with the MemBank128 memory 
; enhancement.
;
; by Joseph Rose, a.k.a. Harry Potter
;-----------------------------------------------------------------------
        .export         _cbm_k_setbnk
        .import         SETBNK
        .import         popa, callkernal
 .importzp tmp1, tmp2, tmp4
                              
.segment "LOWCODE"
_cbm_k_setbnk:
sta tmp1
 jsr popa
 sta tmp4
 lda #$68
 ldx tmp1
 jmp callkernal-----------------------
The callkernal funcion delegates a call to the kernal routine in age 255 with the LSB in .A; the contents of .A is assed in tmp4.
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Tue Feb 7 20:08:02 2012

This archive was generated by hypermail 2.1.8 : 2012-02-07 20:08:05 CET