get inflate test working
This commit is contained in:
parent
185b833929
commit
54acc416b0
@ -31,7 +31,7 @@ CONVERT_ZIP = ../../scripts/conv_zip.py
|
|||||||
|
|
||||||
|
|
||||||
ifeq ($(DEBUG),1)
|
ifeq ($(DEBUG),1)
|
||||||
LDFLAGS =-Wl,-u,vfprintf -lprintf_flt
|
LDFLAGS =-Wl,-u,vfprintf
|
||||||
CFLAGS =-Iusbdrv -I. -DDEBUG_LEVEL=0
|
CFLAGS =-Iusbdrv -I. -DDEBUG_LEVEL=0
|
||||||
OBJECTS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o \
|
OBJECTS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o \
|
||||||
main.o usb_bulk.o uart.o fifo.o sram.o crc.o debug.o \
|
main.o usb_bulk.o uart.o fifo.o sram.o crc.o debug.o \
|
||||||
|
|||||||
6
avr/usbload/Makefile.test
Normal file
6
avr/usbload/Makefile.test
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
all:
|
||||||
|
gcc -c loader_test.c
|
||||||
|
gcc -c inflate.c
|
||||||
|
gcc -c neginf/neginf.c
|
||||||
|
gcc -c inflate_test.c
|
||||||
|
gcc -o inflate_test inflate.o neginf.o inflate_test.o loader_test.o
|
||||||
@ -61,37 +61,6 @@ void usb_connect()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void send_reset()
|
|
||||||
{
|
|
||||||
info_P(PSTR("Reset SNES\n"));
|
|
||||||
cli();
|
|
||||||
snes_reset_on();
|
|
||||||
snes_reset_lo();
|
|
||||||
_delay_ms(2);
|
|
||||||
snes_reset_hi();
|
|
||||||
snes_reset_off();
|
|
||||||
sei();
|
|
||||||
}
|
|
||||||
|
|
||||||
void send_irq()
|
|
||||||
{
|
|
||||||
snes_irq_on();
|
|
||||||
snes_irq_lo();
|
|
||||||
_delay_us(20);
|
|
||||||
snes_irq_hi();
|
|
||||||
snes_irq_off();
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_rom_mode()
|
|
||||||
{
|
|
||||||
if (usb_trans.req_bank_size == 0x8000) {
|
|
||||||
snes_lorom();
|
|
||||||
info_P(PSTR("Set SNES lowrom \n"));
|
|
||||||
} else {
|
|
||||||
snes_hirom();
|
|
||||||
info_P(PSTR("Set SNES hirom \n"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void boot_startup_rom(uint16_t init_delay)
|
void boot_startup_rom(uint16_t init_delay)
|
||||||
{
|
{
|
||||||
@ -108,12 +77,6 @@ void boot_startup_rom(uint16_t init_delay)
|
|||||||
system_snes_irq_off();
|
system_snes_irq_off();
|
||||||
system_set_rom_lorom();
|
system_set_rom_lorom();
|
||||||
|
|
||||||
//info_P(PSTR("Activate AVR bus\n"));
|
|
||||||
//avr_bus_active();
|
|
||||||
//info_P(PSTR("IRQ off\n"));
|
|
||||||
//snes_irq_lo();
|
|
||||||
//snes_irq_off();
|
|
||||||
//snes_lorom();
|
|
||||||
|
|
||||||
inflate_init();
|
inflate_init();
|
||||||
for (i=0; i<ROM_BUFFER_CNT; i++){
|
for (i=0; i<ROM_BUFFER_CNT; i++){
|
||||||
@ -136,16 +99,7 @@ void boot_startup_rom(uint16_t init_delay)
|
|||||||
info(PSTR("crc=%x\n"),crc);
|
info(PSTR("crc=%x\n"),crc);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//snes_irq_lo();
|
|
||||||
//snes_irq_off();
|
|
||||||
//snes_hirom();
|
|
||||||
//snes_wr_disable();
|
|
||||||
|
|
||||||
//system_set_bus_snes();
|
|
||||||
//system_set_rom_hirom();
|
|
||||||
//system_set_wr_disable();
|
|
||||||
//system_snes_irq_off();
|
|
||||||
|
|
||||||
snes_irq_lo();
|
snes_irq_lo();
|
||||||
system_snes_irq_off();
|
system_snes_irq_off();
|
||||||
system_set_rom_hirom();
|
system_set_rom_hirom();
|
||||||
@ -158,31 +112,9 @@ void boot_startup_rom(uint16_t init_delay)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void banner(){
|
void banner(){
|
||||||
uint8_t i;
|
|
||||||
for (i=0;i<40;i++)
|
|
||||||
info_P(PSTR("\n"));
|
|
||||||
info_P(PSTR(" ________ .__ __ ________ ____ ________\n"));
|
|
||||||
info_P(PSTR(" \\_____ \\ __ __|__| ____ | | __\\______ \\ _______ _/_ |/ _____/\n"));
|
|
||||||
info_P(PSTR(" / / \\ \\| | \\ |/ ___\\| |/ / | | \\_/ __ \\ \\/ /| / __ \\ \n"));
|
|
||||||
info_P(PSTR(" / \\_/. \\ | / \\ \\___| < | ` \\ ___/\\ / | \\ |__\\ \\ \n"));
|
|
||||||
info_P(PSTR(" \\_____\\ \\_/____/|__|\\___ >__|_ \\/_______ /\\___ >\\_/ |___|\\_____ / \n"));
|
|
||||||
info_P(PSTR(" \\__> \\/ \\/ \\/ \\/ \\/ \n"));
|
|
||||||
info_P(PSTR("\n"));
|
|
||||||
info_P(PSTR(" www.optixx.org\n"));
|
|
||||||
info_P(PSTR("\n"));
|
|
||||||
info_P(PSTR("System Hw: %s Sw: %s\n"),HW_VERSION,SW_VERSION);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void transaction_status(){
|
void transaction_status(){
|
||||||
info_P(PSTR("\nAddr 0x%06lx\n"),usb_trans.req_addr);
|
|
||||||
info_P(PSTR("Bank 0x%02x\n"),usb_trans.req_bank);
|
|
||||||
info_P(PSTR("Banksize 0x%06lx\n"),usb_trans.req_bank_size);
|
|
||||||
info_P(PSTR("Bankcount 0x%02x\n"),usb_trans.req_bank_cnt);
|
|
||||||
info_P(PSTR("Status 0x%02x\n"),usb_trans.req_state);
|
|
||||||
info_P(PSTR("Percent %02i\n"),usb_trans.req_percent);
|
|
||||||
info_P(PSTR("TX buffer %02i\n"),usb_trans.tx_remaining);
|
|
||||||
info_P(PSTR("RX buffer %02i\n"),usb_trans.rx_remaining);
|
|
||||||
info_P(PSTR("Syncerr %02i\n"),usb_trans.sync_errors);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -17,21 +17,30 @@
|
|||||||
*
|
*
|
||||||
* =====================================================================================
|
* =====================================================================================
|
||||||
*/
|
*/
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "neginf/neginf.h"
|
#include "neginf/neginf.h"
|
||||||
|
|
||||||
#include "inflate.h"
|
#include "inflate.h"
|
||||||
#include "sram.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
char inflate_done = 0;
|
char inflate_done = 0;
|
||||||
|
char *mem;
|
||||||
|
int addr = 0;
|
||||||
|
|
||||||
void inflate_init()
|
void inflate_init()
|
||||||
{
|
{
|
||||||
printf("inflate_init\n");
|
|
||||||
neginf_init(0);
|
neginf_init(0);
|
||||||
sram_bulk_write_start(0x000000);
|
mem = (char*)malloc(2<<16);
|
||||||
|
addr = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void inflate_flush()
|
||||||
|
{
|
||||||
|
FILE *file;
|
||||||
|
file = fopen("out.smc","w");
|
||||||
|
fwrite(mem,2<<16,1,file);
|
||||||
|
fclose(file);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void neginf_cb_completed()
|
void neginf_cb_completed()
|
||||||
@ -41,30 +50,18 @@ void neginf_cb_completed()
|
|||||||
|
|
||||||
void neginf_cb_seq_byte(nbyte byte)
|
void neginf_cb_seq_byte(nbyte byte)
|
||||||
{
|
{
|
||||||
//printf("neginf_cb_seq_byte %x", byte);
|
mem[addr] = byte;
|
||||||
sram_bulk_write(byte);
|
addr++;
|
||||||
}
|
}
|
||||||
|
|
||||||
//uint8_t buffer[512];
|
|
||||||
|
|
||||||
void neginf_cb_copy(nsize from, nsize to, nint length)
|
void neginf_cb_copy(nsize from, nsize to, nint length)
|
||||||
{
|
{
|
||||||
uint32_t addr;
|
int i;
|
||||||
uint8_t c;
|
printf("neginf_cb_copy from=0x%06x to=0x%06x len=%i\n",from, to, length);
|
||||||
|
for (i=0; i<length;i++)
|
||||||
printf("neginf_cb_copy %lx %lx %li\n", from, to, length);
|
mem[to+i] = mem[from+i];
|
||||||
|
|
||||||
sram_bulk_addr_save();
|
addr = to + length;
|
||||||
for (addr=from; addr<from+length; addr++){
|
|
||||||
c = sram_read(addr);
|
|
||||||
sram_write(addr,c);
|
|
||||||
}
|
|
||||||
sram_bulk_addr_restore();
|
|
||||||
/*
|
|
||||||
|
|
||||||
sram_bulk_addr_save();
|
|
||||||
sram_bulk_copy_into_buffer(from, buffer, length);
|
|
||||||
sram_bulk_copy_from_buffer(to, buffer, length);
|
|
||||||
sram_bulk_addr_restore();
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
42
avr/usbload/inflate_test.c
Normal file
42
avr/usbload/inflate_test.c
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* =====================================================================================
|
||||||
|
*
|
||||||
|
* ________ .__ __ ________ ____ ________
|
||||||
|
* \_____ \ __ __|__| ____ | | __\______ \ _______ _/_ |/ _____/
|
||||||
|
* / / \ \| | \ |/ ___\| |/ / | | \_/ __ \ \/ /| / __ \
|
||||||
|
* / \_/. \ | / \ \___| < | ` \ ___/\ / | \ |__\ \
|
||||||
|
* \_____\ \_/____/|__|\___ >__|_ \/_______ /\___ >\_/ |___|\_____ /
|
||||||
|
* \__> \/ \/ \/ \/ \/
|
||||||
|
*
|
||||||
|
* www.optixx.org
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Version: 1.0
|
||||||
|
* Created: 07/21/2009 03:32:16 PM
|
||||||
|
* Author: david@optixx.org
|
||||||
|
*
|
||||||
|
* =====================================================================================
|
||||||
|
*/
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "neginf/neginf.h"
|
||||||
|
#include "inflate.h"
|
||||||
|
#include "loader_test.h"
|
||||||
|
|
||||||
|
extern const char _rom[];
|
||||||
|
extern char inflate_done;
|
||||||
|
|
||||||
|
void main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
|
||||||
|
int j;
|
||||||
|
char c;
|
||||||
|
inflate_init();
|
||||||
|
for (j=0; j< ROM_ZIP_SIZE; j++){
|
||||||
|
neginf_process_byte(_rom[j]);
|
||||||
|
}
|
||||||
|
while(!inflate_done)
|
||||||
|
neginf_process_byte(0x00);
|
||||||
|
inflate_flush();
|
||||||
|
}
|
||||||
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
File: qd16boot02.smc
|
File: qd16boot02.smc
|
||||||
Time: Tue, 20 Oct 2009 22:07:40
|
Time: Sat, 24 Oct 2009 19:05:36
|
||||||
*/
|
*/
|
||||||
#ifndef __FIFO_H__
|
#ifndef __FIFO_H__
|
||||||
#define __FIFO_H__
|
#define __FIFO_H__
|
||||||
|
|||||||
2254
avr/usbload/loader_test.c
Normal file
2254
avr/usbload/loader_test.c
Normal file
File diff suppressed because it is too large
Load Diff
7
avr/usbload/loader_test.h
Normal file
7
avr/usbload/loader_test.h
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
#ifndef __FIFO_H__
|
||||||
|
#define __FIFO_H__
|
||||||
|
|
||||||
|
#define ROM_ZIP_SIZE 35945
|
||||||
|
|
||||||
|
#endif
|
||||||
@ -193,14 +193,6 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
|
|||||||
debug_P(DEBUG_USB, PSTR("USB_CRC: addr=0x%08lx \n"), usb_trans.req_addr);
|
debug_P(DEBUG_USB, PSTR("USB_CRC: addr=0x%08lx \n"), usb_trans.req_addr);
|
||||||
crc_check_bulk_memory(0x000000, usb_trans.req_addr, usb_trans.req_bank_size);
|
crc_check_bulk_memory(0x000000, usb_trans.req_addr, usb_trans.req_bank_size);
|
||||||
ret_len = 0;
|
ret_len = 0;
|
||||||
/*
|
|
||||||
* -------------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
} else if (rq->bRequest == USB_MODE_SNES) {
|
|
||||||
usb_trans.req_state = REQ_STATUS_SNES;
|
|
||||||
debug_P(DEBUG_USB, PSTR("USB_MODE_SNES:\n"));
|
|
||||||
ret_len = 0;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* -------------------------------------------------------------------------
|
* -------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -266,12 +258,6 @@ int main(void)
|
|||||||
|
|
||||||
system_set_bus_avr();
|
system_set_bus_avr();
|
||||||
system_set_wr_disable();
|
system_set_wr_disable();
|
||||||
/*
|
|
||||||
avr_bus_active();
|
|
||||||
info_P(PSTR("Activate AVR bus\n"));
|
|
||||||
info_P(PSTR("Disable SNES WR\n"));
|
|
||||||
snes_wr_disable();
|
|
||||||
*/
|
|
||||||
info_P(PSTR("USB poll\n"));
|
info_P(PSTR("USB poll\n"));
|
||||||
while (usb_trans.req_state != REQ_STATUS_SNES) {
|
while (usb_trans.req_state != REQ_STATUS_SNES) {
|
||||||
usbPoll();
|
usbPoll();
|
||||||
|
|||||||
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "neginf.h"
|
#include "neginf.h"
|
||||||
#include "neginf_priv.h"
|
#include "neginf_priv.h"
|
||||||
@ -46,8 +47,10 @@ void neginf_process_byte(nbyte byte)
|
|||||||
assert(state.queue_size <= 16);
|
assert(state.queue_size <= 16);
|
||||||
state.input_queue |= (byte << state.queue_size);
|
state.input_queue |= (byte << state.queue_size);
|
||||||
state.queue_size += 8;
|
state.queue_size += 8;
|
||||||
|
|
||||||
while(state.queue_size >= 16)
|
while(state.queue_size >= 16)
|
||||||
{
|
{
|
||||||
|
//printf("qsize=%i mode=%i\n",state.queue_size,state.mode);
|
||||||
mode_tab[state.mode]();
|
mode_tab[state.mode]();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -61,11 +64,13 @@ nsize neginf_output_position()
|
|||||||
|
|
||||||
nint lookahead()
|
nint lookahead()
|
||||||
{
|
{
|
||||||
|
//printf("lookahead\n");
|
||||||
return state.input_queue;
|
return state.input_queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void consume(ntiny amount)
|
void consume(ntiny amount)
|
||||||
{
|
{
|
||||||
|
//printf("consume %i %i\n",state.queue_size,amount);
|
||||||
assert(state.queue_size > amount);
|
assert(state.queue_size > amount);
|
||||||
state.input_queue >>= amount;
|
state.input_queue >>= amount;
|
||||||
state.queue_size -= amount;
|
state.queue_size -= amount;
|
||||||
@ -73,6 +78,7 @@ void consume(ntiny amount)
|
|||||||
|
|
||||||
void await_block()
|
void await_block()
|
||||||
{
|
{
|
||||||
|
//printf("wait block\n");
|
||||||
if(state.last_block)
|
if(state.last_block)
|
||||||
{
|
{
|
||||||
neginf_cb_completed();
|
neginf_cb_completed();
|
||||||
@ -103,6 +109,7 @@ void await_block()
|
|||||||
|
|
||||||
void raw_block_begin()
|
void raw_block_begin()
|
||||||
{
|
{
|
||||||
|
//printf("raw block begin\n");
|
||||||
state.raw_size = lookahead() & 0xFFFF; // size of raw block
|
state.raw_size = lookahead() & 0xFFFF; // size of raw block
|
||||||
consume(16);
|
consume(16);
|
||||||
state.mode = mode_raw_block_begin2;
|
state.mode = mode_raw_block_begin2;
|
||||||
@ -110,12 +117,14 @@ void raw_block_begin()
|
|||||||
|
|
||||||
void raw_block_begin2()
|
void raw_block_begin2()
|
||||||
{
|
{
|
||||||
|
//printf("raw block begin2\n");
|
||||||
consume(16); // we ignore the inverted size
|
consume(16); // we ignore the inverted size
|
||||||
state.mode = mode_raw_block;
|
state.mode = mode_raw_block;
|
||||||
}
|
}
|
||||||
|
|
||||||
void raw_block()
|
void raw_block()
|
||||||
{
|
{
|
||||||
|
//printf("raw block\n");
|
||||||
if(state.raw_size == 0)
|
if(state.raw_size == 0)
|
||||||
{
|
{
|
||||||
state.mode = mode_await_block;
|
state.mode = mode_await_block;
|
||||||
@ -133,6 +142,8 @@ void raw_block()
|
|||||||
|
|
||||||
void fixed_block_begin()
|
void fixed_block_begin()
|
||||||
{
|
{
|
||||||
|
//printf("fixed block begin\n");
|
||||||
|
|
||||||
nint i = 0;
|
nint i = 0;
|
||||||
for(; i < 144; i++)
|
for(; i < 144; i++)
|
||||||
state.lit_len_lengths[i] = 8;
|
state.lit_len_lengths[i] = 8;
|
||||||
@ -153,6 +164,7 @@ void fixed_block_begin()
|
|||||||
|
|
||||||
void huff_block()
|
void huff_block()
|
||||||
{
|
{
|
||||||
|
//printf("huff block\n");
|
||||||
nint code = lit_len_read();
|
nint code = lit_len_read();
|
||||||
if(code == 256)
|
if(code == 256)
|
||||||
{
|
{
|
||||||
@ -174,6 +186,7 @@ void huff_block()
|
|||||||
|
|
||||||
void huff_len_addbits()
|
void huff_len_addbits()
|
||||||
{
|
{
|
||||||
|
//printf("huff len addbits\n");
|
||||||
nint len;
|
nint len;
|
||||||
nint code = state.code;
|
nint code = state.code;
|
||||||
nint la = lookahead();
|
nint la = lookahead();
|
||||||
@ -214,12 +227,14 @@ void huff_len_addbits()
|
|||||||
|
|
||||||
void huff_dist()
|
void huff_dist()
|
||||||
{
|
{
|
||||||
|
//printf("huff dist\n");
|
||||||
state.tcode = dist_read();
|
state.tcode = dist_read();
|
||||||
state.mode = mode_huff_dist_addbits;
|
state.mode = mode_huff_dist_addbits;
|
||||||
}
|
}
|
||||||
|
|
||||||
void huff_dist_addbits()
|
void huff_dist_addbits()
|
||||||
{
|
{
|
||||||
|
//printf("huff addbits\n");
|
||||||
nint dist;
|
nint dist;
|
||||||
ntiny code = state.tcode;
|
ntiny code = state.tcode;
|
||||||
|
|
||||||
@ -250,6 +265,7 @@ void dynamic_block_begin()
|
|||||||
{
|
{
|
||||||
nint j;
|
nint j;
|
||||||
ntiny i;
|
ntiny i;
|
||||||
|
//printf("dynamic block begin\n");
|
||||||
for(j = 0; j < 288; j++)
|
for(j = 0; j < 288; j++)
|
||||||
state.lit_len_lengths[j] = 0;
|
state.lit_len_lengths[j] = 0;
|
||||||
for(i = 0; i < 32; i++)
|
for(i = 0; i < 32; i++)
|
||||||
@ -268,6 +284,7 @@ void dynamic_block_begin()
|
|||||||
|
|
||||||
void dynamic_read_lc()
|
void dynamic_read_lc()
|
||||||
{
|
{
|
||||||
|
//printf("dynamic read lc\n");
|
||||||
if(state.hclen == 0)
|
if(state.hclen == 0)
|
||||||
{
|
{
|
||||||
compute_begin(state.hc_lengths, state.hc_begins, 19);
|
compute_begin(state.hc_lengths, state.hc_begins, 19);
|
||||||
@ -290,6 +307,7 @@ void dynamic_read_lc()
|
|||||||
|
|
||||||
void dynamic_read_lit_len()
|
void dynamic_read_lit_len()
|
||||||
{
|
{
|
||||||
|
//printf("dynamic read lit len\n");
|
||||||
if(state.hlit == 0)
|
if(state.hlit == 0)
|
||||||
{
|
{
|
||||||
state.mode = mode_dynamic_read_dist;
|
state.mode = mode_dynamic_read_dist;
|
||||||
@ -303,6 +321,7 @@ void dynamic_read_lit_len()
|
|||||||
|
|
||||||
void dynamic_read_dist()
|
void dynamic_read_dist()
|
||||||
{
|
{
|
||||||
|
//printf("dynamic read dist\n");
|
||||||
if(state.hdist == 0)
|
if(state.hdist == 0)
|
||||||
{
|
{
|
||||||
compute_begins();
|
compute_begins();
|
||||||
@ -316,6 +335,7 @@ void dynamic_read_dist()
|
|||||||
|
|
||||||
ntiny lc_read(ntiny * lenghts)
|
ntiny lc_read(ntiny * lenghts)
|
||||||
{
|
{
|
||||||
|
//printf("read lc\n");
|
||||||
ntiny code = huff_read(state.hc_lengths, state.hc_begins, 19);
|
ntiny code = huff_read(state.hc_lengths, state.hc_begins, 19);
|
||||||
// this reads 7 bits max so we still have 9 bits left in the buffer
|
// this reads 7 bits max so we still have 9 bits left in the buffer
|
||||||
if(code < 16)
|
if(code < 16)
|
||||||
@ -361,6 +381,7 @@ ntiny lc_read(ntiny * lenghts)
|
|||||||
|
|
||||||
void compute_begins()
|
void compute_begins()
|
||||||
{
|
{
|
||||||
|
//printf("compute begins\n");
|
||||||
compute_begin(state.lit_len_lengths, state.lit_len_begins, 288);
|
compute_begin(state.lit_len_lengths, state.lit_len_begins, 288);
|
||||||
compute_begin(state.dist_lengths, state.dist_begins, 32);
|
compute_begin(state.dist_lengths, state.dist_begins, 32);
|
||||||
}
|
}
|
||||||
@ -370,6 +391,7 @@ void compute_begin(ntiny * lengths, nint * begins, nint size)
|
|||||||
{
|
{
|
||||||
ntiny j;
|
ntiny j;
|
||||||
nint i;
|
nint i;
|
||||||
|
//printf("compute begin\n");
|
||||||
for(j = 0; j < 14; j++)
|
for(j = 0; j < 14; j++)
|
||||||
begins[j] = 0;
|
begins[j] = 0;
|
||||||
for(i = 0; i < size; i++)
|
for(i = 0; i < size; i++)
|
||||||
@ -389,16 +411,20 @@ void compute_begin(ntiny * lengths, nint * begins, nint size)
|
|||||||
|
|
||||||
nint lit_len_read()
|
nint lit_len_read()
|
||||||
{
|
{
|
||||||
|
//printf("lit len read\n");
|
||||||
|
|
||||||
return huff_read(state.lit_len_lengths, state.lit_len_begins, 288);
|
return huff_read(state.lit_len_lengths, state.lit_len_begins, 288);
|
||||||
}
|
}
|
||||||
|
|
||||||
nint dist_read()
|
nint dist_read()
|
||||||
{
|
{
|
||||||
|
//printf("dist read\n");
|
||||||
return huff_read(state.dist_lengths, state.dist_begins, 32);
|
return huff_read(state.dist_lengths, state.dist_begins, 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
nint huff_read(ntiny * lenghts, nint * begins, nint size)
|
nint huff_read(ntiny * lenghts, nint * begins, nint size)
|
||||||
{
|
{
|
||||||
|
//printf("huff read\n");
|
||||||
nint code = 0;
|
nint code = 0;
|
||||||
ntiny i;
|
ntiny i;
|
||||||
for(i = 1; i < 16; i++)
|
for(i = 1; i < 16; i++)
|
||||||
@ -421,7 +447,7 @@ nint huff_read(ntiny * lenghts, nint * begins, nint size)
|
|||||||
code--;
|
code--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assert(0);
|
//assert(0);
|
||||||
return 0; // silent warning
|
return 0; // silent warning
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
//#define NEGINF_USE_REL_COPY
|
//#define NEGINF_USE_REL_COPY
|
||||||
//#define NEGINF_POS_TRACKING
|
//#define NEGINF_POS_TRACKING
|
||||||
|
|
||||||
#define NEGINF_8BIT
|
//#define NEGINF_8BIT
|
||||||
#define NEGINF_PACKED_STATE
|
#define NEGINF_PACKED_STATE
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
<plist version="1.0">
|
<plist version="1.0">
|
||||||
<dict>
|
<dict>
|
||||||
<key>currentDocument</key>
|
<key>currentDocument</key>
|
||||||
<string>avr/usbload/shell.c</string>
|
<string>avr/usbload/neginf/neginf.c</string>
|
||||||
<key>documents</key>
|
<key>documents</key>
|
||||||
<array>
|
<array>
|
||||||
<dict>
|
<dict>
|
||||||
@ -40,14 +40,28 @@
|
|||||||
<key>caret</key>
|
<key>caret</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>column</key>
|
<key>column</key>
|
||||||
<integer>1</integer>
|
<integer>12</integer>
|
||||||
<key>line</key>
|
<key>line</key>
|
||||||
<integer>100</integer>
|
<integer>87</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>firstVisibleColumn</key>
|
<key>firstVisibleColumn</key>
|
||||||
<integer>0</integer>
|
<integer>0</integer>
|
||||||
<key>firstVisibleLine</key>
|
<key>firstVisibleLine</key>
|
||||||
<integer>122</integer>
|
<integer>63</integer>
|
||||||
|
</dict>
|
||||||
|
<key>avr/usbload/command.h</key>
|
||||||
|
<dict>
|
||||||
|
<key>caret</key>
|
||||||
|
<dict>
|
||||||
|
<key>column</key>
|
||||||
|
<integer>0</integer>
|
||||||
|
<key>line</key>
|
||||||
|
<integer>24</integer>
|
||||||
|
</dict>
|
||||||
|
<key>firstVisibleColumn</key>
|
||||||
|
<integer>0</integer>
|
||||||
|
<key>firstVisibleLine</key>
|
||||||
|
<integer>0</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>avr/usbload/config.h</key>
|
<key>avr/usbload/config.h</key>
|
||||||
<dict>
|
<dict>
|
||||||
@ -56,12 +70,12 @@
|
|||||||
<key>column</key>
|
<key>column</key>
|
||||||
<integer>37</integer>
|
<integer>37</integer>
|
||||||
<key>line</key>
|
<key>line</key>
|
||||||
<integer>54</integer>
|
<integer>50</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>firstVisibleColumn</key>
|
<key>firstVisibleColumn</key>
|
||||||
<integer>0</integer>
|
<integer>0</integer>
|
||||||
<key>firstVisibleLine</key>
|
<key>firstVisibleLine</key>
|
||||||
<integer>7</integer>
|
<integer>8</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>avr/usbload/crc.c</key>
|
<key>avr/usbload/crc.c</key>
|
||||||
<dict>
|
<dict>
|
||||||
@ -89,7 +103,91 @@
|
|||||||
<key>firstVisibleColumn</key>
|
<key>firstVisibleColumn</key>
|
||||||
<integer>0</integer>
|
<integer>0</integer>
|
||||||
<key>firstVisibleLine</key>
|
<key>firstVisibleLine</key>
|
||||||
<integer>1</integer>
|
<integer>19</integer>
|
||||||
|
</dict>
|
||||||
|
<key>avr/usbload/debug.h</key>
|
||||||
|
<dict>
|
||||||
|
<key>caret</key>
|
||||||
|
<dict>
|
||||||
|
<key>column</key>
|
||||||
|
<integer>0</integer>
|
||||||
|
<key>line</key>
|
||||||
|
<integer>0</integer>
|
||||||
|
</dict>
|
||||||
|
<key>firstVisibleColumn</key>
|
||||||
|
<integer>0</integer>
|
||||||
|
<key>firstVisibleLine</key>
|
||||||
|
<integer>0</integer>
|
||||||
|
</dict>
|
||||||
|
<key>avr/usbload/dump.c</key>
|
||||||
|
<dict>
|
||||||
|
<key>caret</key>
|
||||||
|
<dict>
|
||||||
|
<key>column</key>
|
||||||
|
<integer>15</integer>
|
||||||
|
<key>line</key>
|
||||||
|
<integer>28</integer>
|
||||||
|
</dict>
|
||||||
|
<key>firstVisibleColumn</key>
|
||||||
|
<integer>0</integer>
|
||||||
|
<key>firstVisibleLine</key>
|
||||||
|
<integer>33</integer>
|
||||||
|
</dict>
|
||||||
|
<key>avr/usbload/fifo.c</key>
|
||||||
|
<dict>
|
||||||
|
<key>caret</key>
|
||||||
|
<dict>
|
||||||
|
<key>column</key>
|
||||||
|
<integer>17</integer>
|
||||||
|
<key>line</key>
|
||||||
|
<integer>22</integer>
|
||||||
|
</dict>
|
||||||
|
<key>firstVisibleColumn</key>
|
||||||
|
<integer>0</integer>
|
||||||
|
<key>firstVisibleLine</key>
|
||||||
|
<integer>0</integer>
|
||||||
|
</dict>
|
||||||
|
<key>avr/usbload/fifo.h</key>
|
||||||
|
<dict>
|
||||||
|
<key>caret</key>
|
||||||
|
<dict>
|
||||||
|
<key>column</key>
|
||||||
|
<integer>0</integer>
|
||||||
|
<key>line</key>
|
||||||
|
<integer>19</integer>
|
||||||
|
</dict>
|
||||||
|
<key>firstVisibleColumn</key>
|
||||||
|
<integer>0</integer>
|
||||||
|
<key>firstVisibleLine</key>
|
||||||
|
<integer>0</integer>
|
||||||
|
</dict>
|
||||||
|
<key>avr/usbload/inflate.c</key>
|
||||||
|
<dict>
|
||||||
|
<key>caret</key>
|
||||||
|
<dict>
|
||||||
|
<key>column</key>
|
||||||
|
<integer>0</integer>
|
||||||
|
<key>line</key>
|
||||||
|
<integer>48</integer>
|
||||||
|
</dict>
|
||||||
|
<key>firstVisibleColumn</key>
|
||||||
|
<integer>0</integer>
|
||||||
|
<key>firstVisibleLine</key>
|
||||||
|
<integer>20</integer>
|
||||||
|
</dict>
|
||||||
|
<key>avr/usbload/inflate.h</key>
|
||||||
|
<dict>
|
||||||
|
<key>caret</key>
|
||||||
|
<dict>
|
||||||
|
<key>column</key>
|
||||||
|
<integer>0</integer>
|
||||||
|
<key>line</key>
|
||||||
|
<integer>0</integer>
|
||||||
|
</dict>
|
||||||
|
<key>firstVisibleColumn</key>
|
||||||
|
<integer>0</integer>
|
||||||
|
<key>firstVisibleLine</key>
|
||||||
|
<integer>0</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>avr/usbload/irq.c</key>
|
<key>avr/usbload/irq.c</key>
|
||||||
<dict>
|
<dict>
|
||||||
@ -121,6 +219,34 @@
|
|||||||
<integer>39</integer>
|
<integer>39</integer>
|
||||||
</dict>
|
</dict>
|
||||||
</dict>
|
</dict>
|
||||||
|
<key>avr/usbload/loader.c</key>
|
||||||
|
<dict>
|
||||||
|
<key>caret</key>
|
||||||
|
<dict>
|
||||||
|
<key>column</key>
|
||||||
|
<integer>0</integer>
|
||||||
|
<key>line</key>
|
||||||
|
<integer>0</integer>
|
||||||
|
</dict>
|
||||||
|
<key>firstVisibleColumn</key>
|
||||||
|
<integer>0</integer>
|
||||||
|
<key>firstVisibleLine</key>
|
||||||
|
<integer>2068</integer>
|
||||||
|
</dict>
|
||||||
|
<key>avr/usbload/loader.h</key>
|
||||||
|
<dict>
|
||||||
|
<key>caret</key>
|
||||||
|
<dict>
|
||||||
|
<key>column</key>
|
||||||
|
<integer>0</integer>
|
||||||
|
<key>line</key>
|
||||||
|
<integer>0</integer>
|
||||||
|
</dict>
|
||||||
|
<key>firstVisibleColumn</key>
|
||||||
|
<integer>0</integer>
|
||||||
|
<key>firstVisibleLine</key>
|
||||||
|
<integer>0</integer>
|
||||||
|
</dict>
|
||||||
<key>avr/usbload/main.c</key>
|
<key>avr/usbload/main.c</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>caret</key>
|
<key>caret</key>
|
||||||
@ -128,12 +254,112 @@
|
|||||||
<key>column</key>
|
<key>column</key>
|
||||||
<integer>0</integer>
|
<integer>0</integer>
|
||||||
<key>line</key>
|
<key>line</key>
|
||||||
<integer>330</integer>
|
<integer>260</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>firstVisibleColumn</key>
|
<key>firstVisibleColumn</key>
|
||||||
<integer>0</integer>
|
<integer>0</integer>
|
||||||
<key>firstVisibleLine</key>
|
<key>firstVisibleLine</key>
|
||||||
<integer>281</integer>
|
<integer>253</integer>
|
||||||
|
</dict>
|
||||||
|
<key>avr/usbload/neginf/neginf.c</key>
|
||||||
|
<dict>
|
||||||
|
<key>caret</key>
|
||||||
|
<dict>
|
||||||
|
<key>column</key>
|
||||||
|
<integer>10</integer>
|
||||||
|
<key>line</key>
|
||||||
|
<integer>4</integer>
|
||||||
|
</dict>
|
||||||
|
<key>firstVisibleColumn</key>
|
||||||
|
<integer>0</integer>
|
||||||
|
<key>firstVisibleLine</key>
|
||||||
|
<integer>4</integer>
|
||||||
|
</dict>
|
||||||
|
<key>avr/usbload/neginf/neginf.h</key>
|
||||||
|
<dict>
|
||||||
|
<key>caret</key>
|
||||||
|
<dict>
|
||||||
|
<key>column</key>
|
||||||
|
<integer>0</integer>
|
||||||
|
<key>line</key>
|
||||||
|
<integer>0</integer>
|
||||||
|
</dict>
|
||||||
|
<key>firstVisibleColumn</key>
|
||||||
|
<integer>0</integer>
|
||||||
|
<key>firstVisibleLine</key>
|
||||||
|
<integer>0</integer>
|
||||||
|
</dict>
|
||||||
|
<key>avr/usbload/neginf/neginf_conf.h</key>
|
||||||
|
<dict>
|
||||||
|
<key>caret</key>
|
||||||
|
<dict>
|
||||||
|
<key>column</key>
|
||||||
|
<integer>0</integer>
|
||||||
|
<key>line</key>
|
||||||
|
<integer>0</integer>
|
||||||
|
</dict>
|
||||||
|
<key>firstVisibleColumn</key>
|
||||||
|
<integer>0</integer>
|
||||||
|
<key>firstVisibleLine</key>
|
||||||
|
<integer>0</integer>
|
||||||
|
</dict>
|
||||||
|
<key>avr/usbload/neginf/neginf_priv.h</key>
|
||||||
|
<dict>
|
||||||
|
<key>caret</key>
|
||||||
|
<dict>
|
||||||
|
<key>column</key>
|
||||||
|
<integer>0</integer>
|
||||||
|
<key>line</key>
|
||||||
|
<integer>63</integer>
|
||||||
|
</dict>
|
||||||
|
<key>columnSelection</key>
|
||||||
|
<false/>
|
||||||
|
<key>firstVisibleColumn</key>
|
||||||
|
<integer>0</integer>
|
||||||
|
<key>firstVisibleLine</key>
|
||||||
|
<integer>21</integer>
|
||||||
|
<key>selectFrom</key>
|
||||||
|
<dict>
|
||||||
|
<key>column</key>
|
||||||
|
<integer>0</integer>
|
||||||
|
<key>line</key>
|
||||||
|
<integer>51</integer>
|
||||||
|
</dict>
|
||||||
|
<key>selectTo</key>
|
||||||
|
<dict>
|
||||||
|
<key>column</key>
|
||||||
|
<integer>0</integer>
|
||||||
|
<key>line</key>
|
||||||
|
<integer>63</integer>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<key>avr/usbload/pwm.c</key>
|
||||||
|
<dict>
|
||||||
|
<key>caret</key>
|
||||||
|
<dict>
|
||||||
|
<key>column</key>
|
||||||
|
<integer>4</integer>
|
||||||
|
<key>line</key>
|
||||||
|
<integer>88</integer>
|
||||||
|
</dict>
|
||||||
|
<key>firstVisibleColumn</key>
|
||||||
|
<integer>0</integer>
|
||||||
|
<key>firstVisibleLine</key>
|
||||||
|
<integer>51</integer>
|
||||||
|
</dict>
|
||||||
|
<key>avr/usbload/pwm.h</key>
|
||||||
|
<dict>
|
||||||
|
<key>caret</key>
|
||||||
|
<dict>
|
||||||
|
<key>column</key>
|
||||||
|
<integer>20</integer>
|
||||||
|
<key>line</key>
|
||||||
|
<integer>33</integer>
|
||||||
|
</dict>
|
||||||
|
<key>firstVisibleColumn</key>
|
||||||
|
<integer>0</integer>
|
||||||
|
<key>firstVisibleLine</key>
|
||||||
|
<integer>0</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>avr/usbload/shared_memory.c</key>
|
<key>avr/usbload/shared_memory.c</key>
|
||||||
<dict>
|
<dict>
|
||||||
@ -154,7 +380,7 @@
|
|||||||
<key>caret</key>
|
<key>caret</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>column</key>
|
<key>column</key>
|
||||||
<integer>83</integer>
|
<integer>9</integer>
|
||||||
<key>line</key>
|
<key>line</key>
|
||||||
<integer>444</integer>
|
<integer>444</integer>
|
||||||
</dict>
|
</dict>
|
||||||
@ -280,6 +506,9 @@
|
|||||||
<array>
|
<array>
|
||||||
<string>scripts/conv_rle.py</string>
|
<string>scripts/conv_rle.py</string>
|
||||||
<string>avr/usbload/main.c</string>
|
<string>avr/usbload/main.c</string>
|
||||||
|
<string>avr/usbload/dump.c</string>
|
||||||
|
<string>avr/usbload/pwm.h</string>
|
||||||
|
<string>avr/usbload/pwm.c</string>
|
||||||
<string>avr/usbload/shell.h</string>
|
<string>avr/usbload/shell.h</string>
|
||||||
<string>avr/usbload/shell.c</string>
|
<string>avr/usbload/shell.c</string>
|
||||||
<string>scripts/conv_zip.py</string>
|
<string>scripts/conv_zip.py</string>
|
||||||
@ -289,8 +518,20 @@
|
|||||||
<string>avr/usbload/sram.h</string>
|
<string>avr/usbload/sram.h</string>
|
||||||
<string>avr/usbload/sram.c</string>
|
<string>avr/usbload/sram.c</string>
|
||||||
<string>avr/usbload/command.c</string>
|
<string>avr/usbload/command.c</string>
|
||||||
|
<string>avr/usbload/inflate.c</string>
|
||||||
|
<string>avr/usbload/neginf/neginf.h</string>
|
||||||
|
<string>avr/usbload/neginf/neginf_conf.h</string>
|
||||||
|
<string>avr/usbload/neginf/neginf_priv.h</string>
|
||||||
|
<string>avr/usbload/neginf/neginf.c</string>
|
||||||
|
<string>avr/usbload/inflate.h</string>
|
||||||
|
<string>avr/usbload/loader.h</string>
|
||||||
|
<string>avr/usbload/loader.c</string>
|
||||||
|
<string>avr/usbload/command.h</string>
|
||||||
<string>avr/usbload/crc.c</string>
|
<string>avr/usbload/crc.c</string>
|
||||||
<string>avr/usbload/config.h</string>
|
<string>avr/usbload/config.h</string>
|
||||||
|
<string>avr/usbload/fifo.h</string>
|
||||||
|
<string>avr/usbload/fifo.c</string>
|
||||||
|
<string>avr/usbload/debug.h</string>
|
||||||
<string>avr/usbload/debug.c</string>
|
<string>avr/usbload/debug.c</string>
|
||||||
<string>avr/usbload/irq.c</string>
|
<string>avr/usbload/irq.c</string>
|
||||||
</array>
|
</array>
|
||||||
@ -317,7 +558,15 @@
|
|||||||
<key>isExpanded</key>
|
<key>isExpanded</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>subItems</key>
|
<key>subItems</key>
|
||||||
<dict/>
|
<dict>
|
||||||
|
<key>neginf</key>
|
||||||
|
<dict>
|
||||||
|
<key>isExpanded</key>
|
||||||
|
<true/>
|
||||||
|
<key>subItems</key>
|
||||||
|
<dict/>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
</dict>
|
</dict>
|
||||||
</dict>
|
</dict>
|
||||||
</dict>
|
</dict>
|
||||||
|
|||||||
78
scripts/conv_zip_test.py
Normal file
78
scripts/conv_zip_test.py
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
import binascii
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
import shutil
|
||||||
|
|
||||||
|
LEN = 2**16
|
||||||
|
huffman = False
|
||||||
|
TARGET=os.getcwd()
|
||||||
|
SOURCE=sys.argv[1]
|
||||||
|
DEFLATE=os.path.basename(sys.argv[1]) + ".deflate"
|
||||||
|
PATH="/Users/david/Devel/arch/avr/code/quickdev16/scripts"
|
||||||
|
|
||||||
|
WINE="/Applications/Darwine/Wine.bundle/Contents/bin/wine"
|
||||||
|
KZIP=os.path.join(PATH,"kzip.exe")
|
||||||
|
DEFLOPT=os.path.join(PATH,"DeflOpt.exe")
|
||||||
|
ZIP2RAW=os.path.join(PATH,"zip2raw.rb")
|
||||||
|
|
||||||
|
method = 1
|
||||||
|
|
||||||
|
if method==0:
|
||||||
|
if os.path.isfile("rom.zip"):
|
||||||
|
os.unlink("rom.zip")
|
||||||
|
|
||||||
|
os.system("%s %s rom /s1 %s" % (WINE,KZIP,SOURCE))
|
||||||
|
os.system("%s %s /a rom.zip" % (WINE,DEFLOPT))
|
||||||
|
os.system("ruby %s rom.zip" % ZIP2RAW)
|
||||||
|
|
||||||
|
if os.path.isfile("rom.zip"):
|
||||||
|
os.unlink("rom.zip")
|
||||||
|
data = open(DEFLATE).read()
|
||||||
|
os.unlink(DEFLATE)
|
||||||
|
else:
|
||||||
|
os.system("gzip < %s >/tmp/test" % SOURCE )
|
||||||
|
data = open("/tmp/test").read()
|
||||||
|
os.unlink("/tmp/test")
|
||||||
|
data = data[10:]
|
||||||
|
|
||||||
|
zip_size = len(data)
|
||||||
|
cfile = open("/tmp/loader_test.c","w")
|
||||||
|
hfile = open("/tmp/loader_test.h","w")
|
||||||
|
|
||||||
|
|
||||||
|
hfile.write('''
|
||||||
|
#ifndef __FIFO_H__
|
||||||
|
#define __FIFO_H__
|
||||||
|
|
||||||
|
#define ROM_ZIP_SIZE %i
|
||||||
|
''' % zip_size)
|
||||||
|
hfile.write('\n#endif\n')
|
||||||
|
hfile.close()
|
||||||
|
|
||||||
|
cfile.write('''/*
|
||||||
|
File: %s
|
||||||
|
Time: %s
|
||||||
|
*/
|
||||||
|
''')
|
||||||
|
|
||||||
|
|
||||||
|
cfile.write('''
|
||||||
|
const char _rom[%i] = {
|
||||||
|
''' % (zip_size))
|
||||||
|
for idx,c in enumerate(data):
|
||||||
|
c = ord(c)
|
||||||
|
if idx<len(data)-1:
|
||||||
|
cfile.write("0x%02x," % c)
|
||||||
|
else:
|
||||||
|
cfile.write("0x%02x" % c)
|
||||||
|
if idx and idx%16==0:
|
||||||
|
cfile.write("\n")
|
||||||
|
cfile.write('''
|
||||||
|
};
|
||||||
|
''')
|
||||||
|
|
||||||
|
cfile.close()
|
||||||
|
|
||||||
|
shutil.copy("/tmp/loader_test.c", os.path.join(TARGET,"loader_test.c"))
|
||||||
|
shutil.copy("/tmp/loader_test.h", os.path.join(TARGET,"loader_test.h"))
|
||||||
Loading…
x
Reference in New Issue
Block a user